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

com.fireblocks.sdk.api.NftsApi 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.Pair;
import com.fireblocks.sdk.ValidationUtils;
import com.fireblocks.sdk.model.GetNFTsResponse;
import com.fireblocks.sdk.model.GetOwnershipTokensResponse;
import com.fireblocks.sdk.model.ListOwnedCollectionsResponse;
import com.fireblocks.sdk.model.ListOwnedTokensResponse;
import com.fireblocks.sdk.model.TokenOwnershipSpamUpdatePayload;
import com.fireblocks.sdk.model.TokenOwnershipStatusUpdatePayload;
import com.fireblocks.sdk.model.TokenResponse;
import com.fireblocks.sdk.model.UpdateTokenOwnershipStatusDto;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
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.ArrayList;
import java.util.List;
import java.util.StringJoiner;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;

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

    public NftsApi(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;
    }

    /**
     * List token data by ID Returns the requested token data.
     *
     * @param id NFT ID (required)
     * @return CompletableFuture<ApiResponse<TokenResponse>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> getNFT(String id) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder = getNFTRequestBuilder(id);
            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("getNFT", 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<
                                                                            TokenResponse>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder getNFTRequestBuilder(String id) throws ApiException {
        ValidationUtils.assertParamExistsAndNotEmpty("getNFT", "id", id);

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath =
                "/nfts/tokens/{id}".replace("{id}", ApiClient.urlEncode(id.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 tokens by IDs Returns the requested tokens data.
     *
     * @param ids A comma separated list of NFT IDs. Up to 100 are allowed in a single request.
     *     (required)
     * @param pageCursor Page cursor to fetch (optional)
     * @param pageSize Items per page (max 100) (optional)
     * @param sort Sort by param, it can be one param or a list of params separated by comma
     *     (optional
     * @param order Order direction, it can be `ASC` for ascending or `DESC` for
     *     descending (optional, default to ASC)
     * @return CompletableFuture<ApiResponse<GetNFTsResponse>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> getNFTs(
            String ids, String pageCursor, BigDecimal pageSize, List sort, String order)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    getNFTsRequestBuilder(ids, pageCursor, pageSize, sort, order);
            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("getNFTs", 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<
                                                                            GetNFTsResponse>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder getNFTsRequestBuilder(
            String ids, String pageCursor, BigDecimal pageSize, List sort, String order)
            throws ApiException {
        ValidationUtils.assertParamExistsAndNotEmpty("getNFTs", "ids", ids);

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/nfts/tokens";

        List localVarQueryParams = new ArrayList<>();
        StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
        String localVarQueryParameterBaseName;
        localVarQueryParameterBaseName = "ids";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("ids", ids));
        localVarQueryParameterBaseName = "pageCursor";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("pageCursor", pageCursor));
        localVarQueryParameterBaseName = "pageSize";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("pageSize", pageSize));
        localVarQueryParameterBaseName = "sort";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("multi", "sort", sort));
        localVarQueryParameterBaseName = "order";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("order", order));

        if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) {
            StringJoiner queryJoiner = new StringJoiner("&");
            localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue()));
            if (localVarQueryStringJoiner.length() != 0) {
                queryJoiner.add(localVarQueryStringJoiner.toString());
            }
            localVarRequestBuilder.uri(
                    URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString()));
        } else {
            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 all owned tokens (paginated) Returns all tokens and their data in your workspace.
     *
     * @param blockchainDescriptor Blockchain descriptor filter (optional)
     * @param vaultAccountIds A comma separated list of Vault Account IDs. Up to 100 are allowed in
     *     a single request. This field will be ignored when walletType=END_USER_WALLET or
     *     ncwId is provided. (optional)
     * @param ncwId Tenant's Non-Custodial Wallet ID (optional)
     * @param ncwAccountIds A comma separated list of Non-Custodial account IDs. Up to 100 are
     *     allowed in a single request. This field will be ignored when
     *     walletType=VAULT_ACCOUNT or ncwId is not provided. (optional)
     * @param walletType Wallet type, it can be `VAULT_ACCOUNT` or
     *     `END_USER_WALLET` (optional, default to VAULT_ACCOUNT)
     * @param ids A comma separated list of NFT IDs. Up to 100 are allowed in a single request.
     *     (optional)
     * @param collectionIds A comma separated list of collection IDs. Up to 100 are allowed in a
     *     single request. (optional)
     * @param pageCursor Page cursor to fetch (optional)
     * @param pageSize Items per page (max 100) (optional)
     * @param sort Sort by param, it can be one param or a list of params separated by comma
     *     (optional
     * @param order Order direction, it can be `ASC` for ascending or `DESC` for
     *     descending (optional, default to ASC)
     * @param status Token ownership status (optional, default to LISTED)
     * @param search Search owned tokens and their collections. Possible criteria for search: token
     *     name and id within the contract/collection, collection name, blockchain descriptor and
     *     name. (optional)
     * @param spam Token ownership spam status. (optional)
     * @return CompletableFuture<ApiResponse<GetOwnershipTokensResponse>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> getOwnershipTokens(
            String blockchainDescriptor,
            String vaultAccountIds,
            String ncwId,
            String ncwAccountIds,
            String walletType,
            String ids,
            String collectionIds,
            String pageCursor,
            BigDecimal pageSize,
            List sort,
            String order,
            String status,
            String search,
            String spam)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    getOwnershipTokensRequestBuilder(
                            blockchainDescriptor,
                            vaultAccountIds,
                            ncwId,
                            ncwAccountIds,
                            walletType,
                            ids,
                            collectionIds,
                            pageCursor,
                            pageSize,
                            sort,
                            order,
                            status,
                            search,
                            spam);
            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(
                                                    "getOwnershipTokens", 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<
                                                                            GetOwnershipTokensResponse>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder getOwnershipTokensRequestBuilder(
            String blockchainDescriptor,
            String vaultAccountIds,
            String ncwId,
            String ncwAccountIds,
            String walletType,
            String ids,
            String collectionIds,
            String pageCursor,
            BigDecimal pageSize,
            List sort,
            String order,
            String status,
            String search,
            String spam)
            throws ApiException {

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/nfts/ownership/tokens";

        List localVarQueryParams = new ArrayList<>();
        StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
        String localVarQueryParameterBaseName;
        localVarQueryParameterBaseName = "blockchainDescriptor";
        localVarQueryParams.addAll(
                ApiClient.parameterToPairs("blockchainDescriptor", blockchainDescriptor));
        localVarQueryParameterBaseName = "vaultAccountIds";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("vaultAccountIds", vaultAccountIds));
        localVarQueryParameterBaseName = "ncwId";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("ncwId", ncwId));
        localVarQueryParameterBaseName = "ncwAccountIds";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("ncwAccountIds", ncwAccountIds));
        localVarQueryParameterBaseName = "walletType";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("walletType", walletType));
        localVarQueryParameterBaseName = "ids";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("ids", ids));
        localVarQueryParameterBaseName = "collectionIds";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("collectionIds", collectionIds));
        localVarQueryParameterBaseName = "pageCursor";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("pageCursor", pageCursor));
        localVarQueryParameterBaseName = "pageSize";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("pageSize", pageSize));
        localVarQueryParameterBaseName = "sort";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("multi", "sort", sort));
        localVarQueryParameterBaseName = "order";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("order", order));
        localVarQueryParameterBaseName = "status";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("status", status));
        localVarQueryParameterBaseName = "search";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("search", search));
        localVarQueryParameterBaseName = "spam";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("spam", spam));

        if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) {
            StringJoiner queryJoiner = new StringJoiner("&");
            localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue()));
            if (localVarQueryStringJoiner.length() != 0) {
                queryJoiner.add(localVarQueryStringJoiner.toString());
            }
            localVarRequestBuilder.uri(
                    URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString()));
        } else {
            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 owned collections (paginated) Returns all collections in your workspace
     *
     * @param ncwId Tenant's Non-Custodial Wallet ID (optional)
     * @param walletType Wallet type, it can be `VAULT_ACCOUNT` or
     *     `END_USER_WALLET` (optional, default to VAULT_ACCOUNT)
     * @param search Search owned collections. Possible criteria for search: collection name,
     *     collection contract address. (optional)
     * @param pageCursor Page cursor to fetch (optional)
     * @param pageSize Items per page (max 100) (optional)
     * @param sort Sort by param, it can be one param or a list of params separated by comma
     *     (optional
     * @param order Order direction, it can be `ASC` for ascending or `DESC` for
     *     descending (optional, default to ASC)
     * @param status Token ownership status (optional, default to LISTED)
     * @return CompletableFuture<ApiResponse<ListOwnedCollectionsResponse>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> listOwnedCollections(
            String ncwId,
            String walletType,
            String search,
            String pageCursor,
            BigDecimal pageSize,
            List sort,
            String order,
            String status)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    listOwnedCollectionsRequestBuilder(
                            ncwId, walletType, search, pageCursor, pageSize, sort, order, status);
            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(
                                                    "listOwnedCollections", 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<
                                                                            ListOwnedCollectionsResponse>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder listOwnedCollectionsRequestBuilder(
            String ncwId,
            String walletType,
            String search,
            String pageCursor,
            BigDecimal pageSize,
            List sort,
            String order,
            String status)
            throws ApiException {

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/nfts/ownership/collections";

        List localVarQueryParams = new ArrayList<>();
        StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
        String localVarQueryParameterBaseName;
        localVarQueryParameterBaseName = "ncwId";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("ncwId", ncwId));
        localVarQueryParameterBaseName = "walletType";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("walletType", walletType));
        localVarQueryParameterBaseName = "search";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("search", search));
        localVarQueryParameterBaseName = "pageCursor";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("pageCursor", pageCursor));
        localVarQueryParameterBaseName = "pageSize";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("pageSize", pageSize));
        localVarQueryParameterBaseName = "sort";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("multi", "sort", sort));
        localVarQueryParameterBaseName = "order";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("order", order));
        localVarQueryParameterBaseName = "status";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("status", status));

        if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) {
            StringJoiner queryJoiner = new StringJoiner("&");
            localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue()));
            if (localVarQueryStringJoiner.length() != 0) {
                queryJoiner.add(localVarQueryStringJoiner.toString());
            }
            localVarRequestBuilder.uri(
                    URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString()));
        } else {
            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 all distinct owned tokens (paginated) Returns all owned distinct tokens (for your
     * tenant) and their data in your workspace.
     *
     * @param ncwId Tenant's Non-Custodial Wallet ID (optional)
     * @param walletType Wallet type, it can be `VAULT_ACCOUNT` or
     *     `END_USER_WALLET` (optional, default to VAULT_ACCOUNT)
     * @param pageCursor Page cursor to fetch (optional)
     * @param pageSize Items per page (max 100) (optional)
     * @param sort Sort by param, it can be one param or a list of params separated by comma
     *     (optional
     * @param order Order direction, it can be `ASC` for ascending or `DESC` for
     *     descending (optional, default to ASC)
     * @param status Token ownership status (optional, default to LISTED)
     * @param search Search owned tokens by token name (optional)
     * @param spam Token ownership spam status. (optional)
     * @return CompletableFuture<ApiResponse<ListOwnedTokensResponse>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> listOwnedTokens(
            String ncwId,
            String walletType,
            String pageCursor,
            BigDecimal pageSize,
            List sort,
            String order,
            String status,
            String search,
            String spam)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    listOwnedTokensRequestBuilder(
                            ncwId,
                            walletType,
                            pageCursor,
                            pageSize,
                            sort,
                            order,
                            status,
                            search,
                            spam);
            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("listOwnedTokens", 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<
                                                                            ListOwnedTokensResponse>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder listOwnedTokensRequestBuilder(
            String ncwId,
            String walletType,
            String pageCursor,
            BigDecimal pageSize,
            List sort,
            String order,
            String status,
            String search,
            String spam)
            throws ApiException {

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/nfts/ownership/assets";

        List localVarQueryParams = new ArrayList<>();
        StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
        String localVarQueryParameterBaseName;
        localVarQueryParameterBaseName = "ncwId";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("ncwId", ncwId));
        localVarQueryParameterBaseName = "walletType";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("walletType", walletType));
        localVarQueryParameterBaseName = "pageCursor";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("pageCursor", pageCursor));
        localVarQueryParameterBaseName = "pageSize";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("pageSize", pageSize));
        localVarQueryParameterBaseName = "sort";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("multi", "sort", sort));
        localVarQueryParameterBaseName = "order";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("order", order));
        localVarQueryParameterBaseName = "status";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("status", status));
        localVarQueryParameterBaseName = "search";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("search", search));
        localVarQueryParameterBaseName = "spam";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("spam", spam));

        if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) {
            StringJoiner queryJoiner = new StringJoiner("&");
            localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue()));
            if (localVarQueryStringJoiner.length() != 0) {
                queryJoiner.add(localVarQueryStringJoiner.toString());
            }
            localVarRequestBuilder.uri(
                    URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString()));
        } else {
            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;
    }
    /**
     * Refresh token metadata Updates the latest token metadata.
     *
     * @param id NFT 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> refreshNFTMetadata(String id, String idempotencyKey)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    refreshNFTMetadataRequestBuilder(id, 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(
                                                    "refreshNFTMetadata", localVarResponse));
                                }
                                return CompletableFuture.completedFuture(
                                        new ApiResponse(
                                                localVarResponse.statusCode(),
                                                localVarResponse.headers().map(),
                                                null));
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder refreshNFTMetadataRequestBuilder(String id, String idempotencyKey)
            throws ApiException {
        ValidationUtils.assertParamExistsAndNotEmpty("refreshNFTMetadata", "id", id);

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath =
                "/nfts/tokens/{id}".replace("{id}", ApiClient.urlEncode(id.toString()));

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

        if (idempotencyKey != null) {
            localVarRequestBuilder.header("Idempotency-Key", idempotencyKey.toString());
        }
        localVarRequestBuilder.header("Accept", "application/json");

        localVarRequestBuilder.method("PUT", HttpRequest.BodyPublishers.noBody());
        if (memberVarReadTimeout != null) {
            localVarRequestBuilder.timeout(memberVarReadTimeout);
        }
        if (memberVarInterceptor != null) {
            memberVarInterceptor.accept(localVarRequestBuilder);
        }
        return localVarRequestBuilder;
    }
    /**
     * Refresh vault account tokens Updates all tokens and balances per blockchain and vault
     * account.
     *
     * @param blockchainDescriptor Blockchain descriptor filter (required)
     * @param vaultAccountId Vault account filter (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> updateOwnershipTokens(
            String blockchainDescriptor, String vaultAccountId, String idempotencyKey)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    updateOwnershipTokensRequestBuilder(
                            blockchainDescriptor, vaultAccountId, 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(
                                                    "updateOwnershipTokens", localVarResponse));
                                }
                                return CompletableFuture.completedFuture(
                                        new ApiResponse(
                                                localVarResponse.statusCode(),
                                                localVarResponse.headers().map(),
                                                null));
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder updateOwnershipTokensRequestBuilder(
            String blockchainDescriptor, String vaultAccountId, String idempotencyKey)
            throws ApiException {
        ValidationUtils.assertParamExistsAndNotEmpty(
                "updateOwnershipTokens", "blockchainDescriptor", blockchainDescriptor);
        ValidationUtils.assertParamExistsAndNotEmpty(
                "updateOwnershipTokens", "vaultAccountId", vaultAccountId);

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/nfts/ownership/tokens";

        List localVarQueryParams = new ArrayList<>();
        StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
        String localVarQueryParameterBaseName;
        localVarQueryParameterBaseName = "blockchainDescriptor";
        localVarQueryParams.addAll(
                ApiClient.parameterToPairs("blockchainDescriptor", blockchainDescriptor));
        localVarQueryParameterBaseName = "vaultAccountId";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("vaultAccountId", vaultAccountId));

        if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) {
            StringJoiner queryJoiner = new StringJoiner("&");
            localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue()));
            if (localVarQueryStringJoiner.length() != 0) {
                queryJoiner.add(localVarQueryStringJoiner.toString());
            }
            localVarRequestBuilder.uri(
                    URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString()));
        } else {
            localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
        }

        if (idempotencyKey != null) {
            localVarRequestBuilder.header("Idempotency-Key", idempotencyKey.toString());
        }
        localVarRequestBuilder.header("Accept", "application/json");

        localVarRequestBuilder.method("PUT", HttpRequest.BodyPublishers.noBody());
        if (memberVarReadTimeout != null) {
            localVarRequestBuilder.timeout(memberVarReadTimeout);
        }
        if (memberVarInterceptor != null) {
            memberVarInterceptor.accept(localVarRequestBuilder);
        }
        return localVarRequestBuilder;
    }
    /**
     * Update token ownership status Updates token status for a tenant, in all tenant vaults.
     *
     * @param updateTokenOwnershipStatusDto (required)
     * @param id NFT 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> updateTokenOwnershipStatus(
            UpdateTokenOwnershipStatusDto updateTokenOwnershipStatusDto,
            String id,
            String idempotencyKey)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    updateTokenOwnershipStatusRequestBuilder(
                            updateTokenOwnershipStatusDto, id, 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(
                                                    "updateTokenOwnershipStatus",
                                                    localVarResponse));
                                }
                                return CompletableFuture.completedFuture(
                                        new ApiResponse(
                                                localVarResponse.statusCode(),
                                                localVarResponse.headers().map(),
                                                null));
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder updateTokenOwnershipStatusRequestBuilder(
            UpdateTokenOwnershipStatusDto updateTokenOwnershipStatusDto,
            String id,
            String idempotencyKey)
            throws ApiException {
        ValidationUtils.assertParamExists(
                "updateTokenOwnershipStatus",
                "updateTokenOwnershipStatusDto",
                updateTokenOwnershipStatusDto);
        ValidationUtils.assertParamExistsAndNotEmpty("updateTokenOwnershipStatus", "id", id);

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath =
                "/nfts/ownership/tokens/{id}/status"
                        .replace("{id}", ApiClient.urlEncode(id.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(updateTokenOwnershipStatusDto);
            localVarRequestBuilder.method(
                    "PUT", 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;
    }
    /**
     * Update tokens ownership spam property Updates tokens spam property for a tenant's token
     * ownerships, in all tenant vaults.
     *
     * @param tokenOwnershipSpamUpdatePayload (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> updateTokensOwnershipSpam(
            List tokenOwnershipSpamUpdatePayload,
            String idempotencyKey)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    updateTokensOwnershipSpamRequestBuilder(
                            tokenOwnershipSpamUpdatePayload, 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(
                                                    "updateTokensOwnershipSpam", localVarResponse));
                                }
                                return CompletableFuture.completedFuture(
                                        new ApiResponse(
                                                localVarResponse.statusCode(),
                                                localVarResponse.headers().map(),
                                                null));
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder updateTokensOwnershipSpamRequestBuilder(
            List tokenOwnershipSpamUpdatePayload,
            String idempotencyKey)
            throws ApiException {
        ValidationUtils.assertParamExists(
                "updateTokensOwnershipSpam",
                "tokenOwnershipSpamUpdatePayload",
                tokenOwnershipSpamUpdatePayload);

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/nfts/ownership/tokens/spam";

        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(tokenOwnershipSpamUpdatePayload);
            localVarRequestBuilder.method(
                    "PUT", 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;
    }
    /**
     * Update tokens ownership status Updates tokens status for a tenant, in all tenant vaults.
     *
     * @param tokenOwnershipStatusUpdatePayload (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> updateTokensOwnershipStatus(
            List tokenOwnershipStatusUpdatePayload,
            String idempotencyKey)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    updateTokensOwnershipStatusRequestBuilder(
                            tokenOwnershipStatusUpdatePayload, 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(
                                                    "updateTokensOwnershipStatus",
                                                    localVarResponse));
                                }
                                return CompletableFuture.completedFuture(
                                        new ApiResponse(
                                                localVarResponse.statusCode(),
                                                localVarResponse.headers().map(),
                                                null));
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder updateTokensOwnershipStatusRequestBuilder(
            List tokenOwnershipStatusUpdatePayload,
            String idempotencyKey)
            throws ApiException {
        ValidationUtils.assertParamExists(
                "updateTokensOwnershipStatus",
                "tokenOwnershipStatusUpdatePayload",
                tokenOwnershipStatusUpdatePayload);

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/nfts/ownership/tokens/status";

        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(tokenOwnershipStatusUpdatePayload);
            localVarRequestBuilder.method(
                    "PUT", 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