-
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.
feat: Remove old bemanning and integrate with Vibes
- Loading branch information
Showing
14 changed files
with
134 additions
and
141 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
namespace Infrastructure.ApiClients.DTOs; | ||
|
||
public class VibesEmploymentDTO | ||
{ | ||
public VibesEmploymentDTO(string email, DateTime? startDate, DateTime? endDate) | ||
{ | ||
this.email = email; | ||
this.startDate = startDate; | ||
this.endDate = endDate; | ||
} | ||
|
||
public string email { get; set; } | ||
public DateTime? startDate { get; set; } | ||
public DateTime? endDate { get; set; } | ||
} |
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,7 @@ | ||
namespace Infrastructure.ApiClients.DTOs; | ||
|
||
public class VibesOrganisationDTO | ||
{ | ||
public string Name { get; set; } | ||
public string UrlKey { get; set; } | ||
} |
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,14 @@ | ||
using Infrastructure.ApiClients.DTOs; | ||
using Refit; | ||
|
||
namespace Infrastructure.ApiClients; | ||
|
||
[Headers("Authorization: Bearer")] | ||
public interface IVibesApiClient | ||
{ | ||
[Get("/v0/organisations")] | ||
Task<IEnumerable<VibesOrganisationDTO>> GetOrganisations(); | ||
|
||
[Get("/v0/{companyCountry}/consultants/employment")] | ||
Task<IEnumerable<VibesEmploymentDTO>> GetEmploymentDates(string companyCountry); | ||
} |
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 was deleted.
Oops, something went wrong.
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,31 @@ | ||
using Infrastructure.ApiClients; | ||
using Infrastructure.ApiClients.DTOs; | ||
|
||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Infrastructure.Repositories; | ||
|
||
public class VibesRepository | ||
{ | ||
private readonly IVibesApiClient _vibesApiClient; | ||
private readonly ILogger<VibesRepository> _logger; | ||
|
||
public VibesRepository(IVibesApiClient vibesApiClient, ILogger<VibesRepository> logger) | ||
{ | ||
_vibesApiClient = vibesApiClient; | ||
_logger = logger; | ||
} | ||
public async Task<List<VibesEmploymentDTO>> GetEmployment() | ||
{ | ||
_logger.LogInformation("VibesRepository.GetEmployment: Fetching employee start and end dates from Vibes/Bemanning"); | ||
|
||
var organisationResponse = await _vibesApiClient.GetOrganisations(); | ||
|
||
var getEmploymentTasks = organisationResponse.Select(async organisationDto => | ||
await _vibesApiClient.GetEmploymentDates(organisationDto.UrlKey)); | ||
|
||
var apiResponses = await Task.WhenAll(getEmploymentTasks); | ||
|
||
return apiResponses.SelectMany(response => response).ToList(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Net.Http.Headers; | ||
|
||
using Azure.Core; | ||
|
||
namespace Shared.AzureIdentity; | ||
|
||
public class RefitBearerTokenHandler : DelegatingHandler | ||
{ | ||
private readonly TokenCredential _credential; | ||
private readonly string _scope; | ||
|
||
public RefitBearerTokenHandler(TokenCredential credential, string scope) | ||
{ | ||
_credential = credential ?? throw new ArgumentNullException(nameof(credential)); | ||
_scope = scope ?? throw new ArgumentNullException(nameof(scope)); | ||
} | ||
|
||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | ||
{ | ||
var token = await _credential.GetTokenAsync(new TokenRequestContext(new[] { _scope }), cancellationToken); | ||
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token.Token); | ||
return await base.SendAsync(request, cancellationToken); | ||
} | ||
} |
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
Oops, something went wrong.