/**
 * AvaTax Brazil
 * The Avatax-Brazil API exposes the most commonly services available for interacting with the AvaTax-Brazil services, allowing calculation of taxes, issuing electronic invoice documents and modifying existing transactions when allowed by tax authorities.  This API is exclusively for use by business with a physical presence in Brazil.
 *
 * OpenAPI spec version: 1.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.
 *
 */

(function(root, factory) {
  if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define(['ApiClient', 'model/CfopConf', 'model/InlineResponse201', 'model/Message', 'model/ValidationError'], factory);
  } else if (typeof module === 'object' && module.exports) {
    // CommonJS-like environments that support module.exports, like Node.
    module.exports = factory(require('../ApiClient'), require('../model/CfopConf'), require('../model/InlineResponse201'), require('../model/Message'), require('../model/ValidationError'));
  } else {
    // Browser globals (root is window)
    if (!root.AvaTaxBrazil) {
      root.AvaTaxBrazil = {};
    }
    root.AvaTaxBrazil.TaxConfCFOPApi = factory(root.AvaTaxBrazil.ApiClient, root.AvaTaxBrazil.CfopConf, root.AvaTaxBrazil.InlineResponse201, root.AvaTaxBrazil.Message, root.AvaTaxBrazil.ValidationError);
  }
}(this, function(ApiClient, CfopConf, InlineResponse201, Message, ValidationError) {
  'use strict';

  /**
   * TaxConfCFOP service.
   * @module api/TaxConfCFOPApi
   * @version 1.0
   */

  /**
   * Constructs a new TaxConfCFOPApi. 
   * @alias module:api/TaxConfCFOPApi
   * @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 createCfop operation.
     * @callback module:api/TaxConfCFOPApi~createCfopCallback
     * @param {String} error Error message, if any.
     * @param {module:model/InlineResponse201} data The data returned by the service call.
     * @param {String} response The complete HTTP response.
     */

    /**
     * create a new CFOP configuration
     * @param {String} authorization Bearer {auth}
     * @param {module:model/CfopConf} body The pet JSON you want to post
     * @param {module:api/TaxConfCFOPApi~createCfopCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link module:model/InlineResponse201}
     */
    this.createCfop = function(authorization, body, callback) {
      var postBody = body;

      // verify the required parameter 'authorization' is set
      if (authorization == undefined || authorization == null) {
        throw new Error("Missing the required parameter 'authorization' when calling createCfop");
      }

      // verify the required parameter 'body' is set
      if (body == undefined || body == null) {
        throw new Error("Missing the required parameter 'body' when calling createCfop");
      }


      var pathParams = {
      };
      var queryParams = {
      };
      var headerParams = {
        'Authorization': authorization
      };
      var formParams = {
      };

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

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

    /**
     * Callback function to receive the result of the deleteCfop operation.
     * @callback module:api/TaxConfCFOPApi~deleteCfopCallback
     * @param {String} error Error message, if any.
     * @param data This operation does not return a value.
     * @param {String} response The complete HTTP response.
     */

    /**
     * disable a CFOP.
     * @param {String} authorization Bearer {auth}
     * @param {String} code CFOP Code
     * @param {module:api/TaxConfCFOPApi~deleteCfopCallback} callback The callback function, accepting three arguments: error, data, response
     */
    this.deleteCfop = function(authorization, code, callback) {
      var postBody = null;

      // verify the required parameter 'authorization' is set
      if (authorization == undefined || authorization == null) {
        throw new Error("Missing the required parameter 'authorization' when calling deleteCfop");
      }

      // verify the required parameter 'code' is set
      if (code == undefined || code == null) {
        throw new Error("Missing the required parameter 'code' when calling deleteCfop");
      }


      var pathParams = {
        'code': code
      };
      var queryParams = {
      };
      var headerParams = {
        'Authorization': authorization
      };
      var formParams = {
      };

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

      return this.apiClient.callApi(
        '/taxconf/cfop/{code}', 'DELETE',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, callback
      );
    }

    /**
     * Callback function to receive the result of the getCfop operation.
     * @callback module:api/TaxConfCFOPApi~getCfopCallback
     * @param {String} error Error message, if any.
     * @param {module:model/CfopConf} data The data returned by the service call.
     * @param {String} response The complete HTTP response.
     */

    /**
     * get CFOP information.
     * This operation return CFOP configuration 
     * @param {String} authorization Bearer {auth}
     * @param {String} code CFOP Code
     * @param {module:api/TaxConfCFOPApi~getCfopCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link module:model/CfopConf}
     */
    this.getCfop = function(authorization, code, callback) {
      var postBody = null;

      // verify the required parameter 'authorization' is set
      if (authorization == undefined || authorization == null) {
        throw new Error("Missing the required parameter 'authorization' when calling getCfop");
      }

      // verify the required parameter 'code' is set
      if (code == undefined || code == null) {
        throw new Error("Missing the required parameter 'code' when calling getCfop");
      }


      var pathParams = {
        'code': code
      };
      var queryParams = {
      };
      var headerParams = {
        'Authorization': authorization
      };
      var formParams = {
      };

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

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

    /**
     * Callback function to receive the result of the getCfopList operation.
     * @callback module:api/TaxConfCFOPApi~getCfopListCallback
     * @param {String} error Error message, if any.
     * @param {Array.<module:model/CfopConf>} data The data returned by the service call.
     * @param {String} response The complete HTTP response.
     */

    /**
     * retrive list of CFOP.
     * This operation return CFOP configurations that match with parameters queries 
     * @param {String} authorization Bearer {auth}
     * @param {Object} opts Optional parameters
     * @param {String} opts.suffixcode Identify this CFOP, the CFOP Code has two parts N.XXX where N the prefix is the operation scope type if IN or OUT and if is in state, other state, other country and suffix XXX is the operation type 
     * @param {Date} opts._date When informed return valid version configuration for this date 
     * @param {Boolean} opts.inactive return the inactive versions too 
     * @param {module:api/TaxConfCFOPApi~getCfopListCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link Array.<module:model/CfopConf>}
     */
    this.getCfopList = function(authorization, opts, callback) {
      opts = opts || {};
      var postBody = null;

      // verify the required parameter 'authorization' is set
      if (authorization == undefined || authorization == null) {
        throw new Error("Missing the required parameter 'authorization' when calling getCfopList");
      }


      var pathParams = {
      };
      var queryParams = {
        'suffixcode': opts['suffixcode'],
        'date': opts['_date'],
        'inactive': opts['inactive']
      };
      var headerParams = {
        'Authorization': authorization
      };
      var formParams = {
      };

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

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

    /**
     * Callback function to receive the result of the updateCfop operation.
     * @callback module:api/TaxConfCFOPApi~updateCfopCallback
     * @param {String} error Error message, if any.
     * @param data This operation does not return a value.
     * @param {String} response The complete HTTP response.
     */

    /**
     * update a CFOP configuration
     * @param {String} authorization Bearer {auth}
     * @param {String} code CFOP Code
     * @param {module:model/CfopConf} taxconfcfop The pet JSON you want to post
     * @param {module:api/TaxConfCFOPApi~updateCfopCallback} callback The callback function, accepting three arguments: error, data, response
     */
    this.updateCfop = function(authorization, code, taxconfcfop, callback) {
      var postBody = taxconfcfop;

      // verify the required parameter 'authorization' is set
      if (authorization == undefined || authorization == null) {
        throw new Error("Missing the required parameter 'authorization' when calling updateCfop");
      }

      // verify the required parameter 'code' is set
      if (code == undefined || code == null) {
        throw new Error("Missing the required parameter 'code' when calling updateCfop");
      }

      // verify the required parameter 'taxconfcfop' is set
      if (taxconfcfop == undefined || taxconfcfop == null) {
        throw new Error("Missing the required parameter 'taxconfcfop' when calling updateCfop");
      }


      var pathParams = {
        'code': code
      };
      var queryParams = {
      };
      var headerParams = {
        'Authorization': authorization
      };
      var formParams = {
      };

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

      return this.apiClient.callApi(
        '/taxconf/cfop/{code}', 'PUT',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, callback
      );
    }
  };

  return exports;
}));
