-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
it now checks to see whether the user is non levy or they are a levy …
…that is currently receving transfer funds for TM-133
- Loading branch information
Showing
9 changed files
with
136 additions
and
18 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
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
21 changes: 21 additions & 0 deletions
21
src/SFA.DAS.EmployerFinance/Infrastructure/OuterApiRequests/GetCohortsRequest.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,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using SFA.DAS.EmployerFinance.Interfaces.OuterApi; | ||
|
||
namespace SFA.DAS.EmployerFinance.Infrastructure.OuterApiRequests | ||
{ | ||
public class GetCohortsRequest : IGetApiRequest | ||
{ | ||
private readonly long _accountId; | ||
|
||
public GetCohortsRequest(long accountId) | ||
{ | ||
_accountId = accountId; | ||
} | ||
|
||
public string GetUrl => $"api/cohorts?accountId={_accountId}"; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/SFA.DAS.EmployerFinance/Models/Cohort/CurrentCohorts.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,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using SFA.DAS.CommitmentsV2.Types; | ||
|
||
namespace SFA.DAS.EmployerFinance.Models.Cohort | ||
{ | ||
public class CurrentCohorts | ||
{ | ||
public List<CohortSummary> Cohorts { 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
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,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Newtonsoft.Json; | ||
using SFA.DAS.CommitmentsV2.Types; | ||
using SFA.DAS.EmployerFinance.Configuration; | ||
using SFA.DAS.EmployerFinance.Infrastructure.OuterApiRequests; | ||
using SFA.DAS.EmployerFinance.Infrastructure.OuterApiResponses; | ||
using SFA.DAS.EmployerFinance.Interfaces.OuterApi; | ||
using SFA.DAS.EmployerFinance.Models.Cohort; | ||
|
||
namespace SFA.DAS.EmployerFinance.Services | ||
{ | ||
public class CohortsService : ICohortsService | ||
{ | ||
private readonly HttpClient _httpClient; | ||
|
||
public CohortsService(HttpClient httpClient, string cohortsBaseUrl) | ||
{ | ||
_httpClient = httpClient; | ||
_httpClient.BaseAddress = new Uri(cohortsBaseUrl); | ||
} | ||
|
||
public async Task<int> GetCohortsCount(long accountId) | ||
{ | ||
var cohortsCountResponse = await _httpClient.GetAsync(new GetCohortsRequest(accountId).GetUrl).ConfigureAwait(false); | ||
|
||
cohortsCountResponse.EnsureSuccessStatusCode(); | ||
var json = await cohortsCountResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | ||
var currentCohorts = JsonConvert.DeserializeObject<CurrentCohorts>(json); | ||
|
||
return currentCohorts.Cohorts.Count; | ||
} | ||
} | ||
} |
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,9 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace SFA.DAS.EmployerFinance.Services | ||
{ | ||
public interface ICohortsService | ||
{ | ||
Task<int> GetCohortsCount(long accountId); | ||
} | ||
} |