Skip to content

Commit

Permalink
Update response statements when get payments (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko authored Oct 30, 2023
1 parent ffedc1f commit 7d1170d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public interface ReconciliationClient {
* Statements endpoint
* </a>
* */
CompletableFuture<StatementReportResponse> getStatementsReportById(String statementId);
CompletableFuture<ReconciliationPaymentReportResponse> getStatementsReportById(String statementId);

/**
* More information in:
* <a href="https://www.checkout.com/docs/previous/reporting-and-insights/reconciliation-api/statements-endpoint#2._Statement_ID_/_Payments">
* Statements endpoint
* </a>
* */
CompletableFuture<StatementReportResponse> getStatementsReportByIdQuery(String statementId, StatementsQueryFilter filter);
CompletableFuture<ReconciliationPaymentReportResponse> getStatementsReportByIdQuery(String statementId, StatementsQueryFilter filter);

/**
* @param targetFile Optional parameter that specifies the path where a file with the content returned is saved. If
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,23 @@ public CompletableFuture<StatementReportResponse> queryStatementsReport(final St
}

@Override
public CompletableFuture<StatementReportResponse> getStatementsReportById(final String statementId) {
public CompletableFuture<ReconciliationPaymentReportResponse> getStatementsReportById(final String statementId) {
validateParams("statementId", statementId);
return apiClient.getAsync(
buildPath(REPORTING_PATH, STATEMENTS_PATH, statementId, PAYMENTS_PATH),
sdkAuthorization(),
StatementReportResponse.class
ReconciliationPaymentReportResponse.class
);
}

@Override
public CompletableFuture<StatementReportResponse> getStatementsReportByIdQuery(final String statementId, final StatementsQueryFilter filter) {
public CompletableFuture<ReconciliationPaymentReportResponse> getStatementsReportByIdQuery(final String statementId, final StatementsQueryFilter filter) {
validateParams("statementId", statementId, "filter", filter);
return apiClient.queryAsync(
buildPath(REPORTING_PATH, STATEMENTS_PATH, statementId, PAYMENTS_PATH),
sdkAuthorization(),
filter,
StatementReportResponse.class
ReconciliationPaymentReportResponse.class
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ void shouldQueryStatementsReport() throws ExecutionException, InterruptedExcepti

@Test
void shouldGetStatementsReportById() throws ExecutionException, InterruptedException {
final StatementReportResponse response = mock(StatementReportResponse.class);
final ReconciliationPaymentReportResponse response = mock(ReconciliationPaymentReportResponse.class);

when(apiClient.getAsync(eq("reporting/statements/statement_id/payments"), any(SdkAuthorization.class),
eq(StatementReportResponse.class)))
eq(ReconciliationPaymentReportResponse.class)))
.thenReturn(CompletableFuture.completedFuture(response));

final CompletableFuture<StatementReportResponse> future = client.getStatementsReportById("statement_id");
final CompletableFuture<ReconciliationPaymentReportResponse> future = client.getStatementsReportById("statement_id");

assertNotNull(future.get());
assertEquals(response, future.get());
Expand All @@ -108,13 +108,13 @@ void shouldGetStatementsReportById() throws ExecutionException, InterruptedExcep
@Test
void shouldGetStatementsReportByIdWithQuery() throws ExecutionException, InterruptedException {
final StatementsQueryFilter filter = mock(StatementsQueryFilter.class);
final StatementReportResponse response = mock(StatementReportResponse.class);
final ReconciliationPaymentReportResponse response = mock(ReconciliationPaymentReportResponse.class);

when(apiClient.queryAsync(eq("reporting/statements/statement_id/payments"), any(SdkAuthorization.class), eq(filter),
eq(StatementReportResponse.class)))
eq(ReconciliationPaymentReportResponse.class)))
.thenReturn(CompletableFuture.completedFuture(response));

final CompletableFuture<StatementReportResponse> future = client.getStatementsReportByIdQuery("statement_id", filter);
final CompletableFuture<ReconciliationPaymentReportResponse> future = client.getStatementsReportByIdQuery("statement_id", filter);

assertNotNull(future.get());
assertEquals(response, future.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,29 +142,18 @@ void shouldQueryStatementsReport() throws ExecutionException, InterruptedExcepti
@Disabled("Only works in production")
void shouldGetStatementsReportById() throws ExecutionException, InterruptedException {

final StatementReportResponse response = getProductionCheckoutApi().reconciliationClient().getStatementsReportById("statement_id").get();
final ReconciliationPaymentReportResponse response = getProductionCheckoutApi().reconciliationClient().getStatementsReportById("statement_id").get();

assertNotNull(response);
assertNotNull(response.getLinks());
assertTrue(response.getCount() >= 1);
response.getData().forEach(statementData -> {
assertNotNull(statementData.getId());
assertNotNull(statementData.getPeriodStart());
assertNotNull(statementData.getPeriodEnd());
assertNotNull(statementData.getDate());
assertNotNull(statementData.getPayouts());
assertNotNull(statementData.getLinks());
statementData.getPayouts().forEach(payoutStatement -> {
assertNotNull(payoutStatement.getCurrency());
assertNotNull(payoutStatement.getCarriedForwardAmount());
assertNotNull(payoutStatement.getCurrentPeriodAmount());
assertNotNull(payoutStatement.getNetAmount());
assertNotNull(payoutStatement.getPeriodStart());
assertNotNull(payoutStatement.getPeriodEnd());
assertNotNull(payoutStatement.getId());
assertNotNull(payoutStatement.getStatus());
assertNotNull(payoutStatement.getPayoutFee());
assertNotNull(payoutStatement.getLinks());
response.getData().forEach(PaymentReportData -> {
assertNotNull(PaymentReportData.getId());
PaymentReportData.getActions().forEach(action -> {
assertNotNull(action.getId());
action.getBreakdown().forEach(breakdown -> {
assertNotNull(breakdown.getType());
});
});
});
}
Expand Down

0 comments on commit 7d1170d

Please sign in to comment.