Please wait. This can take some minutes ...
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.
com.fireblocks.sdk.api.TokenizationApi 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.CollectionBurnRequestDto;
import com.fireblocks.sdk.model.CollectionBurnResponseDto;
import com.fireblocks.sdk.model.CollectionDeployRequestDto;
import com.fireblocks.sdk.model.CollectionLinkDto;
import com.fireblocks.sdk.model.CollectionMintRequestDto;
import com.fireblocks.sdk.model.CollectionMintResponseDto;
import com.fireblocks.sdk.model.CreateTokenRequestDto;
import com.fireblocks.sdk.model.GetLinkedCollectionsPaginatedResponse;
import com.fireblocks.sdk.model.TokenLinkDto;
import com.fireblocks.sdk.model.TokenLinkRequestDto;
import com.fireblocks.sdk.model.TokensPaginatedResponse;
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 TokenizationApi {
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 TokenizationApi() {
this(new ApiClient());
}
public TokenizationApi(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;
}
/**
* Burn tokens Burn tokens in a collection
*
* @param collectionBurnRequestDto (required)
* @param id The collection link 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<CollectionBurnResponseDto>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> burnCollectionToken(
CollectionBurnRequestDto collectionBurnRequestDto, String id, String idempotencyKey)
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
burnCollectionTokenRequestBuilder(collectionBurnRequestDto, 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(
"burnCollectionToken", 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<
CollectionBurnResponseDto>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder burnCollectionTokenRequestBuilder(
CollectionBurnRequestDto collectionBurnRequestDto, String id, String idempotencyKey)
throws ApiException {
ValidationUtils.assertParamExists(
"burnCollectionToken", "collectionBurnRequestDto", collectionBurnRequestDto);
ValidationUtils.assertParamExistsAndNotEmpty("burnCollectionToken", "id", id);
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath =
"/tokenization/collections/{id}/tokens/burn"
.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(collectionBurnRequestDto);
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;
}
/**
* Create a new collection Create a new collection and link it as a token
*
* @param collectionDeployRequestDto (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<CollectionLinkDto>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> createNewCollection(
CollectionDeployRequestDto collectionDeployRequestDto, String idempotencyKey)
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
createNewCollectionRequestBuilder(collectionDeployRequestDto, 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(
"createNewCollection", 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<
CollectionLinkDto>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder createNewCollectionRequestBuilder(
CollectionDeployRequestDto collectionDeployRequestDto, String idempotencyKey)
throws ApiException {
ValidationUtils.assertParamExists(
"createNewCollection", "collectionDeployRequestDto", collectionDeployRequestDto);
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/tokenization/collections";
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(collectionDeployRequestDto);
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;
}
/**
* Get collection token details Get collection token details by id
*
* @param id The collection link id (required)
* @param tokenId The tokenId as it appears on the blockchain (required)
* @return CompletableFuture<ApiResponse<CollectionLinkDto>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> fetchCollectionTokenDetails(
String id, String tokenId) throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
fetchCollectionTokenDetailsRequestBuilder(id, tokenId);
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(
"fetchCollectionTokenDetails",
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<
CollectionLinkDto>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder fetchCollectionTokenDetailsRequestBuilder(String id, String tokenId)
throws ApiException {
ValidationUtils.assertParamExistsAndNotEmpty("fetchCollectionTokenDetails", "id", id);
ValidationUtils.assertParamExistsAndNotEmpty(
"fetchCollectionTokenDetails", "tokenId", tokenId);
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath =
"/tokenization/collections/{id}/tokens/{tokenId}"
.replace("{id}", ApiClient.urlEncode(id.toString()))
.replace("{tokenId}", ApiClient.urlEncode(tokenId.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 a collection by id Get a collection by id
*
* @param id The token link id (required)
* @return CompletableFuture<ApiResponse<CollectionLinkDto>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> getCollectionById(String id)
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = getCollectionByIdRequestBuilder(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("getCollectionById", 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<
CollectionLinkDto>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder getCollectionByIdRequestBuilder(String id) throws ApiException {
ValidationUtils.assertParamExistsAndNotEmpty("getCollectionById", "id", id);
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath =
"/tokenization/collections/{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;
}
/**
* Get collections Get collections (paginated)
*
* @param pageCursor Page cursor to get the next page, for example -
* \"MjAyMy0xMi0xMyAyMDozNjowOC4zMDI=:MTEwMA==\" (optional)
* @param pageSize Number of items per page (max 100), requesting more then 100 will return 100
* items (optional, default to 100)
* @param status A comma separated list of statuses to filter. Default is
* \"COMPLETED\" (optional)
* @return CompletableFuture<ApiResponse<GetLinkedCollectionsPaginatedResponse>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture>
getLinkedCollections(String pageCursor, BigDecimal pageSize, Object status)
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
getLinkedCollectionsRequestBuilder(pageCursor, pageSize, 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(
"getLinkedCollections", 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<
GetLinkedCollectionsPaginatedResponse>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder getLinkedCollectionsRequestBuilder(
String pageCursor, BigDecimal pageSize, Object status) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/tokenization/collections";
List localVarQueryParams = new ArrayList<>();
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
localVarQueryParameterBaseName = "pageCursor";
localVarQueryParams.addAll(ApiClient.parameterToPairs("pageCursor", pageCursor));
localVarQueryParameterBaseName = "pageSize";
localVarQueryParams.addAll(ApiClient.parameterToPairs("pageSize", pageSize));
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;
}
/**
* Return a linked token Return a linked token, with its status and metadata.
*
* @param id The token link id (required)
* @return CompletableFuture<ApiResponse<TokenLinkDto>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> getLinkedToken(String id)
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = getLinkedTokenRequestBuilder(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("getLinkedToken", 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<
TokenLinkDto>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder getLinkedTokenRequestBuilder(String id) throws ApiException {
ValidationUtils.assertParamExistsAndNotEmpty("getLinkedToken", "id", id);
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath =
"/tokenization/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 all linked tokens Return all linked tokens (paginated)
*
* @param pageCursor Page cursor to get the next page (optional)
* @param pageSize Number of items per page, requesting more then max will return max items
* (optional)
* @param status A comma separated list of statuses to filter. Default is
* \"COMPLETED\" (optional)
* @return CompletableFuture<ApiResponse<TokensPaginatedResponse>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> getLinkedTokens(
String pageCursor, BigDecimal pageSize, Object status) throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
getLinkedTokensRequestBuilder(pageCursor, pageSize, 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("getLinkedTokens", 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<
TokensPaginatedResponse>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder getLinkedTokensRequestBuilder(
String pageCursor, BigDecimal pageSize, Object status) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/tokenization/tokens";
List localVarQueryParams = new ArrayList<>();
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
localVarQueryParameterBaseName = "pageCursor";
localVarQueryParams.addAll(ApiClient.parameterToPairs("pageCursor", pageCursor));
localVarQueryParameterBaseName = "pageSize";
localVarQueryParams.addAll(ApiClient.parameterToPairs("pageSize", pageSize));
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;
}
/**
* Issue a new token Facilitates the creation of a new token, supporting both EVM-based and
* Stellar/Ripple platforms. For EVM, it deploys the corresponding contract template to the
* blockchain and links the token to the workspace. For Stellar/Ripple, it links a newly created
* token directly to the workspace without deploying a contract. Returns the token link with
* status \"PENDING\" until the token is deployed or \"SUCCESS\" if no
* deployment is needed.
*
* @param createTokenRequestDto (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<TokenLinkDto>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> issueNewToken(
CreateTokenRequestDto createTokenRequestDto, String idempotencyKey)
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
issueNewTokenRequestBuilder(createTokenRequestDto, 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("issueNewToken", 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<
TokenLinkDto>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder issueNewTokenRequestBuilder(
CreateTokenRequestDto createTokenRequestDto, String idempotencyKey)
throws ApiException {
ValidationUtils.assertParamExists(
"issueNewToken", "createTokenRequestDto", createTokenRequestDto);
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/tokenization/tokens";
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(createTokenRequestDto);
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;
}
/**
* Link a contract Link an a contract
*
* @param tokenLinkRequestDto (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<TokenLinkDto>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> link(
TokenLinkRequestDto tokenLinkRequestDto, String idempotencyKey) throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
linkRequestBuilder(tokenLinkRequestDto, 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("link", 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<
TokenLinkDto>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder linkRequestBuilder(
TokenLinkRequestDto tokenLinkRequestDto, String idempotencyKey) throws ApiException {
ValidationUtils.assertParamExists("link", "tokenLinkRequestDto", tokenLinkRequestDto);
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/tokenization/tokens/link";
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(tokenLinkRequestDto);
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;
}
/**
* Mint tokens Mint tokens and upload metadata
*
* @param collectionMintRequestDto (required)
* @param id The collection link 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<CollectionMintResponseDto>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> mintCollectionToken(
CollectionMintRequestDto collectionMintRequestDto, String id, String idempotencyKey)
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
mintCollectionTokenRequestBuilder(collectionMintRequestDto, 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(
"mintCollectionToken", 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<
CollectionMintResponseDto>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder mintCollectionTokenRequestBuilder(
CollectionMintRequestDto collectionMintRequestDto, String id, String idempotencyKey)
throws ApiException {
ValidationUtils.assertParamExists(
"mintCollectionToken", "collectionMintRequestDto", collectionMintRequestDto);
ValidationUtils.assertParamExistsAndNotEmpty("mintCollectionToken", "id", id);
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath =
"/tokenization/collections/{id}/tokens/mint"
.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(collectionMintRequestDto);
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;
}
/**
* Unlink a token Unlink a token. The token will be unlinked from the workspace. The token will
* not be deleted on chain nor the refId, only the link to the workspace will be removed.
*
* @param id The token link id (required)
* @return CompletableFuture<ApiResponse<Void>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> unlink(String id) throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = unlinkRequestBuilder(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("unlink", localVarResponse));
}
return CompletableFuture.completedFuture(
new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null));
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder unlinkRequestBuilder(String id) throws ApiException {
ValidationUtils.assertParamExistsAndNotEmpty("unlink", "id", id);
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath =
"/tokenization/tokens/{id}".replace("{id}", ApiClient.urlEncode(id.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 collection link Delete a collection link
*
* @param id The token link id (required)
* @return CompletableFuture<ApiResponse<Void>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> unlinkCollection(String id) throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = unlinkCollectionRequestBuilder(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("unlinkCollection", localVarResponse));
}
return CompletableFuture.completedFuture(
new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null));
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder unlinkCollectionRequestBuilder(String id) throws ApiException {
ValidationUtils.assertParamExistsAndNotEmpty("unlinkCollection", "id", id);
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath =
"/tokenization/collections/{id}"
.replace("{id}", ApiClient.urlEncode(id.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;
}
}