Skip to content

Commit

Permalink
Add downloading daily payment reports via api (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
byofficial authored Feb 17, 2025
1 parent f40ccea commit 6b9245e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Craftgate/Adapter/FileReportingAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public byte[] RetrieveDailyTransactionReport(RetrieveDailyTransactionReportReque
headers.Add(ContentType, ApplicationOctetStream);
return RestClient.Get<byte[]>(RequestOptions.BaseUrl + path, headers);
}

public Task<byte[]> RetrieveDailyTransactionReportAsync(RetrieveDailyTransactionReportRequest retrieveDailyTransactionReportRequest)
{
var queryParam = RequestQueryParamsBuilder.BuildQueryParam(retrieveDailyTransactionReportRequest);
Expand All @@ -31,5 +31,23 @@ public Task<byte[]> RetrieveDailyTransactionReportAsync(RetrieveDailyTransaction
headers.Add(ContentType, ApplicationOctetStream);
return AsyncRestClient.Get<byte[]>(RequestOptions.BaseUrl + path, headers);
}

public byte[] RetrieveDailyPaymentReport(RetrieveDailyPaymentReportRequest retrieveDailyPaymentReportRequest)
{
var queryParam = RequestQueryParamsBuilder.BuildQueryParam(retrieveDailyPaymentReportRequest);
var path = "/file-reporting/v1/payment-reports" + queryParam;
var headers = CreateHeaders(path, RequestOptions);
headers.Add(ContentType, ApplicationOctetStream);
return RestClient.Get<byte[]>(RequestOptions.BaseUrl + path, headers);
}

public Task<byte[]> RetrieveDailyPaymentReportAsync(RetrieveDailyPaymentReportRequest retrieveDailyPaymentReportRequest)
{
var queryParam = RequestQueryParamsBuilder.BuildQueryParam(retrieveDailyPaymentReportRequest);
var path = "/file-reporting/v1/payment-reports" + queryParam;
var headers = CreateHeaders(path, RequestOptions);
headers.Add(ContentType, ApplicationOctetStream);
return AsyncRestClient.Get<byte[]>(RequestOptions.BaseUrl + path, headers);
}
}
}
10 changes: 10 additions & 0 deletions Craftgate/Request/RetrieveDailyPaymentReportRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Craftgate.Model;

namespace Craftgate.Request
{
public class RetrieveDailyPaymentReportRequest
{
public string ReportDate { get; set; }
public ReportFileType? FileType { get; set; }
}
}
14 changes: 14 additions & 0 deletions Samples/FileReportingSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,19 @@ public void Retrieve_Daily_Transaction_Report()

Assert.NotNull(response);
}

[Test]
public void Retrieve_Daily_Payment_Report()
{
var request = new RetrieveDailyPaymentReportRequest
{
ReportDate = DateTime.Now.ToString("yyyy-MM-dd"),
FileType = ReportFileType.CSV
};

var response = _craftgateClient.FileReporting().RetrieveDailyPaymentReport(request);

Assert.NotNull(response);
}
}
}

0 comments on commit 6b9245e

Please sign in to comment.