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

io.proximax.xpx.service.remote.RemoteTransactionAndAnnounceApi Maven / Gradle / Ivy

There is a newer version: 0.1.0-beta.10
Show newest version
/*
 * Copyright 2018 ProximaX Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Proximax P2P Storage REST API
 * Proximax P2P Storage REST API
 *
 * OpenAPI spec version: v0.0.1
 * Contact: [email protected]
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */


package io.proximax.xpx.service.remote;

import io.proximax.ApiCallback;
import io.proximax.ApiClient;
import io.proximax.ApiResponse;
import io.proximax.Pair;
import io.proximax.ProgressRequestBody;
import io.proximax.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;

import io.proximax.xpx.exceptions.ApiException;
import io.proximax.xpx.model.RequestAnnounceDataSignature;
import io.proximax.xpx.service.intf.TransactionAndAnnounceApi;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;




/**
 * The Class RemoteTransactionAndAnnounceApi.
 */
public class RemoteTransactionAndAnnounceApi implements TransactionAndAnnounceApi {
    
    /** The api client. */
    private final ApiClient apiClient;

    /**
     * Instantiates a new remote transaction and announce api.
     *
     * @param apiClient the api client
     */
    public RemoteTransactionAndAnnounceApi(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    /**
     * Gets the api client.
     *
     * @return the api client
     */
    public ApiClient getApiClient() {
        return apiClient;
    }

    /**
     * Build call for announceRequestPublishDataSignatureUsingPOST.
     *
     * @param requestAnnounceDataSignature The Request Announce Data Signature Json Format (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call announceRequestPublishDataSignatureUsingPOSTCall(RequestAnnounceDataSignature requestAnnounceDataSignature, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = requestAnnounceDataSignature;
        
        // create path and map variables
        String localVarPath = "/transaction/announce";

        List localVarQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {
            "application/json"
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if(progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
                @Override
                public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
                    com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                    .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                    .build();
                }
            });
        }

        String[] localVarAuthNames = new String[] {  };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    /**
     * Announce request publish data signature using POST validate before call.
     *
     * @param requestAnnounceDataSignature the request announce data signature
     * @param progressListener the progress listener
     * @param progressRequestListener the progress request listener
     * @return the com.squareup.okhttp. call
     * @throws ApiException the api exception
     */
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call announceRequestPublishDataSignatureUsingPOSTValidateBeforeCall(RequestAnnounceDataSignature requestAnnounceDataSignature, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        
        com.squareup.okhttp.Call call = announceRequestPublishDataSignatureUsingPOSTCall(requestAnnounceDataSignature, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Announce the DataHash to NEM/P2P Storage and P2P Database
     * Endpoint that can be use to announce the data hash transaction. This will grab the signed BinaryTransaferTransaction and create the P2P Database Entry for the specific data hash / transaction.
     * @param requestAnnounceDataSignature The Request Announce Data Signature Json Format (optional)
     * @return String
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public String announceRequestPublishDataSignatureUsingPOST(RequestAnnounceDataSignature requestAnnounceDataSignature) throws ApiException {
        ApiResponse resp = announceRequestPublishDataSignatureUsingPOSTWithHttpInfo(requestAnnounceDataSignature);
        return resp.getData();
    }

    /**
     * Announce the DataHash to NEM/P2P Storage and P2P Database
     * Endpoint that can be use to announce the data hash transaction. This will grab the signed BinaryTransaferTransaction and create the P2P Database Entry for the specific data hash / transaction.
     * @param requestAnnounceDataSignature The Request Announce Data Signature Json Format (optional)
     * @return ApiResponse<String>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse announceRequestPublishDataSignatureUsingPOSTWithHttpInfo(RequestAnnounceDataSignature requestAnnounceDataSignature) throws ApiException {
        com.squareup.okhttp.Call call = announceRequestPublishDataSignatureUsingPOSTValidateBeforeCall(requestAnnounceDataSignature, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Announce the DataHash to NEM/P2P Storage and P2P Database (asynchronously)
     * Endpoint that can be use to announce the data hash transaction. This will grab the signed BinaryTransaferTransaction and create the P2P Database Entry for the specific data hash / transaction.
     * @param requestAnnounceDataSignature The Request Announce Data Signature Json Format (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call announceRequestPublishDataSignatureUsingPOSTAsync(RequestAnnounceDataSignature requestAnnounceDataSignature, final ApiCallback callback) throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = announceRequestPublishDataSignatureUsingPOSTValidateBeforeCall(requestAnnounceDataSignature, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    
    /**
     * Build call for getXPXTransactionUsingGET.
     *
     * @param nemHash XPX Transaction Hash (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getXPXTransactionUsingGETCall(String nemHash, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/transaction/get/{nemHash}"
            .replaceAll("\\{" + "nemHash" + "\\}", apiClient.escapeString(nemHash.toString()));

        List localVarQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {
            "application/json"
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if(progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
                @Override
                public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
                    com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                    .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                    .build();
                }
            });
        }

        String[] localVarAuthNames = new String[] {  };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    /**
     * Gets the XPX transaction using GET validate before call.
     *
     * @param nemHash the proximax hash
     * @param progressListener the progress listener
     * @param progressRequestListener the progress request listener
     * @return the XPX transaction using GET validate before call
     * @throws ApiException the api exception
     */
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getXPXTransactionUsingGETValidateBeforeCall(String nemHash, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'nemHash' is set
        if (nemHash == null) {
            throw new ApiException("Missing the required parameter 'nemHash' when calling getXPXTransactionUsingGET(Async)");
        }
        
        
        com.squareup.okhttp.Call call = getXPXTransactionUsingGETCall(nemHash, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Get the XPX Transaction Hash
     * Endpoint can be used to get XPX Transaction.
     * @param nemHash XPX Transaction Hash (required)
     * @return String
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public String getXPXTransactionUsingGET(String nemHash) throws ApiException {
        ApiResponse resp = getXPXTransactionUsingGETWithHttpInfo(nemHash);
        return resp.getData();
    }

    /**
     * Get the XPX Transaction Hash
     * Endpoint can be used to get XPX Transaction.
     * @param nemHash XPX Transaction Hash (required)
     * @return ApiResponse<String>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getXPXTransactionUsingGETWithHttpInfo(String nemHash) throws ApiException {
        com.squareup.okhttp.Call call = getXPXTransactionUsingGETValidateBeforeCall(nemHash, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get the XPX Transaction Hash (asynchronously)
     * Endpoint can be used to get XPX Transaction.
     * @param nemHash XPX Transaction Hash (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call getXPXTransactionUsingGETAsync(String nemHash, final ApiCallback callback) throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = getXPXTransactionUsingGETValidateBeforeCall(nemHash, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy