diff --git a/EstateReportingAPI.BusinessLogic/EstateReportingAPI.BusinessLogic.csproj b/EstateReportingAPI.BusinessLogic/EstateReportingAPI.BusinessLogic.csproj
index 8a09a85..26d999a 100644
--- a/EstateReportingAPI.BusinessLogic/EstateReportingAPI.BusinessLogic.csproj
+++ b/EstateReportingAPI.BusinessLogic/EstateReportingAPI.BusinessLogic.csproj
@@ -9,8 +9,8 @@
-
-
+
+
diff --git a/EstateReportingAPI.Client/EstateReportingAPI.Client.csproj b/EstateReportingAPI.Client/EstateReportingAPI.Client.csproj
index 1a60ca7..79d0e41 100644
--- a/EstateReportingAPI.Client/EstateReportingAPI.Client.csproj
+++ b/EstateReportingAPI.Client/EstateReportingAPI.Client.csproj
@@ -7,9 +7,9 @@
-
+
-
+
diff --git a/EstateReportingAPI.Client/EstateReportingApiClient.cs b/EstateReportingAPI.Client/EstateReportingApiClient.cs
index 329f7b5..b456d12 100644
--- a/EstateReportingAPI.Client/EstateReportingApiClient.cs
+++ b/EstateReportingAPI.Client/EstateReportingApiClient.cs
@@ -40,25 +40,18 @@ public EstateReportingApiClient(Func baseAddressResolver,
public async Task>> GetCalendarDates(String accessToken, Guid estateId, Int32 year, CancellationToken cancellationToken){
String requestUri = this.BuildRequestUrl($"/api/dimensions/calendar/{year}/dates");
-
+
try{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ Result> result = await this.SendGetRequest>(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData> responseData = this.HandleResponseContent>(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch(Exception ex){
// An exception has occurred, add some additional information to the message
@@ -73,23 +66,15 @@ public async Task>> GetCalendarYears(String accessToke
String requestUri = this.BuildRequestUrl("/api/dimensions/calendar/years");
try{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result> result = await this.SendGetRequest>(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData> responseData = this.HandleResponseContent>(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch(Exception ex){
// An exception has occurred, add some additional information to the message
@@ -103,23 +88,16 @@ public async Task>> GetComparisonDates(String access
String requestUri = this.BuildRequestUrl("/api/dimensions/calendar/comparisondates");
try{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ Result> result = await this.SendGetRequest>(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData> responseData = this.HandleResponseContent>(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch(Exception ex){
// An exception has occurred, add some additional information to the message
@@ -130,28 +108,18 @@ public async Task>> GetComparisonDates(String access
}
public async Task> GetLastSettlement(String accessToken, Guid estateId, CancellationToken cancellationToken){
- LastSettlement response = null;
-
String requestUri = this.BuildRequestUrl("/api/facts/settlements/lastsettlement");
try{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result result = await this.SendGetRequest(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData responseData = this.HandleResponseContent(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch(Exception ex){
// An exception has occurred, add some additional information to the message
@@ -159,32 +127,22 @@ public async Task> GetLastSettlement(String accessToken,
return Result.Failure(exception.Message);
}
-
- return response;
}
-
+
public async Task>> GetResponseCodes(String accessToken, Guid estateId, CancellationToken cancellationToken){
String requestUri = this.BuildRequestUrl("/api/dimensions/responsecodes");
try
{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result> result = await this.SendGetRequest>(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData> responseData = this.HandleResponseContent>(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch (Exception ex)
{
@@ -204,23 +162,15 @@ public async Task> GetMerchantPerformance(String accessToken
try
{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result result = await this.SendGetRequest(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData responseData = this.HandleResponseContent(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch (Exception ex)
{
@@ -239,24 +189,15 @@ public async Task> GetProductPerformance(String accessToken,
try
{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result result = await this.SendGetRequest(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData responseData = this.HandleResponseContent(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch (Exception ex)
{
@@ -273,24 +214,15 @@ public async Task>> GetMerchantsByLastSaleDate(String acce
try
{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result>? result = await this.SendGetRequest>(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData> responseData = this.HandleResponseContent>(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch (Exception ex)
{
@@ -309,24 +241,15 @@ public async Task> GetOperatorPerformance(String accessToken
try
{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result? result = await this.SendGetRequest(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData responseData = this.HandleResponseContent(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch (Exception ex)
{
@@ -359,25 +282,18 @@ public async Task>> TransactionSearch(String acce
try
{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
- request.Content = new StringContent(JsonConvert.SerializeObject(searchRequest), Encoding.UTF8, "application/json");
+ StringContent content = new StringContent(JsonConvert.SerializeObject(searchRequest), Encoding.UTF8, "application/json");
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ Result>? result = await this.SendGetRequest>(requestUri, accessToken, additionalHeaders,content, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData> responseData = this.HandleResponseContent>(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch (Exception ex)
{
@@ -415,24 +331,15 @@ public async Task>> GetUnsettledFees(String accessToke
try
{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result>? result = await this.SendGetRequest>(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData> responseData = this.HandleResponseContent>(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch (Exception ex)
{
@@ -448,23 +355,15 @@ public async Task> GetMerchantKpi(String accessToken, Guid e
String requestUri = this.BuildRequestUrl("/api/facts/transactions/merchantkpis");
try{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result? result = await this.SendGetRequest(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData responseData = this.HandleResponseContent(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch(Exception ex){
// An exception has occurred, add some additional information to the message
@@ -479,24 +378,15 @@ public async Task>> GetMerchants(String accessToken, Guid
String requestUri = this.BuildRequestUrl("/api/dimensions/merchants");
try{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result>? result = await this.SendGetRequest>(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData> responseData = this.HandleResponseContent>(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch(Exception ex){
// An exception has occurred, add some additional information to the message
@@ -511,23 +401,15 @@ public async Task>> GetOperators(String accessToken, Guid
String requestUri = this.BuildRequestUrl("/api/dimensions/operators");
try{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result>? result = await this.SendGetRequest>(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData> responseData = this.HandleResponseContent>(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch(Exception ex){
// An exception has occurred, add some additional information to the message
@@ -547,23 +429,15 @@ public async Task> GetTodaysFailedSales(String accessToken,
String requestUri = this.BuildRequestUrl($"/api/facts/transactions/todaysfailedsales?{builder.BuildQueryString()}");
try {
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result? result = await this.SendGetRequest(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData responseData = this.HandleResponseContent(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch (Exception ex) {
// An exception has occurred, add some additional information to the message
@@ -582,23 +456,15 @@ public async Task> GetTodaysSales(String accessToken, Guid e
String requestUri = this.BuildRequestUrl($"/api/facts/transactions/todayssales?{builder.BuildQueryString()}");
try{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result? result = await this.SendGetRequest(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData responseData = this.HandleResponseContent(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch(Exception ex){
// An exception has occurred, add some additional information to the message
@@ -617,23 +483,15 @@ public async Task>> GetTodaysSalesCountByHou
String requestUri = this.BuildRequestUrl($"/api/facts/transactions/todayssales/countbyhour?{builder.BuildQueryString()}");
try{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result>? result = await this.SendGetRequest>(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData> responseData = this.HandleResponseContent>(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch(Exception ex){
// An exception has occurred, add some additional information to the message
@@ -652,23 +510,15 @@ public async Task>> GetTodaysSalesValueByHou
String requestUri = this.BuildRequestUrl($"/api/facts/transactions/todayssales/valuebyhour?{builder.BuildQueryString()}");
try{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result>? result = await this.SendGetRequest>(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData> responseData = this.HandleResponseContent>(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch(Exception ex){
// An exception has occurred, add some additional information to the message
@@ -687,23 +537,15 @@ public async Task> GetTodaysSettlement(String accessTok
String requestUri = this.BuildRequestUrl($"/api/facts/settlements/todayssettlement?{builder.BuildQueryString()}");
try{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result? result = await this.SendGetRequest(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData responseData = this.HandleResponseContent(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch(Exception ex){
// An exception has occurred, add some additional information to the message
@@ -717,23 +559,15 @@ public async Task>> GetTopBottomMerchantData(
String requestUri = this.BuildRequestUrl($"/api/facts/transactions/merchants/topbottombyvalue?topOrBottom={(Int32)topBottom}&count={resultCount}");
try{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result>? result = await this.SendGetRequest>(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData> responseData = this.HandleResponseContent>(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch(Exception ex){
// An exception has occurred, add some additional information to the message
@@ -747,23 +581,15 @@ public async Task>> GetTopBottomOperatorData(
String requestUri = this.BuildRequestUrl($"/api/facts/transactions/operators/topbottombyvalue?topOrBottom={(Int32)topBottom}&count={resultCount}");
try{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result>? result = await this.SendGetRequest>(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData> responseData = this.HandleResponseContent>(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch(Exception ex){
// An exception has occurred, add some additional information to the message
@@ -777,23 +603,15 @@ public async Task>> GetTopBottomProductData(St
String requestUri = this.BuildRequestUrl($"/api/facts/transactions/products/topbottombyvalue?topOrBottom={(Int32)topBottom}&count={resultCount}");
try{
- HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
- request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
- request.Headers.Add("EstateId", estateId.ToString());
-
- // Make the Http Call here
- HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
-
- // Process the response
- Result result = await this.HandleResponseX(httpResponse, cancellationToken);
+ List<(String headerName, String headerValue)> additionalHeaders = [
+ ("EstateId", estateId.ToString())
+ ];
+ Result>? result = await this.SendGetRequest>(requestUri, accessToken, additionalHeaders, cancellationToken);
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);
- // call was successful so now deserialise the body to the response object
- ResponseData> responseData = this.HandleResponseContent>(result.Data);
-
- return Result.Success(responseData.Data);
+ return result;
}
catch(Exception ex){
// An exception has occurred, add some additional information to the message
diff --git a/EstateReportingAPI.DataTrasferObjects/CalendarDate.cs b/EstateReportingAPI.DataTrasferObjects/CalendarDate.cs
index f012652..0344b97 100644
--- a/EstateReportingAPI.DataTrasferObjects/CalendarDate.cs
+++ b/EstateReportingAPI.DataTrasferObjects/CalendarDate.cs
@@ -1,18 +1,30 @@
namespace EstateReportingAPI.DataTrasferObjects{
+ using Newtonsoft.Json;
using System;
public class CalendarDate
{
+ [JsonProperty("date")]
public DateTime Date { get; set; }
+ [JsonProperty("day_of_week")]
public String DayOfWeek{ get; set; }
+ [JsonProperty("day_of_week_number")]
public Int32 DayOfWeekNumber{ get; set; }
+ [JsonProperty("day_of_week_short")]
public String DayOfWeekShort{ get; set; }
+ [JsonProperty("month_name")]
public String MonthName{ get; set; }
+ [JsonProperty("month_name_short")]
public String MonthNameShort { get; set; }
+ [JsonProperty("month_number")]
public Int32 MonthNumber { get; set; }
+ [JsonProperty("week_number")]
public Int32 WeekNumber { get; set; }
+ [JsonProperty("week_number_string")]
public String WeekNumberString { get; set; }
+ [JsonProperty("year")]
public Int32 Year { get; set; }
+ [JsonProperty("year_week_number")]
public String YearWeekNumber { get; set; }
}
}
\ No newline at end of file
diff --git a/EstateReportingAPI.DataTrasferObjects/CalendarYear.cs b/EstateReportingAPI.DataTrasferObjects/CalendarYear.cs
index 76ad317..f34c8fd 100644
--- a/EstateReportingAPI.DataTrasferObjects/CalendarYear.cs
+++ b/EstateReportingAPI.DataTrasferObjects/CalendarYear.cs
@@ -1,4 +1,5 @@
-using System;
+using Newtonsoft.Json;
+using System;
using System.Collections.Generic;
using System.Text;
@@ -6,6 +7,7 @@ namespace EstateReportingAPI.DataTrasferObjects
{
public class CalendarYear
{
+ [JsonProperty("year")]
public Int32 Year{ get; set; }
}
}
diff --git a/EstateReportingAPI.DataTrasferObjects/ComparisonDate.cs b/EstateReportingAPI.DataTrasferObjects/ComparisonDate.cs
index 3de80f1..e8d354f 100644
--- a/EstateReportingAPI.DataTrasferObjects/ComparisonDate.cs
+++ b/EstateReportingAPI.DataTrasferObjects/ComparisonDate.cs
@@ -1,9 +1,13 @@
namespace EstateReportingAPI.DataTrasferObjects{
+ using Newtonsoft.Json;
using System;
public class ComparisonDate{
+ [JsonProperty("order_value")]
public Int32 OrderValue{ get; set; }
+ [JsonProperty("date")]
public DateTime Date { get; set; }
+ [JsonProperty("description")]
public String Description { get; set; }
}
}
\ No newline at end of file
diff --git a/EstateReportingAPI.DataTrasferObjects/LastSettlement.cs b/EstateReportingAPI.DataTrasferObjects/LastSettlement.cs
index f862962..256ac3f 100644
--- a/EstateReportingAPI.DataTrasferObjects/LastSettlement.cs
+++ b/EstateReportingAPI.DataTrasferObjects/LastSettlement.cs
@@ -1,11 +1,17 @@
-namespace EstateReportingAPI.DataTransferObjects{
+using Newtonsoft.Json;
+
+namespace EstateReportingAPI.DataTransferObjects{
using System;
public class LastSettlement
{
+ [JsonProperty("settlement_date")]
public DateTime SettlementDate { get; set; }
+ [JsonProperty("sales_value")]
public Decimal SalesValue { get; set; }
+ [JsonProperty("sales_count")]
public Int32 SalesCount { get; set; }
+ [JsonProperty("fees_value")]
public Decimal FeesValue { get; set; }
}
}
\ No newline at end of file
diff --git a/EstateReportingAPI.DataTrasferObjects/Merchant.cs b/EstateReportingAPI.DataTrasferObjects/Merchant.cs
index daebf40..e776aad 100644
--- a/EstateReportingAPI.DataTrasferObjects/Merchant.cs
+++ b/EstateReportingAPI.DataTrasferObjects/Merchant.cs
@@ -1,20 +1,33 @@
namespace EstateReportingAPI.DataTrasferObjects{
+ using Newtonsoft.Json;
using System;
public class Merchant{
#region Properties
+ [JsonProperty("created_date_time")]
public DateTime CreatedDateTime{ get; set; }
+ [JsonProperty("estate_reporting_id")]
public Int32 EstateReportingId{ get; set; }
+ [JsonProperty("last_sale")]
public DateTime LastSale{ get; set; }
+ [JsonProperty("last_sale_date_time")]
public DateTime LastSaleDateTime{ get; set; }
+ [JsonProperty("last_statement")]
public DateTime LastStatement{ get; set; }
+ [JsonProperty("merchant_id")]
public Guid MerchantId{ get; set; }
+ [JsonProperty("merchant_reporting_id")]
public Int32 MerchantReportingId{ get; set; }
+ [JsonProperty("name")]
public String Name{ get; set; }
+ [JsonProperty("post_code")]
public String PostCode{ get; set; }
+ [JsonProperty("reference")]
public String Reference{ get; set; }
+ [JsonProperty("region")]
public String Region{ get; set; }
+ [JsonProperty("town")]
public String Town{ get; set; }
#endregion
diff --git a/EstateReportingAPI.DataTrasferObjects/MerchantKpi.cs b/EstateReportingAPI.DataTrasferObjects/MerchantKpi.cs
index 2c2cdf4..5aba013 100644
--- a/EstateReportingAPI.DataTrasferObjects/MerchantKpi.cs
+++ b/EstateReportingAPI.DataTrasferObjects/MerchantKpi.cs
@@ -1,4 +1,5 @@
-using System;
+using Newtonsoft.Json;
+using System;
using System.Collections.Generic;
using System.Text;
@@ -6,8 +7,11 @@ namespace EstateReportingAPI.DataTransferObjects
{
public class MerchantKpi
{
+ [JsonProperty("merchants_with_sale_in_last_hour")]
public Int32 MerchantsWithSaleInLastHour{ get; set; }
+ [JsonProperty("merchants_with_no_sale_today")]
public Int32 MerchantsWithNoSaleToday { get; set; }
+ [JsonProperty("merchants_with_no_sale_in_last7_days")]
public Int32 MerchantsWithNoSaleInLast7Days { get; set; }
}
}
diff --git a/EstateReportingAPI.DataTrasferObjects/Operator.cs b/EstateReportingAPI.DataTrasferObjects/Operator.cs
index a76539f..db794b1 100644
--- a/EstateReportingAPI.DataTrasferObjects/Operator.cs
+++ b/EstateReportingAPI.DataTrasferObjects/Operator.cs
@@ -1,10 +1,16 @@
-namespace EstateReportingAPI.DataTrasferObjects{
+using Newtonsoft.Json;
+
+namespace EstateReportingAPI.DataTrasferObjects{
using System;
public class Operator{
+ [JsonProperty("estate_reporting_id")]
public Int32 EstateReportingId { get; set; }
+ [JsonProperty("operator_id")]
public Guid OperatorId{ get; set; }
+ [JsonProperty("name")]
public String Name { get; set; }
+ [JsonProperty("operator_reporting_id")]
public Int32 OperatorReportingId { get; set; }
}
}
\ No newline at end of file
diff --git a/EstateReportingAPI.DataTrasferObjects/ResponseCode.cs b/EstateReportingAPI.DataTrasferObjects/ResponseCode.cs
index cb79851..a7024b3 100644
--- a/EstateReportingAPI.DataTrasferObjects/ResponseCode.cs
+++ b/EstateReportingAPI.DataTrasferObjects/ResponseCode.cs
@@ -1,8 +1,11 @@
namespace EstateReportingAPI.DataTrasferObjects{
+ using Newtonsoft.Json;
using System;
public class ResponseCode{
+ [JsonProperty("code")]
public Int32 Code { get; set; }
+ [JsonProperty("description")]
public String Description { get; set; }
}
}
\ No newline at end of file
diff --git a/EstateReportingAPI.DataTrasferObjects/TodaysSales.cs b/EstateReportingAPI.DataTrasferObjects/TodaysSales.cs
index ee3f969..2e10248 100644
--- a/EstateReportingAPI.DataTrasferObjects/TodaysSales.cs
+++ b/EstateReportingAPI.DataTrasferObjects/TodaysSales.cs
@@ -1,4 +1,5 @@
-using System;
+using Newtonsoft.Json;
+using System;
using System.Collections.Generic;
using System.Text;
@@ -6,11 +7,17 @@ namespace EstateReportingAPI.DataTransferObjects
{
public class TodaysSales
{
+ [JsonProperty("todays_average_sales_value")]
public Decimal TodaysAverageSalesValue { get; set; }
+ [JsonProperty("todays_sales_value")]
public Decimal TodaysSalesValue { get; set; }
+ [JsonProperty("todays_sales_count")]
public Int32 TodaysSalesCount { get; set; }
+ [JsonProperty("comparison_sales_value")]
public Decimal ComparisonSalesValue { get; set; }
+ [JsonProperty("comparison_sales_count")]
public Int32 ComparisonSalesCount { get; set; }
+ [JsonProperty("comparison_average_sales_value")]
public Decimal ComparisonAverageSalesValue { get; set; }
}
}
diff --git a/EstateReportingAPI.DataTrasferObjects/TodaysSalesCountByHour.cs b/EstateReportingAPI.DataTrasferObjects/TodaysSalesCountByHour.cs
index bc3fc3b..5545f2f 100644
--- a/EstateReportingAPI.DataTrasferObjects/TodaysSalesCountByHour.cs
+++ b/EstateReportingAPI.DataTrasferObjects/TodaysSalesCountByHour.cs
@@ -1,11 +1,14 @@
namespace EstateReportingAPI.DataTransferObjects{
+ using Newtonsoft.Json;
using System;
public class TodaysSalesCountByHour
{
+ [JsonProperty("hour")]
public Int32 Hour { get; set; }
+ [JsonProperty("todays_sales_count")]
public Int32 TodaysSalesCount { get; set; }
- public Decimal ComparisonSalesValue { get; set; }
+ [JsonProperty("comparison_sales_count")]
public Int32 ComparisonSalesCount { get; set; }
}
}
\ No newline at end of file
diff --git a/EstateReportingAPI.DataTrasferObjects/TodaysSalesValueByHour.cs b/EstateReportingAPI.DataTrasferObjects/TodaysSalesValueByHour.cs
index 8515e5c..77e7b90 100644
--- a/EstateReportingAPI.DataTrasferObjects/TodaysSalesValueByHour.cs
+++ b/EstateReportingAPI.DataTrasferObjects/TodaysSalesValueByHour.cs
@@ -1,9 +1,13 @@
namespace EstateReportingAPI.DataTransferObjects{
+ using Newtonsoft.Json;
using System;
public class TodaysSalesValueByHour{
+ [JsonProperty("hour")]
public Int32 Hour{ get; set; }
+ [JsonProperty("todays_sales_value")]
public Decimal TodaysSalesValue { get; set; }
+ [JsonProperty("comparison_sales_value")]
public Decimal ComparisonSalesValue { get; set; }
}
}
\ No newline at end of file
diff --git a/EstateReportingAPI.DataTrasferObjects/TodaysSettlement.cs b/EstateReportingAPI.DataTrasferObjects/TodaysSettlement.cs
index a2b87cd..7aa584d 100644
--- a/EstateReportingAPI.DataTrasferObjects/TodaysSettlement.cs
+++ b/EstateReportingAPI.DataTrasferObjects/TodaysSettlement.cs
@@ -1,15 +1,24 @@
namespace EstateReportingAPI.DataTransferObjects{
+ using Newtonsoft.Json;
using System;
public class TodaysSettlement
{
+ [JsonProperty("todays_settlement_value")]
public Decimal TodaysSettlementValue { get; set; }
+ [JsonProperty("todays_pending_settlement_value")]
public Decimal TodaysPendingSettlementValue { get; set; }
+ [JsonProperty("todays_settlement_count")]
public Int32 TodaysSettlementCount { get; set; }
+ [JsonProperty("todays_pending_settlement_count")]
public Int32 TodaysPendingSettlementCount { get; set; }
+ [JsonProperty("comparison_settlement_value")]
public Decimal ComparisonSettlementValue { get; set; }
+ [JsonProperty("comparison_pending_settlement_value")]
public Decimal ComparisonPendingSettlementValue { get; set; }
+ [JsonProperty("comparison_settlement_count")]
public Int32 ComparisonSettlementCount { get; set; }
+ [JsonProperty("comparison_pending_settlement_count")]
public Int32 ComparisonPendingSettlementCount { get; set; }
}
}
\ No newline at end of file
diff --git a/EstateReportingAPI.DataTrasferObjects/TopBottomMerchantData.cs b/EstateReportingAPI.DataTrasferObjects/TopBottomMerchantData.cs
index be3af06..8b32115 100644
--- a/EstateReportingAPI.DataTrasferObjects/TopBottomMerchantData.cs
+++ b/EstateReportingAPI.DataTrasferObjects/TopBottomMerchantData.cs
@@ -1,9 +1,12 @@
namespace EstateReportingAPI.DataTransferObjects{
+ using Newtonsoft.Json;
using System;
public class TopBottomMerchantData
{
+ [JsonProperty("merchant_name")]
public String MerchantName { get; set; }
+ [JsonProperty("sales_value")]
public Decimal SalesValue { get; set; }
}
}
\ No newline at end of file
diff --git a/EstateReportingAPI.DataTrasferObjects/TopBottomOperatorData.cs b/EstateReportingAPI.DataTrasferObjects/TopBottomOperatorData.cs
index ab20ea2..f95796e 100644
--- a/EstateReportingAPI.DataTrasferObjects/TopBottomOperatorData.cs
+++ b/EstateReportingAPI.DataTrasferObjects/TopBottomOperatorData.cs
@@ -1,9 +1,12 @@
namespace EstateReportingAPI.DataTransferObjects{
+ using Newtonsoft.Json;
using System;
public class TopBottomOperatorData
{
+ [JsonProperty("operator_name")]
public String OperatorName { get; set; }
+ [JsonProperty("sales_value")]
public Decimal SalesValue { get; set; }
}
}
\ No newline at end of file
diff --git a/EstateReportingAPI.DataTrasferObjects/TopBottomProductData.cs b/EstateReportingAPI.DataTrasferObjects/TopBottomProductData.cs
index 3a55482..fa36511 100644
--- a/EstateReportingAPI.DataTrasferObjects/TopBottomProductData.cs
+++ b/EstateReportingAPI.DataTrasferObjects/TopBottomProductData.cs
@@ -1,9 +1,12 @@
namespace EstateReportingAPI.DataTransferObjects{
+ using Newtonsoft.Json;
using System;
public class TopBottomProductData
{
+ [JsonProperty("product_name")]
public String ProductName { get; set; }
+ [JsonProperty("sales_value")]
public Decimal SalesValue { get; set; }
}
}
\ No newline at end of file
diff --git a/EstateReportingAPI.DataTrasferObjects/UnsettledFee.cs b/EstateReportingAPI.DataTrasferObjects/UnsettledFee.cs
index a2e0da9..d782453 100644
--- a/EstateReportingAPI.DataTrasferObjects/UnsettledFee.cs
+++ b/EstateReportingAPI.DataTrasferObjects/UnsettledFee.cs
@@ -1,4 +1,5 @@
-using System;
+using Newtonsoft.Json;
+using System;
using System.Collections.Generic;
using System.Text;
@@ -6,8 +7,11 @@ namespace EstateReportingAPI.DataTransferObjects
{
public class UnsettledFee
{
+ [JsonProperty("dimension_name")]
public String DimensionName { get; set; }
+ [JsonProperty("fees_value")]
public Decimal FeesValue { get; set; }
+ [JsonProperty("fees_count")]
public Int32 FeesCount { get; set; }
}
}
diff --git a/EstateReportingAPI.IntegrationTests/DimensionControllerTests.cs b/EstateReportingAPI.IntegrationTests/DimensionControllerTests.cs
index 9746795..c309cde 100644
--- a/EstateReportingAPI.IntegrationTests/DimensionControllerTests.cs
+++ b/EstateReportingAPI.IntegrationTests/DimensionControllerTests.cs
@@ -216,7 +216,7 @@ public async Task DimensionsController_GetOperators_OperatorsReturned()
var result = await ApiClient.GetOperators(string.Empty, this.TestId, CancellationToken.None);
result.IsSuccess.ShouldBeTrue();
- var operators = result.Data;
+ List operators = result.Data;
operators.ShouldNotBeNull();
operators.Count.ShouldBe(3);
var operator1 = operators.SingleOrDefault(o => o.Name == "Operator1");
diff --git a/EstateReportingAPI.IntegrationTests/EstateReportingAPI.IntegrationTests.csproj b/EstateReportingAPI.IntegrationTests/EstateReportingAPI.IntegrationTests.csproj
index 308829a..b1ef3ef 100644
--- a/EstateReportingAPI.IntegrationTests/EstateReportingAPI.IntegrationTests.csproj
+++ b/EstateReportingAPI.IntegrationTests/EstateReportingAPI.IntegrationTests.csproj
@@ -7,7 +7,7 @@
-
+
@@ -21,13 +21,13 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
+
+
+
-
+
diff --git a/EstateReportingAPI.Tests/EstateReportingAPI.Tests.csproj b/EstateReportingAPI.Tests/EstateReportingAPI.Tests.csproj
index c5feba4..fddf6f8 100644
--- a/EstateReportingAPI.Tests/EstateReportingAPI.Tests.csproj
+++ b/EstateReportingAPI.Tests/EstateReportingAPI.Tests.csproj
@@ -2,7 +2,7 @@
net9.0
- None
+ Full
false
@@ -19,7 +19,7 @@
-
+
all
diff --git a/EstateReportingAPI.Tests/EstateReportingApiClientTests.cs b/EstateReportingAPI.Tests/EstateReportingApiClientTests.cs
index 8157599..a90b8f5 100644
--- a/EstateReportingAPI.Tests/EstateReportingApiClientTests.cs
+++ b/EstateReportingAPI.Tests/EstateReportingApiClientTests.cs
@@ -31,7 +31,7 @@ public EstateReportingApiClientTests() {
[Fact]
public async Task EstateReportingApiClient_GetCalendarDates_DatesReturned() {
- var resultData = Result.Success(TestData.CalendarDateList);
+ var resultData = TestData.CalendarDateList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -43,8 +43,6 @@ public async Task EstateReportingApiClient_GetCalendarDates_DatesReturned() {
[Fact]
public async Task EstateReportingApiClient_GetCalendarDates_SendAsyncReturnsFailureResponse_ResultFailed()
{
- var resultData = Result.Success(TestData.CalendarDateList);
-
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest });
var result = await this.EstateReportingApiClient.GetCalendarDates("", Guid.NewGuid(), 2024, CancellationToken.None);
@@ -61,7 +59,7 @@ public async Task EstateReportingApiClient_GetCalendarDates_SendAsyncThrowsExcep
[Fact]
public async Task EstateReportingApiClient_GetCalendarYears_YearsReturned() {
- var resultData = Result.Success(TestData.CalendarYearList);
+ var resultData = TestData.CalendarYearList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -80,7 +78,7 @@ public async Task EstateReportingApiClient_GetCalendarYears_SendAsyncThrowsExcep
[Fact]
public async Task EstateReportingApiClient_GetComparisonDates_DatesReturned() {
- var resultData = Result.Success(TestData.ComparisonDateList);
+ var resultData = TestData.ComparisonDateList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -99,7 +97,7 @@ public async Task EstateReportingApiClient_GetComparisonDates_SendAsyncThrowsExc
[Fact]
public async Task EstateReportingApiClient_GetLastSettlement_LastSettlementReturned() {
- var resultData = Result.Success(TestData.LastSettlement);
+ var resultData = TestData.LastSettlement;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -121,7 +119,7 @@ public async Task EstateReportingApiClient_GetLastSettlement_SendAsyncThrowsExce
[Fact]
public async Task EstateReportingApiClient_GetResponseCodes_ResponseCodesReturned() {
- var resultData = Result.Success(TestData.ResponseCodeList);
+ var resultData = TestData.ResponseCodeList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -140,7 +138,7 @@ public async Task EstateReportingApiClient_GetResponseCodes_SendAsyncThrowsExcep
[Fact]
public async Task EstateReportingApiClient_GetMerchantPerformance_PerformanceReturned() {
- var resultData = Result.Success(TestData.TodaysSales);
+ var resultData = TestData.TodaysSales;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -164,7 +162,7 @@ public async Task EstateReportingApiClient_GetMerchantPerformance_SendAsyncThrow
[Fact]
public async Task EstateReportingApiClient_GetProductPerformance_PerformanceReturned() {
- var resultData = Result.Success(TestData.TodaysSales);
+ var resultData = TestData.TodaysSales;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -188,7 +186,7 @@ public async Task EstateReportingApiClient_GetProductPerformance_SendAsyncThrows
[Fact]
public async Task EstateReportingApiClient_GetMerchantsByLastSaleDate_MerchantsReturned() {
- var resultData = Result.Success(TestData.MerchantList);
+ var resultData = TestData.MerchantList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -207,7 +205,7 @@ public async Task EstateReportingApiClient_GetMerchantsByLastSaleDate_SendAsyncT
[Fact]
public async Task EstateReportingApiClient_GetOperatorPerformance_PerformanceReturned() {
- var resultData = Result.Success(TestData.TodaysSales);
+ var resultData = TestData.TodaysSales;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -231,7 +229,7 @@ public async Task EstateReportingApiClient_GetOperatorPerformance_SendAsyncThrow
[Fact]
public async Task EstateReportingApiClient_TransactionSearch_TransactionsReturned() {
- var resultData = Result.Success(TestData.TransactionResultList);
+ var resultData = TestData.TransactionResultList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -243,7 +241,7 @@ public async Task EstateReportingApiClient_TransactionSearch_TransactionsReturne
[Fact]
public async Task EstateReportingApiClient_TransactionSearch_WithPageNumber_TransactionsReturned()
{
- var resultData = Result.Success(TestData.TransactionResultList);
+ var resultData = TestData.TransactionResultList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -255,7 +253,7 @@ public async Task EstateReportingApiClient_TransactionSearch_WithPageNumber_Tran
[Fact]
public async Task EstateReportingApiClient_TransactionSearch_WithPageSize_TransactionsReturned()
{
- var resultData = Result.Success(TestData.TransactionResultList);
+ var resultData = TestData.TransactionResultList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -267,7 +265,7 @@ public async Task EstateReportingApiClient_TransactionSearch_WithPageSize_Transa
[Fact]
public async Task EstateReportingApiClient_TransactionSearch_WithSort_TransactionsReturned()
{
- var resultData = Result.Success(TestData.TransactionResultList);
+ var resultData = TestData.TransactionResultList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -286,7 +284,7 @@ public async Task EstateReportingApiClient_TransactionSearch_SendAsyncThrowsExce
[Fact]
public async Task EstateReportingApiClient_GetUnsettledFees_FeesReturned() {
- var resultData = Result.Success(TestData.UnsettledFeeList);
+ var resultData = TestData.UnsettledFeeList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -305,7 +303,7 @@ public async Task EstateReportingApiClient_GetUnsettledFees_SendAsyncThrowsExcep
[Fact]
public async Task EstateReportingApiClient_GetMerchantKpi_KpiReturned() {
- var resultData = Result.Success(TestData.MerchantKpi);
+ var resultData = TestData.MerchantKpi;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -326,7 +324,7 @@ public async Task EstateReportingApiClient_GetMerchantKpi_SendAsyncThrowsExcepti
[Fact]
public async Task EstateReportingApiClient_GetMerchants_MerchantsReturned() {
- var resultData = Result.Success(TestData.MerchantList);
+ var resultData = TestData.MerchantList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -345,7 +343,7 @@ public async Task EstateReportingApiClient_GetMerchants_SendAsyncThrowsException
[Fact]
public async Task EstateReportingApiClient_GetOperators_OperatorsReturned() {
- var resultData = Result.Success(TestData.OperatorList);
+ var resultData = TestData.OperatorList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -364,7 +362,7 @@ public async Task EstateReportingApiClient_GetOperators_SendAsyncThrowsException
[Fact]
public async Task EstateReportingApiClient_GetTodaysFailedSales_FailedSalesReturned() {
- var resultData = Result.Success(TestData.TodaysSales);
+ var resultData = TestData.TodaysSales;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -388,7 +386,7 @@ public async Task EstateReportingApiClient_GetTodaysFailedSales_SendAsyncThrowsE
[Fact]
public async Task EstateReportingApiClient_GetTodaysSales_SalesReturned() {
- var resultData = Result.Success(TestData.TodaysSales);
+ var resultData = TestData.TodaysSales;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -412,7 +410,7 @@ public async Task EstateReportingApiClient_GetTodaysSales_SendAsyncThrowsExcepti
[Fact]
public async Task EstateReportingApiClient_GetTodaysSalesCountByHour_CountsReturned() {
- var resultData = Result.Success(TestData.TodaysSalesCountByHourList);
+ var resultData = TestData.TodaysSalesCountByHourList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -431,7 +429,7 @@ public async Task EstateReportingApiClient_GetTodaysSalesCountByHour_SendAsyncTh
[Fact]
public async Task EstateReportingApiClient_GetTodaysSalesValueByHour_ValuesReturned() {
- var resultData = Result.Success(TestData.TodaysSalesValueByHourList);
+ var resultData = TestData.TodaysSalesValueByHourList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -450,7 +448,7 @@ public async Task EstateReportingApiClient_GetTodaysSalesValueByHour_SendAsyncTh
[Fact]
public async Task EstateReportingApiClient_GetTodaysSettlement_SettlementReturned() {
- var resultData = Result.Success(TestData.TodaysSettlement);
+ var resultData = TestData.TodaysSettlement;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -476,7 +474,7 @@ public async Task EstateReportingApiClient_GetTodaysSettlement_SendAsyncThrowsEx
[Fact]
public async Task EstateReportingApiClient_GetTopBottomMerchantData_DataReturned() {
- var resultData = Result.Success(TestData.TopBottomMerchantDataList);
+ var resultData = TestData.TopBottomMerchantDataList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -495,7 +493,7 @@ public async Task EstateReportingApiClient_GetTopBottomMerchantData_SendAsyncThr
[Fact]
public async Task EstateReportingApiClient_GetTopBottomOperatorData_DataReturned() {
- var resultData = Result.Success(TestData.TopBottomOperatorDataList);
+ var resultData = TestData.TopBottomOperatorDataList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
@@ -514,7 +512,7 @@ public async Task EstateReportingApiClient_GetTopBottomOperatorData_SendAsyncThr
[Fact]
public async Task EstateReportingApiClient_GetTopBottomProductData_DataReturned() {
- var resultData = Result.Success(TestData.TopBottomProductDataList);
+ var resultData = TestData.TopBottomProductDataList;
this.HttpMessageHandler.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()).ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(resultData)) });
diff --git a/EstateReportingAPI/Bootstrapper/MiddlewareRegistry.cs b/EstateReportingAPI/Bootstrapper/MiddlewareRegistry.cs
index 97a71ae..2e8714b 100644
--- a/EstateReportingAPI/Bootstrapper/MiddlewareRegistry.cs
+++ b/EstateReportingAPI/Bootstrapper/MiddlewareRegistry.cs
@@ -108,6 +108,12 @@ public MiddlewareRegistry()
new RequestResponseMiddlewareLoggingConfig(middlewareLogLevel, logRequests, logResponses);
this.AddSingleton(config);
+
+ this.ConfigureHttpJsonOptions(options =>
+ {
+ options.SerializerOptions.PropertyNamingPolicy = new SnakeCaseNamingPolicy();
+ options.SerializerOptions.PropertyNameCaseInsensitive = true; // optional, but safer
+ });
}
private HttpClientHandler ApiEndpointHttpHandler(IServiceProvider serviceProvider){
diff --git a/EstateReportingAPI/Controllers/DimensionsController.cs b/EstateReportingAPI/Controllers/DimensionsController.cs
index 5fd8151..29149eb 100644
--- a/EstateReportingAPI/Controllers/DimensionsController.cs
+++ b/EstateReportingAPI/Controllers/DimensionsController.cs
@@ -41,150 +41,141 @@ public DimensionsController(IMediator mediator) {
[HttpGet]
[Route("calendar/years")]
- public async Task GetCalendarYears([FromHeader] Guid estateId, CancellationToken cancellationToken){
+ public async Task GetCalendarYears([FromHeader] Guid estateId,
+ CancellationToken cancellationToken) {
- CalendarQueries.GetYearsQuery query = new(estateId);
- Result> result = await this.Mediator.Send(query, cancellationToken);
+ CalendarQueries.GetYearsQuery query = new(estateId);
+ Result> result = await this.Mediator.Send(query, cancellationToken);
- if (result.IsFailed)
- return result.ToActionResultX();
+ return ResponseFactory.FromResult(result, (r) => {
+ List response = new List();
- List response = new List();
+ r.ForEach(y => response.Add(new CalendarYear { Year = y }));
- result.Data.ForEach(y => response.Add(new CalendarYear{
- Year = y
- }));
-
- return Result.Success(response).ToActionResultX();
+ return response;
+ });
}
+
[HttpGet]
[Route("calendar/{year}/dates")]
- public async Task GetCalendarDates([FromHeader] Guid estateId, [FromRoute] Int32 year, CancellationToken cancellationToken){
+ public async Task GetCalendarDates([FromHeader] Guid estateId, [FromRoute] Int32 year, CancellationToken cancellationToken){
CalendarQueries.GetAllDatesQuery query = new(estateId);
Result> result = await this.Mediator.Send(query, cancellationToken);
- if (result.IsFailed)
- return result.ToActionResultX();
-
- List response = new List();
-
- result.Data.ForEach(d => response.Add(new CalendarDate{
- Year = d.Year,
- Date = d.Date,
- DayOfWeek = d.DayOfWeek,
- DayOfWeekNumber = d.DayOfWeekNumber,
- DayOfWeekShort = d.DayOfWeekShort,
- MonthName = d.MonthNameLong,
- MonthNameShort = d.MonthNameShort,
- MonthNumber = d.MonthNumber,
- WeekNumber = d.WeekNumber ?? 0,
- WeekNumberString = d.WeekNumberString,
- YearWeekNumber = d.YearWeekNumber,
- }));
-
- return Result.Success(response).ToActionResultX();
+
+ return ResponseFactory.FromResult(result, (r) => {
+ List response = new List();
+
+ r.ForEach(d => response.Add(new CalendarDate
+ {
+ Year = d.Year,
+ Date = d.Date,
+ DayOfWeek = d.DayOfWeek,
+ DayOfWeekNumber = d.DayOfWeekNumber,
+ DayOfWeekShort = d.DayOfWeekShort,
+ MonthName = d.MonthNameLong,
+ MonthNameShort = d.MonthNameShort,
+ MonthNumber = d.MonthNumber,
+ WeekNumber = d.WeekNumber ?? 0,
+ WeekNumberString = d.WeekNumberString,
+ YearWeekNumber = d.YearWeekNumber,
+ }));
+
+ return response;
+ });
}
[HttpGet]
[Route("calendar/comparisondates")]
- public async Task GetCalendarComparisonDates([FromHeader] Guid estateId, CancellationToken cancellationToken){
+ public async Task GetCalendarComparisonDates([FromHeader] Guid estateId, CancellationToken cancellationToken){
CalendarQueries.GetComparisonDatesQuery query = new(estateId);
Result> result = await this.Mediator.Send(query, cancellationToken);
- if (result.IsFailed)
- return result.ToActionResultX();
-
- List response = new List();
-
- response.Add(new ComparisonDate{
- Date = DateTime.Now.Date.AddDays(-1),
- Description = "Yesterday",
- OrderValue = 0
- });
-
- response.Add(new ComparisonDate{
- Date = DateTime.Now.Date.AddDays(-7),
- Description = "Last Week",
- OrderValue = 1
- });
- response.Add(new ComparisonDate{
- Date = DateTime.Now.Date.AddMonths(-1),
- Description = "Last Month",
- OrderValue = 2
- });
- Int32 orderValue = 3;
- result.Data.ForEach(d => {
- response.Add(new ComparisonDate{
- Date = d.Date,
- Description = d.Date.ToString("yyyy-MM-dd"),
- OrderValue = orderValue
- });
- orderValue++;
- });
-
- return Result.Success(response.OrderBy(d => d.OrderValue)).ToActionResultX();
+
+ return ResponseFactory.FromResult(result, (r) => {
+ List response = [
+ new ComparisonDate { Date = DateTime.Now.Date.AddDays(-1), Description = "Yesterday", OrderValue = 0 },
+
+ new ComparisonDate { Date = DateTime.Now.Date.AddDays(-7), Description = "Last Week", OrderValue = 1 },
+
+ new ComparisonDate { Date = DateTime.Now.Date.AddMonths(-1), Description = "Last Month", OrderValue = 2 }
+
+ ];
+
+ Int32 orderValue = 3;
+ r.ForEach(d =>
+ {
+ response.Add(new ComparisonDate
+ {
+ Date = d.Date,
+ Description = d.Date.ToString("yyyy-MM-dd"),
+ OrderValue = orderValue
+ });
+ orderValue++;
+ });
+
+ return response.OrderBy(d => d.OrderValue);
+ });
}
[HttpGet]
[Route("merchants")]
- public async Task GetMerchants([FromHeader] Guid estateId, CancellationToken cancellationToken) {
+ public async Task GetMerchants([FromHeader] Guid estateId, CancellationToken cancellationToken) {
MerchantQueries.GetMerchantsQuery query = new(estateId);
Result> result = await this.Mediator.Send(query, cancellationToken);
-
- List response = new List();
-
- result.Data.ForEach(m => response.Add(new Merchant{
- MerchantReportingId = m.MerchantReportingId,
- MerchantId = m.MerchantId,
- EstateReportingId = m.EstateReportingId,
- Name = m.Name,
- LastSaleDateTime = m.LastSaleDateTime,
- CreatedDateTime = m.CreatedDateTime,
- LastSale = m.LastSale,
- LastStatement = m.LastStatement,
- PostCode = m.PostCode,
- Reference = m.Reference,
- Region = m.Region,
- Town = m.Town,
- }));
-
- return Result.Success(response.OrderBy(m=> m.Name)).ToActionResultX();
+
+ return ResponseFactory.FromResult(result, (r) => {
+ List response = new List();
+
+ r.ForEach(m => response.Add(new Merchant {
+ MerchantReportingId = m.MerchantReportingId,
+ MerchantId = m.MerchantId,
+ EstateReportingId = m.EstateReportingId,
+ Name = m.Name,
+ LastSaleDateTime = m.LastSaleDateTime,
+ CreatedDateTime = m.CreatedDateTime,
+ LastSale = m.LastSale,
+ LastStatement = m.LastStatement,
+ PostCode = m.PostCode,
+ Reference = m.Reference,
+ Region = m.Region,
+ Town = m.Town,
+ }));
+
+ return response.OrderBy(m => m.Name);
+ });
}
[HttpGet]
[Route("operators")]
- public async Task GetOperators([FromHeader] Guid estateId, CancellationToken cancellationToken)
+ public async Task GetOperators([FromHeader] Guid estateId, CancellationToken cancellationToken)
{
OperatorQueries.GetOperatorsQuery query = new(estateId);
Result> result = await this.Mediator.Send(query, cancellationToken);
- List response = new List();
+ return ResponseFactory.FromResult(result, (r) => {
+ List response = new List();
- result.Data.ForEach(o => response.Add(new Operator
- {
- EstateReportingId = o.EstateReportingId,
- Name = o.Name,
- OperatorId = o.OperatorId,
- OperatorReportingId = o.OperatorReportingId
- }));
+ r.ForEach(o => response.Add(new Operator { EstateReportingId = o.EstateReportingId, Name = o.Name, OperatorId = o.OperatorId, OperatorReportingId = o.OperatorReportingId }));
- return Result.Success(response.OrderBy(o => o.Name)).ToActionResultX();
+ return response.OrderBy(o => o.Name);
+ });
}
[HttpGet]
[Route("responsecodes")]
- public async Task GetResponseCodes([FromHeader] Guid estateId, CancellationToken cancellationToken)
+ public async Task