All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.checkout.disputes.DisputesClientImpl Maven / Gradle / Ivy

There is a newer version: 6.4.2
Show newest version
package com.checkout.disputes;

import com.checkout.AbstractClient;
import com.checkout.ApiClient;
import com.checkout.CheckoutConfiguration;
import com.checkout.EmptyResponse;
import com.checkout.SdkAuthorizationType;
import com.checkout.common.FileDetailsResponse;
import com.checkout.common.FileRequest;
import com.checkout.common.IdResponse;

import java.util.concurrent.CompletableFuture;

import static com.checkout.common.CheckoutUtils.validateParams;

public class DisputesClientImpl extends AbstractClient implements DisputesClient {

    private static final String DISPUTES_PATH = "disputes";
    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 SCHEME_FILES_PATH = "schemefiles";

    public DisputesClientImpl(final ApiClient apiClient, final CheckoutConfiguration configuration, final SdkAuthorizationType sdkAuthorizationType) {
        super(apiClient, configuration, sdkAuthorizationType);
    }

    @Override
    public CompletableFuture query(final DisputesQueryFilter queryFilter) {
        validateParams("queryFilter", queryFilter);
        return apiClient.queryAsync(
                DISPUTES_PATH,
                sdkAuthorization(),
                queryFilter,
                DisputesQueryResponse.class);
    }

    @Override
    public CompletableFuture getDisputeDetails(final String disputeId) {
        validateParams("disputeId", disputeId);
        return apiClient.getAsync(
                buildPath(DISPUTES_PATH, disputeId),
                sdkAuthorization(),
                DisputeDetailsResponse.class);
    }

    @Override
    public CompletableFuture accept(final String disputeId) {
        validateParams("disputeId", disputeId);
        return apiClient.postAsync(
                buildPath(DISPUTES_PATH, disputeId, ACCEPT_PATH),
                sdkAuthorization(),
                EmptyResponse.class,
                null,
                null);
    }

    @Override
    public CompletableFuture putEvidence(final String disputeId, final DisputeEvidenceRequest disputeEvidence) {
        validateParams("disputeId", disputeId, "disputeEvidence", disputeEvidence);
        return apiClient.putAsync(
                buildPath(DISPUTES_PATH, disputeId, EVIDENCE_PATH),
                sdkAuthorization(),
                EmptyResponse.class,
                disputeEvidence);
    }

    @Override
    public CompletableFuture getEvidence(final String disputeId) {
        validateParams("disputeId", disputeId);
        return apiClient.getAsync(
                buildPath(DISPUTES_PATH, disputeId, EVIDENCE_PATH),
                sdkAuthorization(),
                DisputeEvidenceResponse.class);
    }

    @Override
    public CompletableFuture submitEvidence(final String disputeId) {
        validateParams("disputeId", disputeId);
        return apiClient.postAsync(
                buildPath(DISPUTES_PATH, disputeId, EVIDENCE_PATH),
                sdkAuthorization(),
                EmptyResponse.class,
                null,
                null);
    }

    @Override
    public CompletableFuture uploadFile(final FileRequest fileRequest) {
        validateParams("fileRequest", fileRequest);
        return apiClient.submitFileAsync(
                FILES_PATH,
                sdkAuthorization(),
                fileRequest,
                IdResponse.class);
    }

    @Override
    public CompletableFuture getFileDetails(final String fileId) {
        validateParams("fileId", fileId);
        return apiClient.getAsync(
                buildPath(FILES_PATH, fileId),
                sdkAuthorization(),
                FileDetailsResponse.class);
    }

    @Override
    public CompletableFuture getDisputeSchemeFiles(final String disputeId) {
        validateParams("disputeId", disputeId);
        return apiClient.getAsync(
                buildPath(DISPUTES_PATH, disputeId, SCHEME_FILES_PATH),
                sdkAuthorization(),
                SchemeFileResponse.class
        );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy