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

  /**
   * PaymentAuthorization service.
   * @module api/PaymentAuthorizationApi
   */

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

   * Constructs a new PaymentAuthorizationApi. 
   * @alias module:api/PaymentAuthorizationApi
   * @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 cancelPaymentAuthorization operation.
     * @callback module:api/PaymentAuthorizationApi~cancelPaymentAuthorizationCallback
     * @param {String} error Error message, if any.
     * @param data This operation does not return a value.
     * @param {String} response The complete HTTP response.
     */

    /**
     * Cancel Payment Authorization
     * The API is used to cancel a payment authorization. Payment Authorizations that are already been processed into Payment cannot be  cancelled. It returns 204 http status code with empty body in successful case.
     * @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 {String} id_authorization The unique identifier assigned by EBPP to the payment authorization.
     * @param {module:models/CancelPaymentAuthorizationRequest} cancel_payment_authorization_request Details of payment authorization to be cancelled
     * @param {Object} opts Optional parameters
     * @param {String} opts.requestor The identifier for the requestor of the API.
     * @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/PaymentAuthorizationApi~cancelPaymentAuthorizationCallback} callback The callback function, accepting three arguments: error, data, response
     */
    this.cancelPaymentAuthorization = function(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, id_customer, id_authorization, cancel_payment_authorization_request, opts, callback) {
      opts = opts || {};
      var postBody = cancel_payment_authorization_request;

      var pathParams = {
        'ID_CUSTOMER': id_customer,
        'ID_AUTHORIZATION': id_authorization
      };
      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 = null;

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

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

    /**
     * Create Payment Authorization
     * The API is used to create a payment authorization with certain amount on a given card account. Client systems can provide the unique identifier for the payment authorization in their system as payment_auth_reference.
     * @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 {module:models/CreatePaymentAuthorizationRequest} create_payment_authorization_request JSON containing all the fields required to make a payment.
     * @param {Object} opts Optional parameters
     * @param {String} opts.requestor The identifier for the requestor of the API.
     * @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/PaymentAuthorizationApi~createPaymentAuthorizationCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link module:models/PaymentAuthorizationResponse}
     */
    this.createPaymentAuthorization = function(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, create_payment_authorization_request, opts, callback) {
      opts = opts || {};
      var postBody = create_payment_authorization_request;

      var pathParams = {
      };
      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 = PaymentAuthorizationResponse;

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

  return exports;
}));