io.nem.sdk.openapi.jersey2.api.ReceiptRoutesApi Maven / Gradle / Ivy
package io.nem.sdk.openapi.jersey2.api;
import io.nem.sdk.openapi.jersey2.invoker.ApiException;
import io.nem.sdk.openapi.jersey2.invoker.ApiClient;
import io.nem.sdk.openapi.jersey2.invoker.ApiResponse;
import io.nem.sdk.openapi.jersey2.invoker.Configuration;
import io.nem.sdk.openapi.jersey2.invoker.Pair;
import javax.ws.rs.core.GenericType;
import io.nem.sdk.openapi.jersey2.model.MerkleProofInfoDTO;
import io.nem.sdk.openapi.jersey2.model.ModelError;
import io.nem.sdk.openapi.jersey2.model.StatementsDTO;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2020-02-18T19:12:13.803Z[UTC]")
public class ReceiptRoutesApi {
private ApiClient apiClient;
public ReceiptRoutesApi() {
this(Configuration.getDefaultApiClient());
}
public ReceiptRoutesApi(ApiClient apiClient) {
this.apiClient = apiClient;
}
public ApiClient getApiClient() {
return apiClient;
}
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Get receipts from a block
* Returns the receipts linked to a block.
* @param height Block height. (required)
* @return StatementsDTO
* @throws ApiException if fails to make API call
* @http.response.details
Status Code Description Response Headers
200 success -
404 ResourceNotFound -
409 InvalidArgument -
*/
public StatementsDTO getBlockReceipts(java.math.BigInteger height) throws ApiException {
return getBlockReceiptsWithHttpInfo(height).getData();
}
/**
* Get receipts from a block
* Returns the receipts linked to a block.
* @param height Block height. (required)
* @return ApiResponse<StatementsDTO>
* @throws ApiException if fails to make API call
* @http.response.details
Status Code Description Response Headers
200 success -
404 ResourceNotFound -
409 InvalidArgument -
*/
public ApiResponse getBlockReceiptsWithHttpInfo(java.math.BigInteger height) throws ApiException {
Object localVarPostBody = new Object();
// verify the required parameter 'height' is set
if (height == null) {
throw new ApiException(400, "Missing the required parameter 'height' when calling getBlockReceipts");
}
// create path and map variables
String localVarPath = "/block/{height}/receipts"
.replaceAll("\\{" + "height" + "\\}", apiClient.escapeString(height.toString()));
// query params
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { };
GenericType localVarReturnType = new GenericType() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
/**
* Get the merkle path for a given a receipt statement hash and block
* Returns the merkle path for a receipt statement or resolution linked to a block. The merkle path is the minimum number of nodes needed to calculate the merkle root. Steps to calculate the merkle root: 1. proofHash = hash (leaf). 2. Concatenate proofHash with the first unprocessed item from the merklePath list as follows: * a) If item.position == left -> proofHash = sha_256(item.hash + proofHash). * b) If item.position == right -> proofHash = sha_256(proofHash+ item.hash). 3. Repeat 2. for every item in the merklePath list. 4. Compare if the calculated proofHash equals the one recorded in the block header (block.receiptsHash) to verify if the statement was linked with the block.
* @param height Block height. (required)
* @param hash Receipt hash. (required)
* @return MerkleProofInfoDTO
* @throws ApiException if fails to make API call
* @http.response.details
Status Code Description Response Headers
200 success -
404 ResourceNotFound -
409 InvalidArgument -
*/
public MerkleProofInfoDTO getMerkleReceipts(java.math.BigInteger height, String hash) throws ApiException {
return getMerkleReceiptsWithHttpInfo(height, hash).getData();
}
/**
* Get the merkle path for a given a receipt statement hash and block
* Returns the merkle path for a receipt statement or resolution linked to a block. The merkle path is the minimum number of nodes needed to calculate the merkle root. Steps to calculate the merkle root: 1. proofHash = hash (leaf). 2. Concatenate proofHash with the first unprocessed item from the merklePath list as follows: * a) If item.position == left -> proofHash = sha_256(item.hash + proofHash). * b) If item.position == right -> proofHash = sha_256(proofHash+ item.hash). 3. Repeat 2. for every item in the merklePath list. 4. Compare if the calculated proofHash equals the one recorded in the block header (block.receiptsHash) to verify if the statement was linked with the block.
* @param height Block height. (required)
* @param hash Receipt hash. (required)
* @return ApiResponse<MerkleProofInfoDTO>
* @throws ApiException if fails to make API call
* @http.response.details
Status Code Description Response Headers
200 success -
404 ResourceNotFound -
409 InvalidArgument -
*/
public ApiResponse getMerkleReceiptsWithHttpInfo(java.math.BigInteger height, String hash) throws ApiException {
Object localVarPostBody = new Object();
// verify the required parameter 'height' is set
if (height == null) {
throw new ApiException(400, "Missing the required parameter 'height' when calling getMerkleReceipts");
}
// verify the required parameter 'hash' is set
if (hash == null) {
throw new ApiException(400, "Missing the required parameter 'hash' when calling getMerkleReceipts");
}
// create path and map variables
String localVarPath = "/block/{height}/receipt/{hash}/merkle"
.replaceAll("\\{" + "height" + "\\}", apiClient.escapeString(height.toString()))
.replaceAll("\\{" + "hash" + "\\}", apiClient.escapeString(hash.toString()));
// query params
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { };
GenericType localVarReturnType = new GenericType() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy