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

io.proximax.xpx.service.remote.RemoteDownloadApi 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.Pair;
import io.proximax.ProgressRequestBody;
import io.proximax.ProgressResponseBody;
import io.proximax.ApiCallback;
import io.proximax.ApiClient;
import io.proximax.ApiResponse;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;

import io.proximax.xpx.exceptions.ApiException;
import io.proximax.xpx.service.intf.DownloadApi;

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





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

    /**
     * Instantiates a new remote download api.
     *
     * @param apiClient the api client
     */
    public RemoteDownloadApi(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

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

    /**
     * Build call for downloadBinaryUsingGET.
     *
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferMode Transfer Mode default: bytes (bytes,stream,base64) (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 downloadBinaryUsingGETCall(String nemHash, String transferMode, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/download/binary";

        List localVarQueryParams = new ArrayList();
        if (nemHash != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "nemHash", nemHash));
        if (transferMode != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "transferMode", transferMode));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            "*/*"
        };
        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);
    }
    
    /**
     * Download binary using GET validate before call.
     *
     * @param nemHash the proximax hash
     * @param transferMode the transfer mode
     * @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 downloadBinaryUsingGETValidateBeforeCall(String nemHash, String transferMode, 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 downloadBinaryUsingGET(Async)");
        }
        
        // verify the required parameter 'transferMode' is set
        if (transferMode == null) {
            throw new ApiException("Missing the required parameter 'transferMode' when calling downloadBinaryUsingGET(Async)");
        }
        
        
        com.squareup.okhttp.Call call = downloadBinaryUsingGETCall(nemHash, transferMode, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Download a binary using NEM Transaction Hash
     * Download the binary file associated to a NEM Hash. If NEM Hash uses SECURE Message, it returns the NEM TXN Payload Instead
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferMode Transfer Mode default: bytes (bytes,stream,base64) (required)
     * @return byte[]
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public byte[] downloadBinaryUsingGET(String nemHash, String transferMode) throws ApiException {
        ApiResponse resp = downloadBinaryUsingGETWithHttpInfo(nemHash, transferMode);
        return resp.getData();
    }

    /**
     * Download a binary using NEM Transaction Hash
     * Download the binary file associated to a NEM Hash. If NEM Hash uses SECURE Message, it returns the NEM TXN Payload Instead
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferMode Transfer Mode default: bytes (bytes,stream,base64) (required)
     * @return ApiResponse<byte[]>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse downloadBinaryUsingGETWithHttpInfo(String nemHash, String transferMode) throws ApiException {
        com.squareup.okhttp.Call call = downloadBinaryUsingGETValidateBeforeCall(nemHash, transferMode, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Download a binary using NEM Transaction Hash (asynchronously)
     * Download the binary file associated to a NEM Hash. If NEM Hash uses SECURE Message, it returns the NEM TXN Payload Instead
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferMode Transfer Mode default: bytes (bytes,stream,base64) (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 downloadBinaryUsingGETAsync(String nemHash, String transferMode, 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 = downloadBinaryUsingGETValidateBeforeCall(nemHash, transferMode, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    
    /**
     * Build call for downloadFileUsingGET.
     *
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferMode Transfer Mode default: bytes (bytes,stream,base64) (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 downloadFileUsingGETCall(String nemHash, String transferMode, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/download/file";

        List localVarQueryParams = new ArrayList();
        if (nemHash != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "nemHash", nemHash));
        if (transferMode != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "transferMode", transferMode));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            "*/*"
        };
        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);
    }
    
    /**
     * Download file using GET validate before call.
     *
     * @param nemHash the proximax hash
     * @param transferMode the transfer mode
     * @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 downloadFileUsingGETValidateBeforeCall(String nemHash, String transferMode, 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 downloadFileUsingGET(Async)");
        }
        
        // verify the required parameter 'transferMode' is set
        if (transferMode == null) {
            throw new ApiException("Missing the required parameter 'transferMode' when calling downloadFileUsingGET(Async)");
        }
        
        
        com.squareup.okhttp.Call call = downloadFileUsingGETCall(nemHash, transferMode, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Download a file associated to a NEM Hash.
     * Download the binary file associated to a NEM Hash. If NEM Hash uses SECURE Message, it returns the NEM TXN Payload Instead
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferMode Transfer Mode default: bytes (bytes,stream,base64) (required)
     * @return byte[]
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public byte[] downloadFileUsingGET(String nemHash, String transferMode) throws ApiException {
        ApiResponse resp = downloadFileUsingGETWithHttpInfo(nemHash, transferMode);
        return resp.getData();
    }

    /**
     * Download a file associated to a NEM Hash.
     * Download the binary file associated to a NEM Hash. If NEM Hash uses SECURE Message, it returns the NEM TXN Payload Instead
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferMode Transfer Mode default: bytes (bytes,stream,base64) (required)
     * @return ApiResponse<byte[]>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse downloadFileUsingGETWithHttpInfo(String nemHash, String transferMode) throws ApiException {
        com.squareup.okhttp.Call call = downloadFileUsingGETValidateBeforeCall(nemHash, transferMode, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Download a file associated to a NEM Hash. (asynchronously)
     * Download the binary file associated to a NEM Hash. If NEM Hash uses SECURE Message, it returns the NEM TXN Payload Instead
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferMode Transfer Mode default: bytes (bytes,stream,base64) (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 downloadFileUsingGETAsync(String nemHash, String transferMode, 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 = downloadFileUsingGETValidateBeforeCall(nemHash, transferMode, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    
    /**
     * Build call for downloadSecureBinaryUsingGET.
     *
     * @param xPvkey The Sender or Receiver's Private Key (required)
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferType Transfer Type default: bytes (bytes,stream,base64) (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 downloadSecureBinaryUsingGETCall(String xPvkey, String nemHash, String transferType, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/download/secure/binary";

        List localVarQueryParams = new ArrayList();
        if (nemHash != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "nemHash", nemHash));
        if (transferType != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "transferType", transferType));

        Map localVarHeaderParams = new HashMap();
        if (xPvkey != null)
        localVarHeaderParams.put("x-pvkey", apiClient.parameterToString(xPvkey));

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            "*/*"
        };
        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);
    }
    
    /**
     * Download secure binary using GET validate before call.
     *
     * @param xPvkey the x pvkey
     * @param nemHash the proximax hash
     * @param transferType the transfer type
     * @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 downloadSecureBinaryUsingGETValidateBeforeCall(String xPvkey, String nemHash, String transferType, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'xPvkey' is set
        if (xPvkey == null) {
            throw new ApiException("Missing the required parameter 'xPvkey' when calling downloadSecureBinaryUsingGET(Async)");
        }
        
        // verify the required parameter 'nemHash' is set
        if (nemHash == null) {
            throw new ApiException("Missing the required parameter 'nemHash' when calling downloadSecureBinaryUsingGET(Async)");
        }
        
        // verify the required parameter 'transferType' is set
        if (transferType == null) {
            throw new ApiException("Missing the required parameter 'transferType' when calling downloadSecureBinaryUsingGET(Async)");
        }
        
        
        com.squareup.okhttp.Call call = downloadSecureBinaryUsingGETCall(xPvkey, nemHash, transferType, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Download a secure resource/blob using NEM Private Key and Transaction Hash
     * Download a blob associated to a NEM Hash. If NEM Hash uses SECURE Message, it returns the NEM TXN Payload Instead
     * @param xPvkey The Sender or Receiver's Private Key (required)
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferType Transfer Type default: bytes (bytes,stream,base64) (required)
     * @return byte[]
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public byte[] downloadSecureBinaryUsingGET(String xPvkey, String nemHash, String transferType) throws ApiException {
        ApiResponse resp = downloadSecureBinaryUsingGETWithHttpInfo(xPvkey, nemHash, transferType);
        return resp.getData();
    }

    /**
     * Download a secure resource/blob using NEM Private Key and Transaction Hash
     * Download a blob associated to a NEM Hash. If NEM Hash uses SECURE Message, it returns the NEM TXN Payload Instead
     * @param xPvkey The Sender or Receiver's Private Key (required)
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferType Transfer Type default: bytes (bytes,stream,base64) (required)
     * @return ApiResponse<byte[]>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse downloadSecureBinaryUsingGETWithHttpInfo(String xPvkey, String nemHash, String transferType) throws ApiException {
        com.squareup.okhttp.Call call = downloadSecureBinaryUsingGETValidateBeforeCall(xPvkey, nemHash, transferType, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Download a secure resource/blob using NEM Private Key and Transaction Hash (asynchronously)
     * Download a blob associated to a NEM Hash. If NEM Hash uses SECURE Message, it returns the NEM TXN Payload Instead
     * @param xPvkey The Sender or Receiver's Private Key (required)
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferType Transfer Type default: bytes (bytes,stream,base64) (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 downloadSecureBinaryUsingGETAsync(String xPvkey, String nemHash, String transferType, 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 = downloadSecureBinaryUsingGETValidateBeforeCall(xPvkey, nemHash, transferType, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    
    /**
     * Build call for downloadSecureFileUsingGET.
     *
     * @param xPvkey The Sender or Receiver's Private Key (required)
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferType Transfer Type default: bytes (bytes,stream,base64) (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 downloadSecureFileUsingGETCall(String xPvkey, String nemHash, String transferType, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/download/secure/file";

        List localVarQueryParams = new ArrayList();
        if (nemHash != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "nemHash", nemHash));
        if (transferType != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "transferType", transferType));

        Map localVarHeaderParams = new HashMap();
        if (xPvkey != null)
        localVarHeaderParams.put("x-pvkey", apiClient.parameterToString(xPvkey));

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            "*/*"
        };
        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);
    }
    
    /**
     * Download secure file using GET validate before call.
     *
     * @param xPvkey the x pvkey
     * @param nemHash the proximax hash
     * @param transferType the transfer type
     * @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 downloadSecureFileUsingGETValidateBeforeCall(String xPvkey, String nemHash, String transferType, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'xPvkey' is set
        if (xPvkey == null) {
            throw new ApiException("Missing the required parameter 'xPvkey' when calling downloadSecureFileUsingGET(Async)");
        }
        
        // verify the required parameter 'nemHash' is set
        if (nemHash == null) {
            throw new ApiException("Missing the required parameter 'nemHash' when calling downloadSecureFileUsingGET(Async)");
        }
        
        // verify the required parameter 'transferType' is set
        if (transferType == null) {
            throw new ApiException("Missing the required parameter 'transferType' when calling downloadSecureFileUsingGET(Async)");
        }
        
        
        com.squareup.okhttp.Call call = downloadSecureFileUsingGETCall(xPvkey, nemHash, transferType, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Download a secure resource/file using NEM Private Key and Transaction Hash
     * Download a file associated to a NEM Hash. If NEM Hash uses SECURE Message, it returns the NEM TXN Payload Instead
     * @param xPvkey The Sender or Receiver's Private Key (required)
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferType Transfer Type default: bytes (bytes,stream,base64) (required)
     * @return byte[]
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public byte[] downloadSecureFileUsingGET(String xPvkey, String nemHash, String transferType) throws ApiException {
        ApiResponse resp = downloadSecureFileUsingGETWithHttpInfo(xPvkey, nemHash, transferType);
        return resp.getData();
    }

    /**
     * Download a secure resource/file using NEM Private Key and Transaction Hash
     * Download a file associated to a NEM Hash. If NEM Hash uses SECURE Message, it returns the NEM TXN Payload Instead
     * @param xPvkey The Sender or Receiver's Private Key (required)
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferType Transfer Type default: bytes (bytes,stream,base64) (required)
     * @return ApiResponse<byte[]>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse downloadSecureFileUsingGETWithHttpInfo(String xPvkey, String nemHash, String transferType) throws ApiException {
        com.squareup.okhttp.Call call = downloadSecureFileUsingGETValidateBeforeCall(xPvkey, nemHash, transferType, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Download a secure resource/file using NEM Private Key and Transaction Hash (asynchronously)
     * Download a file associated to a NEM Hash. If NEM Hash uses SECURE Message, it returns the NEM TXN Payload Instead
     * @param xPvkey The Sender or Receiver's Private Key (required)
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferType Transfer Type default: bytes (bytes,stream,base64) (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 downloadSecureFileUsingGETAsync(String xPvkey, String nemHash, String transferType, 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 = downloadSecureFileUsingGETValidateBeforeCall(xPvkey, nemHash, transferType, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    
    /**
     * Build call for downloadTextUsingGET.
     *
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferMode Transfer Mode default: bytes (bytes,stream) (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 downloadTextUsingGETCall(String nemHash, String transferMode, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/download/text";

        List localVarQueryParams = new ArrayList();
        if (nemHash != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "nemHash", nemHash));
        if (transferMode != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "transferMode", transferMode));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            "*/*"
        };
        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);
    }
    
    /**
     * Download text using GET validate before call.
     *
     * @param nemHash the proximax hash
     * @param transferMode the transfer mode
     * @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 downloadTextUsingGETValidateBeforeCall(String nemHash, String transferMode, 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 downloadTextUsingGET(Async)");
        }
        
        // verify the required parameter 'transferMode' is set
        if (transferMode == null) {
            throw new ApiException("Missing the required parameter 'transferMode' when calling downloadTextUsingGET(Async)");
        }
        
        
        com.squareup.okhttp.Call call = downloadTextUsingGETCall(nemHash, transferMode, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Download a base64 encoded plain text data using NEM Transaction Hash
     * Download a plain text data associated to a NEM Hash. If NEM Hash uses SECURE Message, it returns the NEM TXN Payload Instead
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferMode Transfer Mode default: bytes (bytes,stream) (required)
     * @return byte[]
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public byte[] downloadTextUsingGET(String nemHash, String transferMode) throws ApiException {
        ApiResponse resp = downloadTextUsingGETWithHttpInfo(nemHash, transferMode);
        return resp.getData();
    }

    /**
     * Download a base64 encoded plain text data using NEM Transaction Hash
     * Download a plain text data associated to a NEM Hash. If NEM Hash uses SECURE Message, it returns the NEM TXN Payload Instead
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferMode Transfer Mode default: bytes (bytes,stream) (required)
     * @return ApiResponse<byte[]>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse downloadTextUsingGETWithHttpInfo(String nemHash, String transferMode) throws ApiException {
        com.squareup.okhttp.Call call = downloadTextUsingGETValidateBeforeCall(nemHash, transferMode, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Download a base64 encoded plain text data using NEM Transaction Hash (asynchronously)
     * Download a plain text data associated to a NEM Hash. If NEM Hash uses SECURE Message, it returns the NEM TXN Payload Instead
     * @param nemHash The NEM Transaction Hash (required)
     * @param transferMode Transfer Mode default: bytes (bytes,stream) (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 downloadTextUsingGETAsync(String nemHash, String transferMode, 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 = downloadTextUsingGETValidateBeforeCall(nemHash, transferMode, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    
    /**
     * Build call for downloadUsingDataHashUsingGET.
     *
     * @param dataHash The NEM 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 downloadUsingDataHashUsingGETCall(String dataHash, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/download/direct/datahash";

        List localVarQueryParams = new ArrayList();
        if (dataHash != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "dataHash", dataHash));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            "*/*"
        };
        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);
    }
    
    /**
     * Download using data hash using GET validate before call.
     *
     * @param dataHash the data hash
     * @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 downloadUsingDataHashUsingGETValidateBeforeCall(String dataHash, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'dataHash' is set
        if (dataHash == null) {
            throw new ApiException("Missing the required parameter 'dataHash' when calling downloadUsingDataHashUsingGET(Async)");
        }
        
        
        com.squareup.okhttp.Call call = downloadUsingDataHashUsingGETCall(dataHash, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Download IPFS file associated to the datahash
     * Download IPFS file associated to the datahash.
     *
     * @param dataHash The NEM Transaction Hash (required)
     * @return byte[]
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public byte[] downloadUsingDataHashUsingGET(String dataHash) throws ApiException {
        ApiResponse resp = downloadUsingDataHashUsingGETWithHttpInfo(dataHash);
        return resp.getData();
    }

    /**
     * Download IPFS file associated to the datahash
     * Download IPFS file associated to the datahash.
     *
     * @param dataHash The NEM Transaction Hash (required)
     * @return ApiResponse<byte[]>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse downloadUsingDataHashUsingGETWithHttpInfo(String dataHash) throws ApiException {
        com.squareup.okhttp.Call call = downloadUsingDataHashUsingGETValidateBeforeCall(dataHash, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Download IPFS file associated to the datahash (asynchronously)
     * Download IPFS file associated to the datahash.
     *
     * @param dataHash The NEM 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 downloadUsingDataHashUsingGETAsync(String dataHash, 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 = downloadUsingDataHashUsingGETValidateBeforeCall(dataHash, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy