/*
 * Open Payments Cloud Application API
 * Open Payments Cloud API
 *
 * OpenAPI spec version: 1.0.0
 * 
 *
 * 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 com.ixaris.ope.applications.client.api;

import com.ixaris.ope.applications.client.ApiCallback;
import com.ixaris.ope.applications.client.ApiClient;
import com.ixaris.ope.applications.client.ApiException;
import com.ixaris.ope.applications.client.ApiResponse;
import com.ixaris.ope.applications.client.Configuration;
import com.ixaris.ope.applications.client.Pair;
import com.ixaris.ope.applications.client.ProgressRequestBody;
import com.ixaris.ope.applications.client.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import com.ixaris.ope.applications.client.model.CreateTransferConflict;
import com.ixaris.ope.applications.client.model.CreateTransferParams;
import com.ixaris.ope.applications.client.model.DefaultClientInvalidRequest;
import com.ixaris.ope.applications.client.model.DefaultErrorModel;
import com.ixaris.ope.applications.client.model.Transfer;
import com.ixaris.ope.applications.client.model.TransferFilter;
import com.ixaris.ope.applications.client.model.TransferProfile;
import com.ixaris.ope.applications.client.model.TransferProfiles;
import com.ixaris.ope.applications.client.model.TransferProfilesFilter;
import com.ixaris.ope.applications.client.model.Transfers;

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

public class TransfersApi {
    private ApiClient apiClient;

    public TransfersApi() {
        this(Configuration.getDefaultApiClient());
    }

    public TransfersApi(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return apiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    /* Build call for transfersGet */
    private com.squareup.okhttp.Call transfersGetCall(String xProgrammeKey, String authorization, TransferFilter request, String xCallref, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = request;
        
        // create path and map variables
        String localVarPath = "/transfers/get".replaceAll("\\{format\\}","json");

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        if (xCallref != null)
        localVarHeaderParams.put("X-callref", apiClient.parameterToString(xCallref));
        if (xProgrammeKey != null)
        localVarHeaderParams.put("X-programmeKey", apiClient.parameterToString(xProgrammeKey));
        if (authorization != null)
        localVarHeaderParams.put("Authorization", apiClient.parameterToString(authorization));

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        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);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call transfersGetValidateBeforeCall(String xProgrammeKey, String authorization, TransferFilter request, String xCallref, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'xProgrammeKey' is set
        if (xProgrammeKey == null) {
            throw new ApiException("Missing the required parameter 'xProgrammeKey' when calling transfersGet(Async)");
        }
        
        // verify the required parameter 'authorization' is set
        if (authorization == null) {
            throw new ApiException("Missing the required parameter 'authorization' when calling transfersGet(Async)");
        }
        
        // verify the required parameter 'request' is set
        if (request == null) {
            throw new ApiException("Missing the required parameter 'request' when calling transfersGet(Async)");
        }
        
        
        com.squareup.okhttp.Call call = transfersGetCall(xProgrammeKey, authorization, request, xCallref, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * 
     * Retrieve a list of transfer transactions which match the given criteria.
     * @param xProgrammeKey This identifies your tenant and programme within OPE. The typical format is &#x60;tenantId|programmeId&#x60;, for example &#x60;team-01|3749203750&#x60;. (required)
     * @param authorization This is the authorisation token that you receive after logging into the API with your credentials. To login, you need to perform a &#x60;POST&#x60; call on &#x60;/auth/login&#x60; with your credentials. (required)
     * @param request  (required)
     * @param xCallref A unique call reference to provide correlation between application and system. This can be generated by your application. (optional)
     * @return Transfers
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public Transfers transfersGet(String xProgrammeKey, String authorization, TransferFilter request, String xCallref) throws ApiException {
        ApiResponse<Transfers> resp = transfersGetWithHttpInfo(xProgrammeKey, authorization, request, xCallref);
        return resp.getData();
    }

    /**
     * 
     * Retrieve a list of transfer transactions which match the given criteria.
     * @param xProgrammeKey This identifies your tenant and programme within OPE. The typical format is &#x60;tenantId|programmeId&#x60;, for example &#x60;team-01|3749203750&#x60;. (required)
     * @param authorization This is the authorisation token that you receive after logging into the API with your credentials. To login, you need to perform a &#x60;POST&#x60; call on &#x60;/auth/login&#x60; with your credentials. (required)
     * @param request  (required)
     * @param xCallref A unique call reference to provide correlation between application and system. This can be generated by your application. (optional)
     * @return ApiResponse&lt;Transfers&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<Transfers> transfersGetWithHttpInfo(String xProgrammeKey, String authorization, TransferFilter request, String xCallref) throws ApiException {
        com.squareup.okhttp.Call call = transfersGetValidateBeforeCall(xProgrammeKey, authorization, request, xCallref, null, null);
        Type localVarReturnType = new TypeToken<Transfers>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     *  (asynchronously)
     * Retrieve a list of transfer transactions which match the given criteria.
     * @param xProgrammeKey This identifies your tenant and programme within OPE. The typical format is &#x60;tenantId|programmeId&#x60;, for example &#x60;team-01|3749203750&#x60;. (required)
     * @param authorization This is the authorisation token that you receive after logging into the API with your credentials. To login, you need to perform a &#x60;POST&#x60; call on &#x60;/auth/login&#x60; with your credentials. (required)
     * @param request  (required)
     * @param xCallref A unique call reference to provide correlation between application and system. This can be generated by your application. (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 transfersGetAsync(String xProgrammeKey, String authorization, TransferFilter request, String xCallref, final ApiCallback<Transfers> 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 = transfersGetValidateBeforeCall(xProgrammeKey, authorization, request, xCallref, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<Transfers>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /* Build call for transfersIdCreate */
    private com.squareup.okhttp.Call transfersIdCreateCall(String xProgrammeKey, String authorization, CreateTransferParams request, String xCallref, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = request;
        
        // create path and map variables
        String localVarPath = "/transfers/_/create".replaceAll("\\{format\\}","json");

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        if (xCallref != null)
        localVarHeaderParams.put("X-callref", apiClient.parameterToString(xCallref));
        if (xProgrammeKey != null)
        localVarHeaderParams.put("X-programmeKey", apiClient.parameterToString(xProgrammeKey));
        if (authorization != null)
        localVarHeaderParams.put("Authorization", apiClient.parameterToString(authorization));

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        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);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call transfersIdCreateValidateBeforeCall(String xProgrammeKey, String authorization, CreateTransferParams request, String xCallref, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'xProgrammeKey' is set
        if (xProgrammeKey == null) {
            throw new ApiException("Missing the required parameter 'xProgrammeKey' when calling transfersIdCreate(Async)");
        }
        
        // verify the required parameter 'authorization' is set
        if (authorization == null) {
            throw new ApiException("Missing the required parameter 'authorization' when calling transfersIdCreate(Async)");
        }
        
        // verify the required parameter 'request' is set
        if (request == null) {
            throw new ApiException("Missing the required parameter 'request' when calling transfersIdCreate(Async)");
        }
        
        
        com.squareup.okhttp.Call call = transfersIdCreateCall(xProgrammeKey, authorization, request, xCallref, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * 
     * Create a transfer transaction with the given ID and details.
     * @param xProgrammeKey This identifies your tenant and programme within OPE. The typical format is &#x60;tenantId|programmeId&#x60;, for example &#x60;team-01|3749203750&#x60;. (required)
     * @param authorization This is the authorisation token that you receive after logging into the API with your credentials. To login, you need to perform a &#x60;POST&#x60; call on &#x60;/auth/login&#x60; with your credentials. (required)
     * @param request  (required)
     * @param xCallref A unique call reference to provide correlation between application and system. This can be generated by your application. (optional)
     * @return Transfer
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public Transfer transfersIdCreate(String xProgrammeKey, String authorization, CreateTransferParams request, String xCallref) throws ApiException {
        ApiResponse<Transfer> resp = transfersIdCreateWithHttpInfo(xProgrammeKey, authorization, request, xCallref);
        return resp.getData();
    }

    /**
     * 
     * Create a transfer transaction with the given ID and details.
     * @param xProgrammeKey This identifies your tenant and programme within OPE. The typical format is &#x60;tenantId|programmeId&#x60;, for example &#x60;team-01|3749203750&#x60;. (required)
     * @param authorization This is the authorisation token that you receive after logging into the API with your credentials. To login, you need to perform a &#x60;POST&#x60; call on &#x60;/auth/login&#x60; with your credentials. (required)
     * @param request  (required)
     * @param xCallref A unique call reference to provide correlation between application and system. This can be generated by your application. (optional)
     * @return ApiResponse&lt;Transfer&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<Transfer> transfersIdCreateWithHttpInfo(String xProgrammeKey, String authorization, CreateTransferParams request, String xCallref) throws ApiException {
        com.squareup.okhttp.Call call = transfersIdCreateValidateBeforeCall(xProgrammeKey, authorization, request, xCallref, null, null);
        Type localVarReturnType = new TypeToken<Transfer>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     *  (asynchronously)
     * Create a transfer transaction with the given ID and details.
     * @param xProgrammeKey This identifies your tenant and programme within OPE. The typical format is &#x60;tenantId|programmeId&#x60;, for example &#x60;team-01|3749203750&#x60;. (required)
     * @param authorization This is the authorisation token that you receive after logging into the API with your credentials. To login, you need to perform a &#x60;POST&#x60; call on &#x60;/auth/login&#x60; with your credentials. (required)
     * @param request  (required)
     * @param xCallref A unique call reference to provide correlation between application and system. This can be generated by your application. (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 transfersIdCreateAsync(String xProgrammeKey, String authorization, CreateTransferParams request, String xCallref, final ApiCallback<Transfer> 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 = transfersIdCreateValidateBeforeCall(xProgrammeKey, authorization, request, xCallref, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<Transfer>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /* Build call for transfersIdGet */
    private com.squareup.okhttp.Call transfersIdGetCall(Long id, String xProgrammeKey, String authorization, String xCallref, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/transfers/{id}/get".replaceAll("\\{format\\}","json")
        .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        if (xCallref != null)
        localVarHeaderParams.put("X-callref", apiClient.parameterToString(xCallref));
        if (xProgrammeKey != null)
        localVarHeaderParams.put("X-programmeKey", apiClient.parameterToString(xProgrammeKey));
        if (authorization != null)
        localVarHeaderParams.put("Authorization", apiClient.parameterToString(authorization));

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        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);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call transfersIdGetValidateBeforeCall(Long id, String xProgrammeKey, String authorization, String xCallref, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling transfersIdGet(Async)");
        }
        
        // verify the required parameter 'xProgrammeKey' is set
        if (xProgrammeKey == null) {
            throw new ApiException("Missing the required parameter 'xProgrammeKey' when calling transfersIdGet(Async)");
        }
        
        // verify the required parameter 'authorization' is set
        if (authorization == null) {
            throw new ApiException("Missing the required parameter 'authorization' when calling transfersIdGet(Async)");
        }
        
        
        com.squareup.okhttp.Call call = transfersIdGetCall(id, xProgrammeKey, authorization, xCallref, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * 
     * Retrieve the transfer transaction identified by the given ID.
     * @param id The transfer transaction identified by the given ID. (required)
     * @param xProgrammeKey This identifies your tenant and programme within OPE. The typical format is &#x60;tenantId|programmeId&#x60;, for example &#x60;team-01|3749203750&#x60;. (required)
     * @param authorization This is the authorisation token that you receive after logging into the API with your credentials. To login, you need to perform a &#x60;POST&#x60; call on &#x60;/auth/login&#x60; with your credentials. (required)
     * @param xCallref A unique call reference to provide correlation between application and system. This can be generated by your application. (optional)
     * @return Transfer
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public Transfer transfersIdGet(Long id, String xProgrammeKey, String authorization, String xCallref) throws ApiException {
        ApiResponse<Transfer> resp = transfersIdGetWithHttpInfo(id, xProgrammeKey, authorization, xCallref);
        return resp.getData();
    }

    /**
     * 
     * Retrieve the transfer transaction identified by the given ID.
     * @param id The transfer transaction identified by the given ID. (required)
     * @param xProgrammeKey This identifies your tenant and programme within OPE. The typical format is &#x60;tenantId|programmeId&#x60;, for example &#x60;team-01|3749203750&#x60;. (required)
     * @param authorization This is the authorisation token that you receive after logging into the API with your credentials. To login, you need to perform a &#x60;POST&#x60; call on &#x60;/auth/login&#x60; with your credentials. (required)
     * @param xCallref A unique call reference to provide correlation between application and system. This can be generated by your application. (optional)
     * @return ApiResponse&lt;Transfer&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<Transfer> transfersIdGetWithHttpInfo(Long id, String xProgrammeKey, String authorization, String xCallref) throws ApiException {
        com.squareup.okhttp.Call call = transfersIdGetValidateBeforeCall(id, xProgrammeKey, authorization, xCallref, null, null);
        Type localVarReturnType = new TypeToken<Transfer>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     *  (asynchronously)
     * Retrieve the transfer transaction identified by the given ID.
     * @param id The transfer transaction identified by the given ID. (required)
     * @param xProgrammeKey This identifies your tenant and programme within OPE. The typical format is &#x60;tenantId|programmeId&#x60;, for example &#x60;team-01|3749203750&#x60;. (required)
     * @param authorization This is the authorisation token that you receive after logging into the API with your credentials. To login, you need to perform a &#x60;POST&#x60; call on &#x60;/auth/login&#x60; with your credentials. (required)
     * @param xCallref A unique call reference to provide correlation between application and system. This can be generated by your application. (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 transfersIdGetAsync(Long id, String xProgrammeKey, String authorization, String xCallref, final ApiCallback<Transfer> 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 = transfersIdGetValidateBeforeCall(id, xProgrammeKey, authorization, xCallref, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<Transfer>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /* Build call for transfersProfilesGet */
    private com.squareup.okhttp.Call transfersProfilesGetCall(String xProgrammeKey, String authorization, TransferProfilesFilter request, String xCallref, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = request;
        
        // create path and map variables
        String localVarPath = "/transfers/profiles/get".replaceAll("\\{format\\}","json");

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        if (xCallref != null)
        localVarHeaderParams.put("X-callref", apiClient.parameterToString(xCallref));
        if (xProgrammeKey != null)
        localVarHeaderParams.put("X-programmeKey", apiClient.parameterToString(xProgrammeKey));
        if (authorization != null)
        localVarHeaderParams.put("Authorization", apiClient.parameterToString(authorization));

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        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);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call transfersProfilesGetValidateBeforeCall(String xProgrammeKey, String authorization, TransferProfilesFilter request, String xCallref, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'xProgrammeKey' is set
        if (xProgrammeKey == null) {
            throw new ApiException("Missing the required parameter 'xProgrammeKey' when calling transfersProfilesGet(Async)");
        }
        
        // verify the required parameter 'authorization' is set
        if (authorization == null) {
            throw new ApiException("Missing the required parameter 'authorization' when calling transfersProfilesGet(Async)");
        }
        
        // verify the required parameter 'request' is set
        if (request == null) {
            throw new ApiException("Missing the required parameter 'request' when calling transfersProfilesGet(Async)");
        }
        
        
        com.squareup.okhttp.Call call = transfersProfilesGetCall(xProgrammeKey, authorization, request, xCallref, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * 
     * Retrieves the transfer profiles which match all of the criteria specified in the given filter.
     * @param xProgrammeKey This identifies your tenant and programme within OPE. The typical format is &#x60;tenantId|programmeId&#x60;, for example &#x60;team-01|3749203750&#x60;. (required)
     * @param authorization This is the authorisation token that you receive after logging into the API with your credentials. To login, you need to perform a &#x60;POST&#x60; call on &#x60;/auth/login&#x60; with your credentials. (required)
     * @param request  (required)
     * @param xCallref A unique call reference to provide correlation between application and system. This can be generated by your application. (optional)
     * @return TransferProfiles
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TransferProfiles transfersProfilesGet(String xProgrammeKey, String authorization, TransferProfilesFilter request, String xCallref) throws ApiException {
        ApiResponse<TransferProfiles> resp = transfersProfilesGetWithHttpInfo(xProgrammeKey, authorization, request, xCallref);
        return resp.getData();
    }

    /**
     * 
     * Retrieves the transfer profiles which match all of the criteria specified in the given filter.
     * @param xProgrammeKey This identifies your tenant and programme within OPE. The typical format is &#x60;tenantId|programmeId&#x60;, for example &#x60;team-01|3749203750&#x60;. (required)
     * @param authorization This is the authorisation token that you receive after logging into the API with your credentials. To login, you need to perform a &#x60;POST&#x60; call on &#x60;/auth/login&#x60; with your credentials. (required)
     * @param request  (required)
     * @param xCallref A unique call reference to provide correlation between application and system. This can be generated by your application. (optional)
     * @return ApiResponse&lt;TransferProfiles&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TransferProfiles> transfersProfilesGetWithHttpInfo(String xProgrammeKey, String authorization, TransferProfilesFilter request, String xCallref) throws ApiException {
        com.squareup.okhttp.Call call = transfersProfilesGetValidateBeforeCall(xProgrammeKey, authorization, request, xCallref, null, null);
        Type localVarReturnType = new TypeToken<TransferProfiles>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     *  (asynchronously)
     * Retrieves the transfer profiles which match all of the criteria specified in the given filter.
     * @param xProgrammeKey This identifies your tenant and programme within OPE. The typical format is &#x60;tenantId|programmeId&#x60;, for example &#x60;team-01|3749203750&#x60;. (required)
     * @param authorization This is the authorisation token that you receive after logging into the API with your credentials. To login, you need to perform a &#x60;POST&#x60; call on &#x60;/auth/login&#x60; with your credentials. (required)
     * @param request  (required)
     * @param xCallref A unique call reference to provide correlation between application and system. This can be generated by your application. (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 transfersProfilesGetAsync(String xProgrammeKey, String authorization, TransferProfilesFilter request, String xCallref, final ApiCallback<TransferProfiles> 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 = transfersProfilesGetValidateBeforeCall(xProgrammeKey, authorization, request, xCallref, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<TransferProfiles>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /* Build call for transfersProfilesIdGet */
    private com.squareup.okhttp.Call transfersProfilesIdGetCall(Long id, String xProgrammeKey, String authorization, String xCallref, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/transfers/profiles/{id}/get".replaceAll("\\{format\\}","json")
        .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        if (xCallref != null)
        localVarHeaderParams.put("X-callref", apiClient.parameterToString(xCallref));
        if (xProgrammeKey != null)
        localVarHeaderParams.put("X-programmeKey", apiClient.parameterToString(xProgrammeKey));
        if (authorization != null)
        localVarHeaderParams.put("Authorization", apiClient.parameterToString(authorization));

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        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);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call transfersProfilesIdGetValidateBeforeCall(Long id, String xProgrammeKey, String authorization, String xCallref, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling transfersProfilesIdGet(Async)");
        }
        
        // verify the required parameter 'xProgrammeKey' is set
        if (xProgrammeKey == null) {
            throw new ApiException("Missing the required parameter 'xProgrammeKey' when calling transfersProfilesIdGet(Async)");
        }
        
        // verify the required parameter 'authorization' is set
        if (authorization == null) {
            throw new ApiException("Missing the required parameter 'authorization' when calling transfersProfilesIdGet(Async)");
        }
        
        
        com.squareup.okhttp.Call call = transfersProfilesIdGetCall(id, xProgrammeKey, authorization, xCallref, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * 
     * Retrieves the latest version of the profile identified by the ID parameter.
     * @param id This sub resource represents a specific profile, as identified by the ID parameter, and allows this specific profile to be managed. (required)
     * @param xProgrammeKey This identifies your tenant and programme within OPE. The typical format is &#x60;tenantId|programmeId&#x60;, for example &#x60;team-01|3749203750&#x60;. (required)
     * @param authorization This is the authorisation token that you receive after logging into the API with your credentials. To login, you need to perform a &#x60;POST&#x60; call on &#x60;/auth/login&#x60; with your credentials. (required)
     * @param xCallref A unique call reference to provide correlation between application and system. This can be generated by your application. (optional)
     * @return TransferProfile
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TransferProfile transfersProfilesIdGet(Long id, String xProgrammeKey, String authorization, String xCallref) throws ApiException {
        ApiResponse<TransferProfile> resp = transfersProfilesIdGetWithHttpInfo(id, xProgrammeKey, authorization, xCallref);
        return resp.getData();
    }

    /**
     * 
     * Retrieves the latest version of the profile identified by the ID parameter.
     * @param id This sub resource represents a specific profile, as identified by the ID parameter, and allows this specific profile to be managed. (required)
     * @param xProgrammeKey This identifies your tenant and programme within OPE. The typical format is &#x60;tenantId|programmeId&#x60;, for example &#x60;team-01|3749203750&#x60;. (required)
     * @param authorization This is the authorisation token that you receive after logging into the API with your credentials. To login, you need to perform a &#x60;POST&#x60; call on &#x60;/auth/login&#x60; with your credentials. (required)
     * @param xCallref A unique call reference to provide correlation between application and system. This can be generated by your application. (optional)
     * @return ApiResponse&lt;TransferProfile&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TransferProfile> transfersProfilesIdGetWithHttpInfo(Long id, String xProgrammeKey, String authorization, String xCallref) throws ApiException {
        com.squareup.okhttp.Call call = transfersProfilesIdGetValidateBeforeCall(id, xProgrammeKey, authorization, xCallref, null, null);
        Type localVarReturnType = new TypeToken<TransferProfile>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     *  (asynchronously)
     * Retrieves the latest version of the profile identified by the ID parameter.
     * @param id This sub resource represents a specific profile, as identified by the ID parameter, and allows this specific profile to be managed. (required)
     * @param xProgrammeKey This identifies your tenant and programme within OPE. The typical format is &#x60;tenantId|programmeId&#x60;, for example &#x60;team-01|3749203750&#x60;. (required)
     * @param authorization This is the authorisation token that you receive after logging into the API with your credentials. To login, you need to perform a &#x60;POST&#x60; call on &#x60;/auth/login&#x60; with your credentials. (required)
     * @param xCallref A unique call reference to provide correlation between application and system. This can be generated by your application. (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 transfersProfilesIdGetAsync(Long id, String xProgrammeKey, String authorization, String xCallref, final ApiCallback<TransferProfile> 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 = transfersProfilesIdGetValidateBeforeCall(id, xProgrammeKey, authorization, xCallref, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<TransferProfile>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}
