(function(root, factory) {
  if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define(['ApiClient', 'models/CreatePaymentSetupRequest', 'models/DeletePaymentSetupRequest', 'models/DeleteResponse', 'models/ErrorResponseVo', 'models/PaymentSetupResponse', 'models/PaymentSetupsResponse', 'models/UpdatePaymentSetupRequest'], factory);
  } else if (typeof module === 'object' && module.exports) {
    // CommonJS-like environments that support module.exports, like Node.
    module.exports = factory(require('../ApiClient'), require('../models/CreatePaymentSetupRequest'), require('../models/DeletePaymentSetupRequest'), require('../models/DeleteResponse'), require('../models/ErrorResponseVo'), require('../models/PaymentSetupResponse'), require('../models/PaymentSetupsResponse'), require('../models/UpdatePaymentSetupRequest'));
  } else {
    // Browser globals (root is window)
    if (!root.OrbipayPaymentsapiClient) {
      root.OrbipayPaymentsapiClient = {};
    }
    root.OrbipayPaymentsapiClient.PaymentSetupApi = factory(root.OrbipayPaymentsapiClient.ApiClient, root.OrbipayPaymentsapiClient.CreatePaymentSetupRequest, root.OrbipayPaymentsapiClient.DeletePaymentSetupRequest, root.OrbipayPaymentsapiClient.DeleteResponse, root.OrbipayPaymentsapiClient.ErrorResponseVo, root.OrbipayPaymentsapiClient.PaymentSetupResponse, root.OrbipayPaymentsapiClient.PaymentSetupsResponse, root.OrbipayPaymentsapiClient.UpdatePaymentSetupRequest);
  }
}(this, function(ApiClient, CreatePaymentSetupRequest, DeletePaymentSetupRequest, DeleteResponse, ErrorResponseVo, PaymentSetupResponse, PaymentSetupsResponse, UpdatePaymentSetupRequest) {
  'use strict';

  /**
   * PaymentSetup service.
   * @module api/PaymentSetupApi
   */

  /**
   * <h3 style="color:red"> This class subject to change without prior notice, Please dont use this class directly. </h3>

   * Constructs a new PaymentSetupApi. 
   * @alias module:api/PaymentSetupApi
   * @class
   * @param {module:ApiClient} [apiClient] Optional API client implementation to use,
   * default to {@link module:ApiClient#instance} if unspecified.
   */
  var exports = function(apiClient) {
    this.apiClient = apiClient || ApiClient.instance;


    /**
     * Callback function to receive the result of the createRecurringPaymentSetup operation.
     * @callback module:api/PaymentSetupApi~createRecurringPaymentSetupCallback
     * @param {String} error Error message, if any.
     * @param {module:models/PaymentSetupResponse} data The data returned by the service call.
     * @param {String} response The complete HTTP response.
     */

    /**
     * Create Payment Setup
     * The API is used to set up recurring payments to service a customer account.
     * @param {String} channel The channel through which the API is invoked.
     * @param {String} client_key The unique identifier assigned by EBPP to the client.
     * @param {module:models/String} product The product identifier corresponding to the API.
     * @param {String} timestamp The timestamp for the moment when the API request is created.
     * @param {String} idempotent_request_key The unique token that clients can generate and maintain in order to identify an API request.
     * @param {module:models/String} requestor_type Type of the requestor of the API.
     * @param {String} id_customer The unique identifier assigned by EBPP to the customer.
     * @param {module:models/CreatePaymentSetupRequest} create_payment_setup_request JSON containing all the fields required to create a recurring payment setup.
     * @param {Object} opts Optional parameters
     * @param {String} opts.requestor The identifier for the requestor of the API. If the requestor_type is &lt;b&gt;system&lt;/b&gt;, requestor is optional.
     * @param {String} opts.x_opay_headers Intended for the future use.
     * @param {String} opts.trace_id The unique reference that can be used for tracing and debugging an API call.
     * @param {module:api/PaymentSetupApi~createRecurringPaymentSetupCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link module:models/PaymentSetupResponse}
     */
    this.createRecurringPaymentSetup = function(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, id_customer, create_payment_setup_request, opts, callback) {
      opts = opts || {};
      var postBody = create_payment_setup_request;

      var pathParams = {
        'ID_CUSTOMER': id_customer
      };
      var queryParams = {
      };
      var headerParams = {
        'channel': channel,
        'client_key': client_key,
        'product': product,
        'timestamp': timestamp,
        'idempotent_request_key': idempotent_request_key,
        'requestor_type': requestor_type,
        'requestor': opts['requestor'],
        'X-OPAY-Headers': opts['x_opay_headers'],
        'trace_id': opts['trace_id']
      };
      var formParams = {
      };

      var authNames = [];
      var contentTypes = ['application/json'];
      var accepts = ['application/json'];
      var returnType = PaymentSetupResponse;

      return this.apiClient.callApi(
        '/customers/{ID_CUSTOMER}/paymentsetups', 'POST',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, callback
      );
    };

    /**
     * Callback function to receive the result of the deletePaymentSetup operation.
     * @callback module:api/PaymentSetupApi~deletePaymentSetupCallback
     * @param {String} error Error message, if any.
     * @param {module:models/DeleteResponse} data The data returned by the service call.
     * @param {String} response The complete HTTP response.
     */

    /**
     * Delete Payment Setup
     * The API is used to delete or cancel a recurring payment setup. Cancelling a payment setup will also cancel all the pending and future payments under the setup.
     * @param {String} channel The channel through which the API is invoked.
     * @param {String} client_key The unique identifier assigned by EBPP to the client.
     * @param {module:models/String} product The product identifier corresponding to the API.
     * @param {String} timestamp The timestamp for the moment when the API request is created.
     * @param {String} idempotent_request_key The unique token that clients can generate and maintain in order to identify an API request.
     * @param {module:models/String} requestor_type Type of the requestor of the API.
     * @param {String} id_payment_setup The unique identifier assigned by EBPP to the payment setup.
     * @param {String} id_customer The unique identifier assigned by EBPP to the customer.
     * @param {module:models/DeletePaymentSetupRequest} delete_payment_setup_request JSON containing all the fields required to delete a payment. Setup.
     * @param {Object} opts Optional parameters
     * @param {String} opts.requestor The identifier for the requestor of the API. If the requestor_type is &lt;b&gt;system&lt;/b&gt;, requestor is optional.
     * @param {String} opts.x_opay_headers Intended for the future use.
     * @param {String} opts.trace_id The unique reference that can be used for tracing and debugging an API call.
     * @param {module:api/PaymentSetupApi~deletePaymentSetupCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link module:models/DeleteResponse}
     */
    this.deletePaymentSetup = function(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, id_payment_setup, id_customer, delete_payment_setup_request, opts, callback) {
      opts = opts || {};
      var postBody = delete_payment_setup_request;

      var pathParams = {
        'ID_PAYMENT_SETUP': id_payment_setup,
        'ID_CUSTOMER': id_customer
      };
      var queryParams = {
      };
      var headerParams = {
        'channel': channel,
        'client_key': client_key,
        'product': product,
        'timestamp': timestamp,
        'idempotent_request_key': idempotent_request_key,
        'requestor_type': requestor_type,
        'requestor': opts['requestor'],
        'X-OPAY-Headers': opts['x_opay_headers'],
        'trace_id': opts['trace_id']
      };
      var formParams = {
      };

      var authNames = [];
      var contentTypes = ['application/json'];
      var accepts = ['application/json'];
      var returnType = DeleteResponse;

      return this.apiClient.callApi(
        '/customers/{ID_CUSTOMER}/paymentsetups/{ID_PAYMENT_SETUP}', 'DELETE',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, callback
      );
    };

    /**
     * Callback function to receive the result of the getPaymentSetup operation.
     * @callback module:api/PaymentSetupApi~getPaymentSetupCallback
     * @param {String} error Error message, if any.
     * @param {module:models/PaymentSetupResponse} data The data returned by the service call.
     * @param {String} response The complete HTTP response.
     */

    /**
     * Get Payment Setup
     * The API is used to retrieve the details of a recurring payment setup by id.
     * @param {String} channel The channel through which the API is invoked.
     * @param {String} client_key The unique identifier assigned by EBPP to the client.
     * @param {module:models/String} product The product identifier corresponding to the API.
     * @param {String} timestamp The timestamp for the moment when the API request is created.
     * @param {String} idempotent_request_key The unique token that clients can generate and maintain in order to identify an API request.
     * @param {module:models/String} requestor_type Type of the requestor of the API.
     * @param {String} id_payment_setup The unique identifier assigned by EBPP to the payment setup.
     * @param {String} id_customer The unique identifier assigned by EBPP to the customer.
     * @param {Object} opts Optional parameters
     * @param {String} opts.requestor The identifier for the requestor of the API. If the requestor_type is &lt;b&gt;system&lt;/b&gt;, requestor is optional.
     * @param {String} opts.x_opay_headers Intended for the future use.
     * @param {String} opts.trace_id The unique reference that can be used for tracing and debugging an API call.
     * @param {module:api/PaymentSetupApi~getPaymentSetupCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link module:models/PaymentSetupResponse}
     */
    this.getPaymentSetup = function(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, id_payment_setup, id_customer, opts, callback) {
      opts = opts || {};
      var postBody = null;

      var pathParams = {
        'ID_PAYMENT_SETUP': id_payment_setup,
        'ID_CUSTOMER': id_customer
      };
      var queryParams = {
      };
      var headerParams = {
        'channel': channel,
        'client_key': client_key,
        'product': product,
        'timestamp': timestamp,
        'idempotent_request_key': idempotent_request_key,
        'requestor_type': requestor_type,
        'requestor': opts['requestor'],
        'X-OPAY-Headers': opts['x_opay_headers'],
        'trace_id': opts['trace_id']
      };
      var formParams = {
      };

      var authNames = [];
      var contentTypes = [];
      var accepts = ['application/json'];
      var returnType = PaymentSetupResponse;

      return this.apiClient.callApi(
        '/customers/{ID_CUSTOMER}/paymentsetups/{ID_PAYMENT_SETUP}', 'GET',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, callback
      );
    };

    /**
     * Callback function to receive the result of the retrievePaymentSetups operation.
     * @callback module:api/PaymentSetupApi~retrievePaymentSetupsCallback
     * @param {String} error Error message, if any.
     * @param {module:models/PaymentSetupsResponse} data The data returned by the service call.
     * @param {String} response The complete HTTP response.
     */

    /**
     * Retrieve Payment Setups
     * The API is used to retrieve the recurring and autopay payments setup made against a customer account. The setup can be filtered using the confirmation number, customer account, funding account, status and payment setup schedule type, by date range and others mentioned below. If no dates are provided for retrieval, recurring payments set up in the last six months and all the ones in future are returned. If the requestor type is customer then the id_customer request parameter is mandatory. The results are sorted in descending order of the payment_start_date followed by the last_modified_time.
     * @param {String} channel The channel through which the API is invoked.
     * @param {String} client_key The unique identifier assigned by EBPP to the client.
     * @param {module:models/String} product The product identifier corresponding to the API.
     * @param {String} timestamp The timestamp for the moment when the API request is created.
     * @param {String} idempotent_request_key The unique token that clients can generate and maintain in order to identify an API request.
     * @param {module:models/String} requestor_type Type of the requestor of the API.
     * @param {Object} opts Optional parameters
     * @param {String} opts.requestor The identifier for the requestor of the API. If the requestor_type is &lt;b&gt;system&lt;/b&gt;, requestor is optional.
     * @param {String} opts.x_opay_headers Intended for the future use.
     * @param {String} opts.trace_id The unique reference that can be used for tracing and debugging an API call.
     * @param {String} opts.id_customer The unique identifier assigned by EBPP to the customer.
     * @param {String} opts.id_funding_account The unique identifier assigned by EBPP to the funding account
     * @param {String} opts.id_customer_account The unique identifier assigned by EBPP to the customer account
     * @param {String} opts.confirmation_number The confirmation number or reference provided to the customer for the successful payment.
     * @param {Array.<module:models/String>} opts.status The status of the payment. This can take multiple values in the format key&#x3D;value1&amp;key&#x3D;value2....
     * @param {Array.<module:models/String>} opts.payment_setup_schedule_type The schedule type for the payment setup. This can take multiple values in the format key&#x3D;value1&amp;key&#x3D;value2....
     * @param {String} opts.from_date The date from which recurring payments setup, matching the criteria specified, need to be retrieved.
     * @param {String} opts.to_date The date upto which recurring payments setup, matching the criteria specified, need to be retrieved.
     * @param {String} opts.page_size The maximum number of objects returned in the query.
     * @param {String} opts.query_id query id of the Retrieve/Search Customers lookup.
     * @param {String} opts.from_index To fetch the next set of objects that start after this object
     * @param {String} opts.to_index To fetch the previous set of objects that end at this object
     * @param {module:api/PaymentSetupApi~retrievePaymentSetupsCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link module:models/PaymentSetupsResponse}
     */
    this.retrievePaymentSetups = function(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, opts, callback) {
      opts = opts || {};
      var postBody = null;

      var pathParams = {
      };
      var queryParams = {
        'id_customer': opts['id_customer'],
        'id_funding_account': opts['id_funding_account'],
        'id_customer_account': opts['id_customer_account'],
        'confirmation_number': opts['confirmation_number'],
        'status': opts['status'],
        'payment_setup_schedule_type': opts['payment_setup_schedule_type'],
        'from_date': opts['from_date'],
        'to_date': opts['to_date'],
        'page_size': opts['page_size'],
        'query_id': opts['query_id'],
        'from_index': opts['from_index'],
        'to_index': opts['to_index']
      };
      var headerParams = {
        'channel': channel,
        'client_key': client_key,
        'product': product,
        'timestamp': timestamp,
        'idempotent_request_key': idempotent_request_key,
        'requestor_type': requestor_type,
        'requestor': opts['requestor'],
        'X-OPAY-Headers': opts['x_opay_headers'],
        'trace_id': opts['trace_id']
      };
      var formParams = {
      };

      var authNames = [];
      var contentTypes = [];
      var accepts = ['application/json'];
      var returnType = PaymentSetupsResponse;

      return this.apiClient.callApi(
        '/paymentsetups', 'GET',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, callback
      );
    };

    /**
     * Callback function to receive the result of the updatePaymentSetup operation.
     * @callback module:api/PaymentSetupApi~updatePaymentSetupCallback
     * @param {String} error Error message, if any.
     * @param {module:models/PaymentSetupResponse} data The data returned by the service call.
     * @param {String} response The complete HTTP response.
     */

    /**
     * Update Payment Setup
     * The API is used to edit a payment Setup. Only autopay payment setup is allowed to  edit.
     * @param {String} channel The channel through which the API is invoked.
     * @param {String} client_key The unique identifier assigned by EBPP to the client.
     * @param {module:models/String} product The product identifier corresponding to the API.
     * @param {String} timestamp The timestamp for the moment when the API request is created.
     * @param {String} idempotent_request_key The unique token that clients can generate and maintain in order to identify an API request.
     * @param {module:models/String} requestor_type Type of the requestor of the API.
     * @param {String} id_payment_setup The unique identifier assigned by EBPP to the payment setup.
     * @param {String} id_customer The unique identifier assigned by EBPP to the customer.
     * @param {module:models/UpdatePaymentSetupRequest} update_payment_setup_request Details of the Payment Setup to be updated.
     * @param {Object} opts Optional parameters
     * @param {String} opts.requestor The identifier for the requestor of the API. If the requestor_type is &lt;b&gt;system&lt;/b&gt;, requestor is optional.
     * @param {String} opts.x_opay_headers Intended for the future use.
     * @param {String} opts.trace_id The unique reference that can be used for tracing and debugging an API call.
     * @param {module:api/PaymentSetupApi~updatePaymentSetupCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link module:models/PaymentSetupResponse}
     */
    this.updatePaymentSetup = function(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, id_payment_setup, id_customer, update_payment_setup_request, opts, callback) {
      opts = opts || {};
      var postBody = update_payment_setup_request;

      var pathParams = {
        'ID_PAYMENT_SETUP': id_payment_setup,
        'ID_CUSTOMER': id_customer
      };
      var queryParams = {
      };
      var headerParams = {
        'channel': channel,
        'client_key': client_key,
        'product': product,
        'timestamp': timestamp,
        'idempotent_request_key': idempotent_request_key,
        'requestor_type': requestor_type,
        'requestor': opts['requestor'],
        'X-OPAY-Headers': opts['x_opay_headers'],
        'trace_id': opts['trace_id']
      };
      var formParams = {
      };

      var authNames = [];
      var contentTypes = ['application/json'];
      var accepts = ['application/json'];
      var returnType = PaymentSetupResponse;

      return this.apiClient.callApi(
        '/customers/{ID_CUSTOMER}/paymentsetups/{ID_PAYMENT_SETUP}', 'PUT',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, callback
      );
    };
  };

  return exports;
}));