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

com.truelayer.java.payouts.PayoutsHandler Maven / Gradle / Ivy

There is a newer version: 16.0.0
Show newest version
package com.truelayer.java.payouts;

import static com.truelayer.java.Constants.Scopes.PAYMENTS;
import static com.truelayer.java.http.mappers.HeadersMapper.toMap;
import static java.util.Collections.emptyMap;

import com.truelayer.java.IAuthenticatedHandler;
import com.truelayer.java.entities.RequestScopes;
import com.truelayer.java.http.entities.ApiResponse;
import com.truelayer.java.http.entities.Headers;
import com.truelayer.java.payouts.entities.CreatePayoutRequest;
import com.truelayer.java.payouts.entities.CreatePayoutResponse;
import com.truelayer.java.payouts.entities.Payout;
import java.util.concurrent.CompletableFuture;
import lombok.Builder;

@Builder
public class PayoutsHandler implements IAuthenticatedHandler, IPayoutsHandler {

    private IPayoutsApi payoutsApi;

    @Builder.Default
    private RequestScopes scopes = RequestScopes.builder().scope(PAYMENTS).build();

    @Override
    public RequestScopes getRequestScopes() {
        return scopes;
    }

    @Override
    public CompletableFuture> createPayout(CreatePayoutRequest request) {
        return payoutsApi.createPayout(getRequestScopes(), emptyMap(), request);
    }

    @Override
    public CompletableFuture> createPayout(
            Headers headers, CreatePayoutRequest request) {
        return payoutsApi.createPayout(getRequestScopes(), toMap(headers), request);
    }

    @Override
    public CompletableFuture> getPayout(String payoutId) {
        return payoutsApi.getPayout(getRequestScopes(), payoutId);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy