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

com.checkout.transfers.TransfersClientImpl Maven / Gradle / Ivy

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

import com.checkout.AbstractClient;
import com.checkout.ApiClient;
import com.checkout.CheckoutConfiguration;
import com.checkout.SdkAuthorizationType;

import java.util.concurrent.CompletableFuture;

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

public class TransfersClientImpl extends AbstractClient implements TransfersClient {

    private static final String TRANSFERS_PATH = "transfers";

    public TransfersClientImpl(final ApiClient apiClient, final CheckoutConfiguration configuration) {
        super(apiClient, configuration, SdkAuthorizationType.SECRET_KEY_OR_OAUTH);
    }

    @Override
    public CompletableFuture initiateTransferOfFunds(final CreateTransferRequest createTransferRequest) {
        return requestInitiateTransferOfFunds(createTransferRequest, null);
    }

    @Override
    public CompletableFuture initiateTransferOfFunds(final CreateTransferRequest createTransferRequest, final String idempotencyKey) {
        return requestInitiateTransferOfFunds(createTransferRequest, idempotencyKey);
    }

    @Override
    public CompletableFuture retrieveATransfer(final String transferId) {
        validateParams("transferId", transferId);
        return apiClient.getAsync(buildPath(TRANSFERS_PATH, transferId), sdkAuthorization(), TransferDetailsResponse.class);
    }


    private CompletableFuture requestInitiateTransferOfFunds(final CreateTransferRequest createTransferRequest, final String idempotencyKey) {
        validateParams("createTransferRequest", createTransferRequest);
        return apiClient.postAsync(TRANSFERS_PATH, sdkAuthorization(), CreateTransferResponse.class, createTransferRequest, idempotencyKey);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy