Skip to content

Commit

Permalink
Add compiled submitted evidence endpoint to disputes
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko committed Mar 21, 2024
1 parent fab4210 commit db75814
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.checkout.disputes;

import com.checkout.common.Resource;
import com.google.gson.annotations.SerializedName;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@Builder
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = false)

Check notice

Code scanning / CodeQL

Missing Override annotation Note

This method overrides
Resource.canEqual
; it is advisable to add an Override annotation.
public final class DisputeCompiledSubmittedEvidenceResponse extends Resource {

@SerializedName("file_id")
private String fileId;

}
2 changes: 2 additions & 0 deletions src/main/java/com/checkout/disputes/DisputesClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public interface DisputesClient {

CompletableFuture<FileDetailsResponse> getFileDetails(String fileId);

CompletableFuture<DisputeCompiledSubmittedEvidenceResponse> getCompiledSubmittedEvidence(String disputeId);

CompletableFuture<SchemeFileResponse> getDisputeSchemeFiles(String disputeId);

}
11 changes: 11 additions & 0 deletions src/main/java/com/checkout/disputes/DisputesClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class DisputesClientImpl extends AbstractClient implements DisputesClient
private static final String FILES_PATH = "files";
private static final String ACCEPT_PATH = "accept";
private static final String EVIDENCE_PATH = "evidence";
private static final String SUBMITTED_PATH = "submitted";
private static final String SCHEME_FILES_PATH = "schemefiles";

public DisputesClientImpl(final ApiClient apiClient, final CheckoutConfiguration configuration, final SdkAuthorizationType sdkAuthorizationType) {
Expand Down Expand Up @@ -104,6 +105,16 @@ public CompletableFuture<FileDetailsResponse> getFileDetails(final String fileId
FileDetailsResponse.class);
}

@Override
public CompletableFuture<DisputeCompiledSubmittedEvidenceResponse> getCompiledSubmittedEvidence(String disputeId) {
validateParams("disputeId", disputeId);
return apiClient.getAsync(
buildPath(DISPUTES_PATH, disputeId, EVIDENCE_PATH, SUBMITTED_PATH),
sdkAuthorization(),
DisputeCompiledSubmittedEvidenceResponse.class
);
}

@Override
public CompletableFuture<SchemeFileResponse> getDisputeSchemeFiles(final String disputeId) {
validateParams("disputeId", disputeId);
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/com/checkout/disputes/DisputesClientImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ void shouldGetDisputeEvidence() throws ExecutionException, InterruptedException
assertEquals(response, future.get());
}

@Test
void shouldGetCompiledSubmittedEvidence() throws ExecutionException, InterruptedException {
final DisputeCompiledSubmittedEvidenceResponse response = mock(DisputeCompiledSubmittedEvidenceResponse.class);

when(apiClient.getAsync("disputes/dispute_id/evidence/submitted", authorization, DisputeCompiledSubmittedEvidenceResponse.class))
.thenReturn(CompletableFuture.completedFuture(response));

final CompletableFuture<DisputeCompiledSubmittedEvidenceResponse> future = client.getCompiledSubmittedEvidence("dispute_id");

assertNotNull(future.get());
assertEquals(response, future.get());
}

@Test
void shouldSubmitDisputeEvidence() throws ExecutionException, InterruptedException {

Expand Down
6 changes: 6 additions & 0 deletions src/test/java/com/checkout/disputes/DisputesTestIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ void shouldTestFullDisputesWorkFlow() throws Exception {

//Submit your dispute evidence
blocking(() -> checkoutApi.disputesClient().submitEvidence(disputeDetails.getId()));

//Get compiled submitted evidence
final DisputeCompiledSubmittedEvidenceResponse compiledSubmittedEvidenceResponse = blocking(() -> checkoutApi.disputesClient().getCompiledSubmittedEvidence(disputeDetails.getId()));
assertNotNull(compiledSubmittedEvidenceResponse);
assertNotNull(compiledSubmittedEvidenceResponse.getFileId());

}

}

0 comments on commit db75814

Please sign in to comment.