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

com.fireblocks.sdk.api.InternalWalletsApi Maven / Gradle / Ivy

/*
 * 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.CreateInternalWalletAssetRequest;
import com.fireblocks.sdk.model.CreateWalletRequest;
import com.fireblocks.sdk.model.SetCustomerRefIdRequest;
import com.fireblocks.sdk.model.UnmanagedWallet;
import com.fireblocks.sdk.model.WalletAsset;
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.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;

@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class InternalWalletsApi {
    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 InternalWalletsApi() {
        this(new ApiClient());
    }

    public InternalWalletsApi(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 an internal wallet Creates a new internal wallet with the requested name.
     *
     * @param createWalletRequest (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<UnmanagedWallet>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> createInternalWallet(
            CreateWalletRequest createWalletRequest, String idempotencyKey) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    createInternalWalletRequestBuilder(createWalletRequest, 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(
                                                    "createInternalWallet", 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<
                                                                            UnmanagedWallet>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder createInternalWalletRequestBuilder(
            CreateWalletRequest createWalletRequest, String idempotencyKey) throws ApiException {

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/internal_wallets";

        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(createWalletRequest);
            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;
    }
    /**
     * Add an asset to an internal wallet Adds an asset to an existing internal wallet.
     *
     * @param walletId The ID of the wallet (required)
     * @param assetId The ID of the asset to add (required)
     * @param createInternalWalletAssetRequest (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<WalletAsset>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> createInternalWalletAsset(
            String walletId,
            String assetId,
            CreateInternalWalletAssetRequest createInternalWalletAssetRequest,
            String idempotencyKey)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    createInternalWalletAssetRequestBuilder(
                            walletId, assetId, createInternalWalletAssetRequest, 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(
                                                    "createInternalWalletAsset", 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<
                                                                            WalletAsset>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder createInternalWalletAssetRequestBuilder(
            String walletId,
            String assetId,
            CreateInternalWalletAssetRequest createInternalWalletAssetRequest,
            String idempotencyKey)
            throws ApiException {
        ValidationUtils.assertParamExistsAndNotEmpty(
                "createInternalWalletAsset", "walletId", walletId);
        ValidationUtils.assertParamExistsAndNotEmpty(
                "createInternalWalletAsset", "assetId", assetId);

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath =
                "/internal_wallets/{walletId}/{assetId}"
                        .replace("{walletId}", ApiClient.urlEncode(walletId.toString()))
                        .replace("{assetId}", ApiClient.urlEncode(assetId.toString()));

        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(createInternalWalletAssetRequest);
            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;
    }
    /**
     * Delete an internal wallet Deletes an internal wallet by ID.
     *
     * @param walletId The ID of the wallet to delete (required)
     * @return CompletableFuture<ApiResponse<Void>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> deleteInternalWallet(String walletId)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    deleteInternalWalletRequestBuilder(walletId);
            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(
                                                    "deleteInternalWallet", localVarResponse));
                                }
                                return CompletableFuture.completedFuture(
                                        new ApiResponse(
                                                localVarResponse.statusCode(),
                                                localVarResponse.headers().map(),
                                                null));
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder deleteInternalWalletRequestBuilder(String walletId)
            throws ApiException {
        ValidationUtils.assertParamExistsAndNotEmpty("deleteInternalWallet", "walletId", walletId);

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath =
                "/internal_wallets/{walletId}"
                        .replace("{walletId}", ApiClient.urlEncode(walletId.toString()));

        localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

        localVarRequestBuilder.header("Accept", "application/json");

        localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody());
        if (memberVarReadTimeout != null) {
            localVarRequestBuilder.timeout(memberVarReadTimeout);
        }
        if (memberVarInterceptor != null) {
            memberVarInterceptor.accept(localVarRequestBuilder);
        }
        return localVarRequestBuilder;
    }
    /**
     * Delete a whitelisted address from an internal wallet Deletes a whitelisted address (for an
     * asset) from an internal wallet.
     *
     * @param walletId The ID of the wallet (required)
     * @param assetId The ID of the asset to delete (required)
     * @return CompletableFuture<ApiResponse<Void>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> deleteInternalWalletAsset(
            String walletId, String assetId) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    deleteInternalWalletAssetRequestBuilder(walletId, assetId);
            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(
                                                    "deleteInternalWalletAsset", localVarResponse));
                                }
                                return CompletableFuture.completedFuture(
                                        new ApiResponse(
                                                localVarResponse.statusCode(),
                                                localVarResponse.headers().map(),
                                                null));
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder deleteInternalWalletAssetRequestBuilder(
            String walletId, String assetId) throws ApiException {
        ValidationUtils.assertParamExistsAndNotEmpty(
                "deleteInternalWalletAsset", "walletId", walletId);
        ValidationUtils.assertParamExistsAndNotEmpty(
                "deleteInternalWalletAsset", "assetId", assetId);

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath =
                "/internal_wallets/{walletId}/{assetId}"
                        .replace("{walletId}", ApiClient.urlEncode(walletId.toString()))
                        .replace("{assetId}", ApiClient.urlEncode(assetId.toString()));

        localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

        localVarRequestBuilder.header("Accept", "application/json");

        localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody());
        if (memberVarReadTimeout != null) {
            localVarRequestBuilder.timeout(memberVarReadTimeout);
        }
        if (memberVarInterceptor != null) {
            memberVarInterceptor.accept(localVarRequestBuilder);
        }
        return localVarRequestBuilder;
    }
    /**
     * Get assets for internal wallet Returns all assets in an internal wallet by ID.
     *
     * @param walletId The ID of the wallet to return (required)
     * @return CompletableFuture<ApiResponse<UnmanagedWallet>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> getInternalWallet(String walletId)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder = getInternalWalletRequestBuilder(walletId);
            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("getInternalWallet", 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<
                                                                            UnmanagedWallet>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder getInternalWalletRequestBuilder(String walletId)
            throws ApiException {
        ValidationUtils.assertParamExistsAndNotEmpty("getInternalWallet", "walletId", walletId);

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath =
                "/internal_wallets/{walletId}"
                        .replace("{walletId}", ApiClient.urlEncode(walletId.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;
    }
    /**
     * Get an asset from an internal wallet Returns information for an asset in an internal wallet.
     *
     * @param walletId The ID of the wallet (required)
     * @param assetId The ID of the asset to return (required)
     * @return CompletableFuture<ApiResponse<WalletAsset>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> getInternalWalletAsset(
            String walletId, String assetId) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    getInternalWalletAssetRequestBuilder(walletId, assetId);
            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(
                                                    "getInternalWalletAsset", 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<
                                                                            WalletAsset>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder getInternalWalletAssetRequestBuilder(
            String walletId, String assetId) throws ApiException {
        ValidationUtils.assertParamExistsAndNotEmpty(
                "getInternalWalletAsset", "walletId", walletId);
        ValidationUtils.assertParamExistsAndNotEmpty("getInternalWalletAsset", "assetId", assetId);

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath =
                "/internal_wallets/{walletId}/{assetId}"
                        .replace("{walletId}", ApiClient.urlEncode(walletId.toString()))
                        .replace("{assetId}", ApiClient.urlEncode(assetId.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;
    }
    /**
     * List internal wallets Gets a list of internal wallets. **Note**: BTC-based assets belonging
     * to whitelisted addresses cannot be retrieved between 00:00 UTC and 00:01 UTC daily due to
     * third-party provider, Blockchair, being unavailable for this 60 second period. Please wait
     * until the next minute to retrieve BTC-based assets.
     *
     * @return CompletableFuture<ApiResponse<List<UnmanagedWallet>>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture>> getInternalWallets()
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder = getInternalWalletsRequestBuilder();
            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(
                                                    "getInternalWallets", 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<
                                                                            List<
                                                                                    UnmanagedWallet>>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder getInternalWalletsRequestBuilder() throws ApiException {

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/internal_wallets";

        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;
    }
    /**
     * Set an AML/KYT customer reference ID for an internal wallet Sets an AML/KYT customer
     * reference ID for the specific internal wallet.
     *
     * @param setCustomerRefIdRequest (required)
     * @param walletId The wallet ID (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<Void>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> setCustomerRefIdForInternalWallet(
            SetCustomerRefIdRequest setCustomerRefIdRequest, String walletId, String idempotencyKey)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    setCustomerRefIdForInternalWalletRequestBuilder(
                            setCustomerRefIdRequest, walletId, 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(
                                                    "setCustomerRefIdForInternalWallet",
                                                    localVarResponse));
                                }
                                return CompletableFuture.completedFuture(
                                        new ApiResponse(
                                                localVarResponse.statusCode(),
                                                localVarResponse.headers().map(),
                                                null));
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder setCustomerRefIdForInternalWalletRequestBuilder(
            SetCustomerRefIdRequest setCustomerRefIdRequest, String walletId, String idempotencyKey)
            throws ApiException {
        ValidationUtils.assertParamExists(
                "setCustomerRefIdForInternalWallet",
                "setCustomerRefIdRequest",
                setCustomerRefIdRequest);
        ValidationUtils.assertParamExistsAndNotEmpty(
                "setCustomerRefIdForInternalWallet", "walletId", walletId);

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath =
                "/internal_wallets/{walletId}/set_customer_ref_id"
                        .replace("{walletId}", ApiClient.urlEncode(walletId.toString()));

        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(setCustomerRefIdRequest);
            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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy