-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Feature): Scheduled weekly report (#599)
- [x] New feature - [ ] Bug fix - [ ] High impact **Description of work:** **Testing:** - [x] Can be tested - [ ] Automatic tests created / updated - [ ] ~~Local tests are passing~~ **Checklist:** - [ ] Considered automated tests - [ ] Considered updating specification / documentation - [ ] Considered work items - [ ] Considered security - [ ] Performed developer testing - [ ] Checklist finalized / ready for review --------- Co-authored-by: Aleksander Lund <[email protected]>
- Loading branch information
1 parent
cc1975f
commit 0265d56
Showing
20 changed files
with
902 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/backend/function/Fusion.Resources.Functions/ApiClients/ApiModels/LineOrg.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
|
||
namespace Fusion.Resources.Functions.ApiClients.ApiModels; | ||
|
||
public class LineOrgPersonsResponse | ||
{ | ||
[JsonProperty("totalCount")] public int TotalCount { get; set; } | ||
|
||
[JsonProperty("count")] public int Count { get; set; } | ||
|
||
[JsonProperty("@nextPage")] public object NextPage { get; set; } | ||
|
||
[JsonProperty("value")] public List<LineOrgPerson> Value { get; set; } | ||
} | ||
public class Manager | ||
{ | ||
[JsonProperty("azureUniqueId")] public string AzureUniqueId { get; set; } | ||
|
||
[JsonProperty("mail")] public string Mail { get; set; } | ||
|
||
[JsonProperty("department")] public string Department { get; set; } | ||
|
||
[JsonProperty("fullDepartment")] public string FullDepartment { get; set; } | ||
|
||
[JsonProperty("name")] public string Name { get; set; } | ||
|
||
[JsonProperty("jobTitle")] public string JobTitle { get; set; } | ||
} | ||
public class LineOrgPerson | ||
{ | ||
[JsonProperty("azureUniqueId")] public string AzureUniqueId { get; set; } | ||
|
||
[JsonProperty("managerId")] public string ManagerId { get; set; } | ||
|
||
[JsonProperty("manager")] public Manager Manager { get; set; } | ||
|
||
[JsonProperty("department")] public string Department { get; set; } | ||
|
||
[JsonProperty("fullDepartment")] public string FullDepartment { get; set; } | ||
|
||
[JsonProperty("name")] public string Name { get; set; } | ||
|
||
[JsonProperty("givenName")] public string GivenName { get; set; } | ||
|
||
[JsonProperty("surname")] public string Surname { get; set; } | ||
|
||
[JsonProperty("jobTitle")] public string JobTitle { get; set; } | ||
|
||
[JsonProperty("mail")] public string Mail { get; set; } | ||
|
||
[JsonProperty("country")] public string Country { get; set; } | ||
|
||
[JsonProperty("phone")] public string Phone { get; set; } | ||
|
||
[JsonProperty("officeLocation")] public string OfficeLocation { get; set; } | ||
|
||
[JsonProperty("userType")] public string UserType { get; set; } | ||
|
||
[JsonProperty("isResourceOwner")] public bool IsResourceOwner { get; set; } | ||
|
||
[JsonProperty("hasChildPositions")] public bool HasChildPositions { get; set; } | ||
|
||
[JsonProperty("hasOfficeLicense")] public bool HasOfficeLicense { get; set; } | ||
|
||
[JsonProperty("created")] public DateTime Created { get; set; } | ||
|
||
[JsonProperty("updated")] public DateTime Updated { get; set; } | ||
|
||
[JsonProperty("lastSyncDate")] public DateTime LastSyncDate { get; set; } | ||
} |
15 changes: 15 additions & 0 deletions
15
src/backend/function/Fusion.Resources.Functions/ApiClients/ApiModels/Notifications.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
|
||
namespace Fusion.Resources.Functions.ApiClients.ApiModels; | ||
|
||
public class SendNotificationsRequest | ||
{ | ||
[JsonProperty("emailPriority")] public int EmailPriority { get; set; } | ||
|
||
[JsonProperty("title")] public string Title { get; set; } | ||
|
||
[JsonProperty("description")] public string Description { get; set; } | ||
|
||
[JsonProperty("card")] public object Card { get; set; } | ||
} |
2 changes: 2 additions & 0 deletions
2
src/backend/function/Fusion.Resources.Functions/ApiClients/ILineOrgApiClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Fusion.Resources.Functions.ApiClients.ApiModels; | ||
|
||
namespace Fusion.Resources.Functions.ApiClients; | ||
|
||
public interface ILineOrgApiClient | ||
{ | ||
Task<IEnumerable<string>> GetOrgUnitDepartmentsAsync(); | ||
Task<List<LineOrgPerson>> GetResourceOwnersFromFullDepartment(List<string> fullDepartments); | ||
} |
10 changes: 10 additions & 0 deletions
10
src/backend/function/Fusion.Resources.Functions/ApiClients/INotificationApiClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Fusion.Resources.Functions.ApiClients.ApiModels; | ||
|
||
namespace Fusion.Resources.Functions.ApiClients; | ||
|
||
public interface INotificationApiClient | ||
{ | ||
Task<bool> SendNotification(SendNotificationsRequest request, Guid azureUniqueId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/backend/function/Fusion.Resources.Functions/ApiClients/NotificationApiClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Fusion.Resources.Functions.ApiClients.ApiModels; | ||
using Newtonsoft.Json; | ||
|
||
namespace Fusion.Resources.Functions.ApiClients; | ||
|
||
public class NotificationApiClient : INotificationApiClient | ||
{ | ||
private readonly HttpClient _client; | ||
|
||
public NotificationApiClient(IHttpClientFactory httpClientFactory) | ||
{ | ||
_client = httpClientFactory.CreateClient(HttpClientNames.Application.Notifications); | ||
} | ||
|
||
public async Task<bool> SendNotification(SendNotificationsRequest request, Guid azureUniqueId) | ||
{ | ||
var content = JsonConvert.SerializeObject(request); | ||
var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); | ||
|
||
var response = await _client.PostAsync($"/persons/{azureUniqueId}/notifications?api-version=1.0", | ||
stringContent); | ||
|
||
return response.IsSuccessStatusCode; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...es.Functions/Functions/Notifications/Models/AdaptiveCard/ResourceOwnerAdaptiveCardData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Fusion.Resources.Functions.Functions.Notifications.Models.AdaptiveCard; | ||
|
||
public class ResourceOwnerAdaptiveCardData | ||
{ | ||
public int TotalNumberOfRequests { get; set; } | ||
public int NumberOfOlderRequests { get; set; } | ||
public int NumberOfNewRequestsWithNoNomination { get; set; } | ||
public int NumberOfOpenRequests { get; set; } | ||
internal IEnumerable<PersonnelContent> PersonnelPositionsEndingWithNoFutureAllocation { get; set; } | ||
public int PercentAllocationOfTotalCapacity { get; set; } | ||
internal IEnumerable<PersonnelContent> PersonnelAllocatedMoreThan100Percent { get; set; } | ||
public int NumberOfExtContractsEnding { get; set; } | ||
} |
13 changes: 13 additions & 0 deletions
13
....Resources.Functions/Functions/Notifications/Models/DTOs/ScheduledNotificationQueueDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Fusion.Resources.Functions.Functions.Notifications.Models.DTOs; | ||
|
||
public class ScheduledNotificationQueueDto | ||
{ | ||
public string AzureUniqueId { get; set; } | ||
public string FullDepartment { get; set; } | ||
public NotificationRoleType Role { get; set; } | ||
} | ||
public enum NotificationRoleType | ||
{ | ||
ResourceOwner, | ||
TaskOwner | ||
} |
Oops, something went wrong.