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

com.checkout.instruments.previous.InstrumentsClientImpl Maven / Gradle / Ivy

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

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

import java.util.concurrent.CompletableFuture;

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

public class InstrumentsClientImpl extends AbstractClient implements InstrumentsClient {

    private static final String INSTRUMENTS_PATH = "instruments";
    private static final String INSTRUMENT_ID = "instrumentId";

    public InstrumentsClientImpl(final ApiClient apiClient, final CheckoutConfiguration configuration) {
        super(apiClient, configuration, SdkAuthorizationType.SECRET_KEY);
    }

    @Override
    public CompletableFuture create(final CreateInstrumentRequest createInstrumentRequest) {
        validateParams("createInstrumentRequest", createInstrumentRequest);
        return apiClient.postAsync(INSTRUMENTS_PATH, sdkAuthorization(), CreateInstrumentResponse.class, createInstrumentRequest, null);
    }

    @Override
    public CompletableFuture get(final String instrumentId) {
        validateParams(INSTRUMENT_ID, instrumentId);
        return apiClient.getAsync(buildPath(INSTRUMENTS_PATH, instrumentId), sdkAuthorization(), InstrumentDetailsResponse.class);
    }

    @Override
    public CompletableFuture update(final String instrumentId, final UpdateInstrumentRequest updateInstrumentRequest) {
        validateParams(INSTRUMENT_ID, instrumentId, "updateInstrumentRequest", updateInstrumentRequest);
        return apiClient.patchAsync(buildPath(INSTRUMENTS_PATH, instrumentId), sdkAuthorization(), UpdateInstrumentResponse.class, updateInstrumentRequest, null);
    }

    @Override
    public CompletableFuture delete(final String instrumentId) {
        validateParams(INSTRUMENT_ID, instrumentId);
        return apiClient.deleteAsync(buildPath(INSTRUMENTS_PATH, instrumentId), sdkAuthorization());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy