text: /**
   * PagarmeCoreApiLib
   *
   * This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
   */
  
  'use strict';
  
  const _request = require('../Http/Client/RequestClient');
  const _configuration = require('../configuration');
  const _apiHelper = require('../APIHelper');
  const _baseController = require('./BaseController');
  
  class ChargesController {
      /**
       * Updates the metadata from a charge
       *
       * @param {string} chargeId The charge id
       * @param {UpdateMetadataRequest} request Request for updating the charge metadata
       * @param {string} idempotencyKey (optional) TODO: type description here
       *
       * @callback    The callback function that returns response from the API call
       *
       * @returns {Promise}
       */
      static updateChargeMetadata(chargeId, request, idempotencyKey, callback) {
          // create empty callback if absent
          const _callback = typeof callback === 'function' ? callback : () => undefined;
  
          // prepare query string for API call
          const _baseUri = _configuration.BASEURI;
  
          let _pathUrl = '/Charges/{charge_id}/metadata';
          // process template parameters
          _pathUrl = _apiHelper.appendUrlWithTemplateParameters(_pathUrl, {
              charge_id: { value: chargeId, encode: true },
          });
  
          const _queryBuilder = `${_baseUri}${_pathUrl}`;
  
          // validate and preprocess url
          const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
  
          // prepare headers
          const _headers = {
              accept: 'application/json',
              'content-type': 'application/json; charset=utf-8',
              'idempotency-key': idempotencyKey,
              'user-agent': 'PagarmeCoreApi - Node 5.5.0',
          };
  
          // construct the request
          const _options = {
              queryUrl: _queryUrl,
              method: 'PATCH',
              headers: _headers,
              body: _apiHelper.jsonSerialize(request),
              username: _configuration.basicAuthUserName,
              password: _configuration.basicAuthPassword,
          };
  
          // build the response processing.
          return new Promise((_fulfill, _reject) => {
              _request(_options, (_error, _response, _context) => {
                  let errorResponse;
                  if (_error) {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
                      let parsed = JSON.parse(_response.body);
                      parsed = _baseController.getObjectMapper().mapObject(parsed, 'GetChargeResponse');
                      _callback(null, parsed, _context);
                      _fulfill(parsed);
                  } else {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  }
              });
          });
      }
      /**
       * Updates a charge's payment method
       *
       * @param {string} chargeId Charge id
       * @param {UpdateChargePaymentMethodRequest} request Request for updating the payment method
       * from a charge
       * @param {string} idempotencyKey (optional) TODO: type description here
       *
       * @callback    The callback function that returns response from the API call
       *
       * @returns {Promise}
       */
      static updateChargePaymentMethod(chargeId, request, idempotencyKey, callback) {
          // create empty callback if absent
          const _callback = typeof callback === 'function' ? callback : () => undefined;
  
          // prepare query string for API call
          const _baseUri = _configuration.BASEURI;
  
          let _pathUrl = '/charges/{charge_id}/payment-method';
          // process template parameters
          _pathUrl = _apiHelper.appendUrlWithTemplateParameters(_pathUrl, {
              charge_id: { value: chargeId, encode: true },
          });
  
          const _queryBuilder = `${_baseUri}${_pathUrl}`;
  
          // validate and preprocess url
          const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
  
          // prepare headers
          const _headers = {
              accept: 'application/json',
              'content-type': 'application/json; charset=utf-8',
              'idempotency-key': idempotencyKey,
              'user-agent': 'PagarmeCoreApi - Node 5.5.0',
          };
  
          // construct the request
          const _options = {
              queryUrl: _queryUrl,
              method: 'PATCH',
              headers: _headers,
              body: _apiHelper.jsonSerialize(request),
              username: _configuration.basicAuthUserName,
              password: _configuration.basicAuthPassword,
          };
  
          // build the response processing.
          return new Promise((_fulfill, _reject) => {
              _request(_options, (_error, _response, _context) => {
                  let errorResponse;
                  if (_error) {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
                      let parsed = JSON.parse(_response.body);
                      parsed = _baseController.getObjectMapper().mapObject(parsed, 'GetChargeResponse');
                      _callback(null, parsed, _context);
                      _fulfill(parsed);
                  } else {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  }
              });
          });
      }
      /**
       * @todo Add general description for this endpoint
       *
       * @param {string} chargeId Charge Id
       * @param {int} page (optional) Page number
       * @param {int} size (optional) Page size
       *
       * @callback    The callback function that returns response from the API call
       *
       * @returns {Promise}
       */
      static getChargeTransactions(chargeId, page, size, callback) {
          // create empty callback if absent
          const _callback = typeof callback === 'function' ? callback : () => undefined;
  
          // prepare query string for API call
          const _baseUri = _configuration.BASEURI;
  
          let _pathUrl = '/charges/{charge_id}/transactions';
          // process template parameters
          _pathUrl = _apiHelper.appendUrlWithTemplateParameters(_pathUrl, {
              charge_id: { value: chargeId, encode: true },
          });
  
          let _queryBuilder = `${_baseUri}${_pathUrl}`;
  
          // process query parameters
          _queryBuilder = _apiHelper.appendUrlWithQueryParameters(_queryBuilder, {
              page,
              size,
          });
  
          // validate and preprocess url
          const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
  
          // prepare headers
          const _headers = {
              accept: 'application/json',
              'user-agent': 'PagarmeCoreApi - Node 5.5.0',
          };
  
          // construct the request
          const _options = {
              queryUrl: _queryUrl,
              method: 'GET',
              headers: _headers,
              username: _configuration.basicAuthUserName,
              password: _configuration.basicAuthPassword,
          };
  
          // build the response processing.
          return new Promise((_fulfill, _reject) => {
              _request(_options, (_error, _response, _context) => {
                  let errorResponse;
                  if (_error) {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
                      let parsed = JSON.parse(_response.body);
                      parsed = _baseController.getObjectMapper()
                  .mapObject(parsed, 'ListChargeTransactionsResponse');
                      _callback(null, parsed, _context);
                      _fulfill(parsed);
                  } else {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  }
              });
          });
      }
      /**
       * Updates the due date from a charge
       *
       * @param {string} chargeId Charge Id
       * @param {UpdateChargeDueDateRequest} request Request for updating the due date
       * @param {string} idempotencyKey (optional) TODO: type description here
       *
       * @callback    The callback function that returns response from the API call
       *
       * @returns {Promise}
       */
      static updateChargeDueDate(chargeId, request, idempotencyKey, callback) {
          // create empty callback if absent
          const _callback = typeof callback === 'function' ? callback : () => undefined;
  
          // prepare query string for API call
          const _baseUri = _configuration.BASEURI;
  
          let _pathUrl = '/Charges/{charge_id}/due-date';
          // process template parameters
          _pathUrl = _apiHelper.appendUrlWithTemplateParameters(_pathUrl, {
              charge_id: { value: chargeId, encode: true },
          });
  
          const _queryBuilder = `${_baseUri}${_pathUrl}`;
  
          // validate and preprocess url
          const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
  
          // prepare headers
          const _headers = {
              accept: 'application/json',
              'content-type': 'application/json; charset=utf-8',
              'idempotency-key': idempotencyKey,
              'user-agent': 'PagarmeCoreApi - Node 5.5.0',
          };
  
          // construct the request
          const _options = {
              queryUrl: _queryUrl,
              method: 'PATCH',
              headers: _headers,
              body: _apiHelper.jsonSerialize(request),
              username: _configuration.basicAuthUserName,
              password: _configuration.basicAuthPassword,
          };
  
          // build the response processing.
          return new Promise((_fulfill, _reject) => {
              _request(_options, (_error, _response, _context) => {
                  let errorResponse;
                  if (_error) {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
                      let parsed = JSON.parse(_response.body);
                      parsed = _baseController.getObjectMapper().mapObject(parsed, 'GetChargeResponse');
                      _callback(null, parsed, _context);
                      _fulfill(parsed);
                  } else {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  }
              });
          });
      }
      /**
       * Lists all charges
       *
       * @param {int} page (optional) Page number
       * @param {int} size (optional) Page size
       * @param {string} code (optional) Filter for charge's code
       * @param {string} status (optional) Filter for charge's status
       * @param {string} paymentMethod (optional) Filter for charge's payment method
       * @param {string} customerId (optional) Filter for charge's customer id
       * @param {string} orderId (optional) Filter for charge's order id
       * @param {dateTime} createdSince (optional) Filter for the beginning of the range for charge's
       * creation
       * @param {dateTime} createdUntil (optional) Filter for the end of the range for charge's
       * creation
       *
       * @callback    The callback function that returns response from the API call
       *
       * @returns {Promise}
       */
      static getCharges(page,
          size,
          code,
          status,
          paymentMethod,
          customerId,
          orderId,
          createdSince,
          createdUntil,
          callback) {
          // create empty callback if absent
          const _callback = typeof callback === 'function' ? callback : () => undefined;
  
          // prepare query string for API call
          const _baseUri = _configuration.BASEURI;
  
          const _pathUrl = '/charges';
          let _queryBuilder = `${_baseUri}${_pathUrl}`;
  
          // process query parameters
          _queryBuilder = _apiHelper.appendUrlWithQueryParameters(_queryBuilder, {
              page,
              size,
              code,
              status,
              payment_method: paymentMethod,
              customer_id: customerId,
              order_id: orderId,
              created_since: _apiHelper.stringifyDateTime(createdSince, 'rfc3339'),
              created_until: _apiHelper.stringifyDateTime(createdUntil, 'rfc3339'),
          });
  
          // validate and preprocess url
          const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
  
          // prepare headers
          const _headers = {
              accept: 'application/json',
              'user-agent': 'PagarmeCoreApi - Node 5.5.0',
          };
  
          // construct the request
          const _options = {
              queryUrl: _queryUrl,
              method: 'GET',
              headers: _headers,
              username: _configuration.basicAuthUserName,
              password: _configuration.basicAuthPassword,
          };
  
          // build the response processing.
          return new Promise((_fulfill, _reject) => {
              _request(_options, (_error, _response, _context) => {
                  let errorResponse;
                  if (_error) {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
                      let parsed = JSON.parse(_response.body);
                      parsed = _baseController.getObjectMapper().mapObject(parsed, 'ListChargesResponse');
                      _callback(null, parsed, _context);
                      _fulfill(parsed);
                  } else {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  }
              });
          });
      }
      /**
       * Captures a charge
       *
       * @param {string} chargeId Charge id
       * @param {CreateCaptureChargeRequest} request (optional) Request for capturing a charge
       * @param {string} idempotencyKey (optional) TODO: type description here
       *
       * @callback    The callback function that returns response from the API call
       *
       * @returns {Promise}
       */
      static captureCharge(chargeId, request, idempotencyKey, callback) {
          // create empty callback if absent
          const _callback = typeof callback === 'function' ? callback : () => undefined;
  
          // prepare query string for API call
          const _baseUri = _configuration.BASEURI;
  
          let _pathUrl = '/charges/{charge_id}/capture';
          // process template parameters
          _pathUrl = _apiHelper.appendUrlWithTemplateParameters(_pathUrl, {
              charge_id: { value: chargeId, encode: true },
          });
  
          const _queryBuilder = `${_baseUri}${_pathUrl}`;
  
          // validate and preprocess url
          const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
  
          // prepare headers
          const _headers = {
              accept: 'application/json',
              'content-type': 'application/json; charset=utf-8',
              'idempotency-key': idempotencyKey,
              'user-agent': 'PagarmeCoreApi - Node 5.5.0',
          };
  
          // construct the request
          const _options = {
              queryUrl: _queryUrl,
              method: 'POST',
              headers: _headers,
              body: _apiHelper.jsonSerialize(request),
              username: _configuration.basicAuthUserName,
              password: _configuration.basicAuthPassword,
          };
  
          // build the response processing.
          return new Promise((_fulfill, _reject) => {
              _request(_options, (_error, _response, _context) => {
                  let errorResponse;
                  if (_error) {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
                      let parsed = JSON.parse(_response.body);
                      parsed = _baseController.getObjectMapper().mapObject(parsed, 'GetChargeResponse');
                      _callback(null, parsed, _context);
                      _fulfill(parsed);
                  } else {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  }
              });
          });
      }
      /**
       * Updates the card from a charge
       *
       * @param {string} chargeId Charge id
       * @param {UpdateChargeCardRequest} request Request for updating a charge's card
       * @param {string} idempotencyKey (optional) TODO: type description here
       *
       * @callback    The callback function that returns response from the API call
       *
       * @returns {Promise}
       */
      static updateChargeCard(chargeId, request, idempotencyKey, callback) {
          // create empty callback if absent
          const _callback = typeof callback === 'function' ? callback : () => undefined;
  
          // prepare query string for API call
          const _baseUri = _configuration.BASEURI;
  
          let _pathUrl = '/charges/{charge_id}/card';
          // process template parameters
          _pathUrl = _apiHelper.appendUrlWithTemplateParameters(_pathUrl, {
              charge_id: { value: chargeId, encode: true },
          });
  
          const _queryBuilder = `${_baseUri}${_pathUrl}`;
  
          // validate and preprocess url
          const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
  
          // prepare headers
          const _headers = {
              accept: 'application/json',
              'content-type': 'application/json; charset=utf-8',
              'idempotency-key': idempotencyKey,
              'user-agent': 'PagarmeCoreApi - Node 5.5.0',
          };
  
          // construct the request
          const _options = {
              queryUrl: _queryUrl,
              method: 'PATCH',
              headers: _headers,
              body: _apiHelper.jsonSerialize(request),
              username: _configuration.basicAuthUserName,
              password: _configuration.basicAuthPassword,
          };
  
          // build the response processing.
          return new Promise((_fulfill, _reject) => {
              _request(_options, (_error, _response, _context) => {
                  let errorResponse;
                  if (_error) {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
                      let parsed = JSON.parse(_response.body);
                      parsed = _baseController.getObjectMapper().mapObject(parsed, 'GetChargeResponse');
                      _callback(null, parsed, _context);
                      _fulfill(parsed);
                  } else {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  }
              });
          });
      }
      /**
       * Get a charge from its id
       *
       * @param {string} chargeId Charge id
       *
       * @callback    The callback function that returns response from the API call
       *
       * @returns {Promise}
       */
      static getCharge(chargeId, callback) {
          // create empty callback if absent
          const _callback = typeof callback === 'function' ? callback : () => undefined;
  
          // prepare query string for API call
          const _baseUri = _configuration.BASEURI;
  
          let _pathUrl = '/charges/{charge_id}';
          // process template parameters
          _pathUrl = _apiHelper.appendUrlWithTemplateParameters(_pathUrl, {
              charge_id: { value: chargeId, encode: true },
          });
  
          const _queryBuilder = `${_baseUri}${_pathUrl}`;
  
          // validate and preprocess url
          const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
  
          // prepare headers
          const _headers = {
              accept: 'application/json',
              'user-agent': 'PagarmeCoreApi - Node 5.5.0',
          };
  
          // construct the request
          const _options = {
              queryUrl: _queryUrl,
              method: 'GET',
              headers: _headers,
              username: _configuration.basicAuthUserName,
              password: _configuration.basicAuthPassword,
          };
  
          // build the response processing.
          return new Promise((_fulfill, _reject) => {
              _request(_options, (_error, _response, _context) => {
                  let errorResponse;
                  if (_error) {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
                      let parsed = JSON.parse(_response.body);
                      parsed = _baseController.getObjectMapper().mapObject(parsed, 'GetChargeResponse');
                      _callback(null, parsed, _context);
                      _fulfill(parsed);
                  } else {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  }
              });
          });
      }
      /**
       * @todo Add general description for this endpoint
       *
       * @param {string} status TODO: type description here
       * @param {dateTime} createdSince (optional) TODO: type description here
       * @param {dateTime} createdUntil (optional) TODO: type description here
       *
       * @callback    The callback function that returns response from the API call
       *
       * @returns {Promise}
       */
      static getChargesSummary(status, createdSince, createdUntil, callback) {
          // create empty callback if absent
          const _callback = typeof callback === 'function' ? callback : () => undefined;
  
          // prepare query string for API call
          const _baseUri = _configuration.BASEURI;
  
          const _pathUrl = '/charges/summary';
          let _queryBuilder = `${_baseUri}${_pathUrl}`;
  
          // process query parameters
          _queryBuilder = _apiHelper.appendUrlWithQueryParameters(_queryBuilder, {
              status,
              created_since: _apiHelper.stringifyDateTime(createdSince, 'rfc3339'),
              created_until: _apiHelper.stringifyDateTime(createdUntil, 'rfc3339'),
          });
  
          // validate and preprocess url
          const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
  
          // prepare headers
          const _headers = {
              accept: 'application/json',
              'user-agent': 'PagarmeCoreApi - Node 5.5.0',
          };
  
          // construct the request
          const _options = {
              queryUrl: _queryUrl,
              method: 'GET',
              headers: _headers,
              username: _configuration.basicAuthUserName,
              password: _configuration.basicAuthPassword,
          };
  
          // build the response processing.
          return new Promise((_fulfill, _reject) => {
              _request(_options, (_error, _response, _context) => {
                  let errorResponse;
                  if (_error) {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
                      let parsed = JSON.parse(_response.body);
                      parsed = _baseController.getObjectMapper().mapObject(parsed, 'GetChargesSummaryResponse');
                      _callback(null, parsed, _context);
                      _fulfill(parsed);
                  } else {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  }
              });
          });
      }
      /**
       * Retries a charge
       *
       * @param {string} chargeId Charge id
       * @param {string} idempotencyKey (optional) TODO: type description here
       *
       * @callback    The callback function that returns response from the API call
       *
       * @returns {Promise}
       */
      static retryCharge(chargeId, idempotencyKey, callback) {
          // create empty callback if absent
          const _callback = typeof callback === 'function' ? callback : () => undefined;
  
          // prepare query string for API call
          const _baseUri = _configuration.BASEURI;
  
          let _pathUrl = '/charges/{charge_id}/retry';
          // process template parameters
          _pathUrl = _apiHelper.appendUrlWithTemplateParameters(_pathUrl, {
              charge_id: { value: chargeId, encode: true },
          });
  
          const _queryBuilder = `${_baseUri}${_pathUrl}`;
  
          // validate and preprocess url
          const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
  
          // prepare headers
          const _headers = {
              accept: 'application/json',
              'idempotency-key': idempotencyKey,
              'user-agent': 'PagarmeCoreApi - Node 5.5.0',
          };
  
          // construct the request
          const _options = {
              queryUrl: _queryUrl,
              method: 'POST',
              headers: _headers,
              username: _configuration.basicAuthUserName,
              password: _configuration.basicAuthPassword,
          };
  
          // build the response processing.
          return new Promise((_fulfill, _reject) => {
              _request(_options, (_error, _response, _context) => {
                  let errorResponse;
                  if (_error) {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
                      let parsed = JSON.parse(_response.body);
                      parsed = _baseController.getObjectMapper().mapObject(parsed, 'GetChargeResponse');
                      _callback(null, parsed, _context);
                      _fulfill(parsed);
                  } else {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  }
              });
          });
      }
      /**
       * Cancel a charge
       *
       * @param {string} chargeId Charge id
       * @param {CreateCancelChargeRequest} request (optional) Request for cancelling a charge
       * @param {string} idempotencyKey (optional) TODO: type description here
       *
       * @callback    The callback function that returns response from the API call
       *
       * @returns {Promise}
       */
      static cancelCharge(chargeId, request, idempotencyKey, callback) {
          // create empty callback if absent
          const _callback = typeof callback === 'function' ? callback : () => undefined;
  
          // prepare query string for API call
          const _baseUri = _configuration.BASEURI;
  
          let _pathUrl = '/charges/{charge_id}';
          // process template parameters
          _pathUrl = _apiHelper.appendUrlWithTemplateParameters(_pathUrl, {
              charge_id: { value: chargeId, encode: true },
          });
  
          const _queryBuilder = `${_baseUri}${_pathUrl}`;
  
          // validate and preprocess url
          const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
  
          // prepare headers
          const _headers = {
              accept: 'application/json',
              'content-type': 'application/json; charset=utf-8',
              'idempotency-key': idempotencyKey,
              'user-agent': 'PagarmeCoreApi - Node 5.5.0',
          };
  
          // construct the request
          const _options = {
              queryUrl: _queryUrl,
              method: 'DELETE',
              headers: _headers,
              body: _apiHelper.jsonSerialize(request),
              username: _configuration.basicAuthUserName,
              password: _configuration.basicAuthPassword,
          };
  
          // build the response processing.
          return new Promise((_fulfill, _reject) => {
              _request(_options, (_error, _response, _context) => {
                  let errorResponse;
                  if (_error) {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
                      let parsed = JSON.parse(_response.body);
                      parsed = _baseController.getObjectMapper().mapObject(parsed, 'GetChargeResponse');
                      _callback(null, parsed, _context);
                      _fulfill(parsed);
                  } else {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  }
              });
          });
      }
      /**
       * Creates a new charge
       *
       * @param {CreateChargeRequest} request Request for creating a charge
       * @param {string} idempotencyKey (optional) TODO: type description here
       *
       * @callback    The callback function that returns response from the API call
       *
       * @returns {Promise}
       */
      static createCharge(request, idempotencyKey, callback) {
          // create empty callback if absent
          const _callback = typeof callback === 'function' ? callback : () => undefined;
  
          // prepare query string for API call
          const _baseUri = _configuration.BASEURI;
  
          const _pathUrl = '/Charges';
          const _queryBuilder = `${_baseUri}${_pathUrl}`;
  
          // validate and preprocess url
          const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
  
          // prepare headers
          const _headers = {
              accept: 'application/json',
              'content-type': 'application/json; charset=utf-8',
              'idempotency-key': idempotencyKey,
              'user-agent': 'PagarmeCoreApi - Node 5.5.0',
          };
  
          // construct the request
          const _options = {
              queryUrl: _queryUrl,
              method: 'POST',
              headers: _headers,
              body: _apiHelper.jsonSerialize(request),
              username: _configuration.basicAuthUserName,
              password: _configuration.basicAuthPassword,
          };
  
          // build the response processing.
          return new Promise((_fulfill, _reject) => {
              _request(_options, (_error, _response, _context) => {
                  let errorResponse;
                  if (_error) {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
                      let parsed = JSON.parse(_response.body);
                      parsed = _baseController.getObjectMapper().mapObject(parsed, 'GetChargeResponse');
                      _callback(null, parsed, _context);
                      _fulfill(parsed);
                  } else {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  }
              });
          });
      }
      /**
       * @todo Add general description for this endpoint
       *
       * @param {string} chargeId TODO: type description here
       * @param {CreateConfirmPaymentRequest} request (optional) Request for confirm payment
       * @param {string} idempotencyKey (optional) TODO: type description here
       *
       * @callback    The callback function that returns response from the API call
       *
       * @returns {Promise}
       */
      static confirmPayment(chargeId, request, idempotencyKey, callback) {
          // create empty callback if absent
          const _callback = typeof callback === 'function' ? callback : () => undefined;
  
          // prepare query string for API call
          const _baseUri = _configuration.BASEURI;
  
          let _pathUrl = '/charges/{charge_id}/confirm-payment';
          // process template parameters
          _pathUrl = _apiHelper.appendUrlWithTemplateParameters(_pathUrl, {
              charge_id: { value: chargeId, encode: true },
          });
  
          const _queryBuilder = `${_baseUri}${_pathUrl}`;
  
          // validate and preprocess url
          const _queryUrl = _apiHelper.cleanUrl(_queryBuilder);
  
          // prepare headers
          const _headers = {
              accept: 'application/json',
              'content-type': 'application/json; charset=utf-8',
              'idempotency-key': idempotencyKey,
              'user-agent': 'PagarmeCoreApi - Node 5.5.0',
          };
  
          // construct the request
          const _options = {
              queryUrl: _queryUrl,
              method: 'POST',
              headers: _headers,
              body: _apiHelper.jsonSerialize(request),
              username: _configuration.basicAuthUserName,
              password: _configuration.basicAuthPassword,
          };
  
          // build the response processing.
          return new Promise((_fulfill, _reject) => {
              _request(_options, (_error, _response, _context) => {
                  let errorResponse;
                  if (_error) {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  } else if (_response.statusCode >= 200 && _response.statusCode <= 206) {
                      let parsed = JSON.parse(_response.body);
                      parsed = _baseController.getObjectMapper().mapObject(parsed, 'GetChargeResponse');
                      _callback(null, parsed, _context);
                      _fulfill(parsed);
                  } else {
                      errorResponse = _baseController.validateResponse(_context);
                      _callback(errorResponse.error, errorResponse.response, errorResponse.context);
                      _reject(errorResponse.error);
                  }
              });
          });
      }
  }
  module.exports = ChargesController;
  