Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Fireblocks API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.6.2
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.fireblocks.sdk.api;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fireblocks.sdk.ApiClient;
import com.fireblocks.sdk.ApiException;
import com.fireblocks.sdk.ApiResponse;
import com.fireblocks.sdk.ValidationUtils;
import com.fireblocks.sdk.model.CreatePayoutRequest;
import com.fireblocks.sdk.model.DispatchPayoutResponse;
import com.fireblocks.sdk.model.PayoutResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class PaymentsPayoutApi {
private final HttpClient memberVarHttpClient;
private final ObjectMapper memberVarObjectMapper;
private final String memberVarBaseUri;
private final Consumer memberVarInterceptor;
private final Duration memberVarReadTimeout;
private final Consumer> memberVarResponseInterceptor;
private final Consumer> memberVarAsyncResponseInterceptor;
public PaymentsPayoutApi() {
this(new ApiClient());
}
public PaymentsPayoutApi(ApiClient apiClient) {
memberVarHttpClient = apiClient.getHttpClient();
memberVarObjectMapper = apiClient.getObjectMapper();
memberVarBaseUri = apiClient.getBaseUri();
memberVarInterceptor = apiClient.getRequestInterceptor();
memberVarReadTimeout = apiClient.getReadTimeout();
memberVarResponseInterceptor = apiClient.getResponseInterceptor();
memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor();
}
private ApiException getApiException(String operationId, HttpResponse response) {
String message =
formatExceptionMessage(operationId, response.statusCode(), response.body());
return new ApiException(
response.statusCode(), message, response.headers(), response.body());
}
private String formatExceptionMessage(String operationId, int statusCode, String body) {
if (body == null || body.isEmpty()) {
body = "[no body]";
}
return operationId + " call failed with: " + statusCode + " - " + body;
}
/**
* Create a payout instruction set **Note:** The reference content in this section documents the
* Payments Engine endpoint. The Payments Engine endpoints include APIs available only for
* customers with Payments Engine enabled on their accounts. </br> </br>These
* endpoints are currently in beta and might be subject to changes.</br> </br>If you
* want to learn more about Fireblocks Payments Engine, please contact your Fireblocks Customer
* Success Manager or email [email protected]. </br> </br> <b u>Create a
* payout instruction set.</b> </u></br> A payout instruction set is a set of
* instructions for distributing payments from a single payment account to a list of payee
* accounts. </br> The instruction set defines: </br> <ul> <li>the
* payment account and its account type (vault, exchange, or fiat). </li> <li>the
* account type (vault account, exchange account, whitelisted address, network connection, fiat
* account, or merchant account), the amount, and the asset of payment for each payee
* account.</li> </ul>
*
* @param createPayoutRequest (optional)
* @param idempotencyKey A unique identifier for the request. If the request is sent multiple
* times with the same idempotency key, the server will return the same response as the
* first request. The idempotency key is valid for 24 hours. (optional)
* @return CompletableFuture<ApiResponse<PayoutResponse>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> createPayout(
CreatePayoutRequest createPayoutRequest, String idempotencyKey) throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
createPayoutRequestBuilder(createPayoutRequest, idempotencyKey);
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (memberVarAsyncResponseInterceptor != null) {
memberVarAsyncResponseInterceptor.accept(localVarResponse);
}
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException("createPayout", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
PayoutResponse>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder createPayoutRequestBuilder(
CreatePayoutRequest createPayoutRequest, String idempotencyKey) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/payments/payout";
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
if (idempotencyKey != null) {
localVarRequestBuilder.header("Idempotency-Key", idempotencyKey.toString());
}
localVarRequestBuilder.header("Content-Type", "application/json");
localVarRequestBuilder.header("Accept", "application/json");
try {
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(createPayoutRequest);
localVarRequestBuilder.method(
"POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
} catch (IOException e) {
throw new ApiException(e);
}
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
/**
* Execute a payout instruction set **Note:** The reference content in this section documents
* the Payments Engine endpoint. The Payments Engine endpoints include APIs available only for
* customers with Payments Engine enabled on their accounts. </br> </br>These
* endpoints are currently in beta and might be subject to changes.</br> </br>If you
* want to learn more about Fireblocks Payments Engine, please contact your Fireblocks Customer
* Success Manager or email [email protected]. </br> </br><b u>Execute a
* payout instruction set.</b> </u> </br> </br>The instruction set will
* be verified and executed.</br> <b><u>Source locking</br></b>
* </u> If you are executing a payout instruction set from a payment account with an
* already active payout the active payout will complete before the new payout instruction set
* can be executed. </br> You cannot execute the same payout instruction set more than
* once.
*
* @param payoutId the payout id received from the creation of the payout instruction set
* (required)
* @param idempotencyKey A unique identifier for the request. If the request is sent multiple
* times with the same idempotency key, the server will return the same response as the
* first request. The idempotency key is valid for 24 hours. (optional)
* @return CompletableFuture<ApiResponse<DispatchPayoutResponse>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> executePayoutAction(
String payoutId, String idempotencyKey) throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
executePayoutActionRequestBuilder(payoutId, idempotencyKey);
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (memberVarAsyncResponseInterceptor != null) {
memberVarAsyncResponseInterceptor.accept(localVarResponse);
}
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException(
"executePayoutAction", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
DispatchPayoutResponse>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder executePayoutActionRequestBuilder(
String payoutId, String idempotencyKey) throws ApiException {
ValidationUtils.assertParamExistsAndNotEmpty("executePayoutAction", "payoutId", payoutId);
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath =
"/payments/payout/{payoutId}/actions/execute"
.replace("{payoutId}", ApiClient.urlEncode(payoutId.toString()));
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
if (idempotencyKey != null) {
localVarRequestBuilder.header("Idempotency-Key", idempotencyKey.toString());
}
localVarRequestBuilder.header("Accept", "application/json");
localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.noBody());
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
/**
* Get the status of a payout instruction set **Note:** The reference content in this section
* documents the Payments Engine endpoint. The Payments Engine endpoints include APIs available
* only for customers with Payments Engine enabled on their accounts. </br>
* </br>These endpoints are currently in beta and might be subject to changes.</br>
* </br>If you want to learn more about Fireblocks Payments Engine, please contact your
* Fireblocks Customer Success Manager or email [email protected]. </br>
*
* @param payoutId the payout id received from the creation of the payout instruction set
* (required)
* @return CompletableFuture<ApiResponse<PayoutResponse>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> getPayout(String payoutId)
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = getPayoutRequestBuilder(payoutId);
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (memberVarAsyncResponseInterceptor != null) {
memberVarAsyncResponseInterceptor.accept(localVarResponse);
}
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException("getPayout", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
PayoutResponse>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder getPayoutRequestBuilder(String payoutId) throws ApiException {
ValidationUtils.assertParamExistsAndNotEmpty("getPayout", "payoutId", payoutId);
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath =
"/payments/payout/{payoutId}"
.replace("{payoutId}", ApiClient.urlEncode(payoutId.toString()));
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Accept", "application/json");
localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody());
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
}