module AvaTax
  class Client
    module TaxCodes 


      # Create a new tax code
      #
      # Create one or more new taxcode objects attached to this company.
      # A 'TaxCode' represents a uniquely identified type of product, good, or service.
      # Avalara supports correct tax rates and taxability rules for all TaxCodes in all supported jurisdictions.
      # If you identify your products by tax code in your 'Create Transacion' API calls, Avalara will correctly calculate tax rates and
      # taxability rules for this product in all supported jurisdictions.
      # @param companyId [Integer] The ID of the company that owns this tax code.
      # @param model [TaxCodeModel[]] The tax code you wish to create.
      # @return [TaxCodeModel[]]
      def create_tax_codes(companyId, model)
        path = "/api/v2/companies/#{companyId}/taxcodes"
        post(path, model)
      end


      # Delete a single tax code
      #
      # Marks the existing TaxCode object at this URL as deleted.
      # @param companyId [Integer] The ID of the company that owns this tax code.
      # @param id [Integer] The ID of the tax code you wish to delete.
      # @return [ErrorDetail[]]
      def delete_tax_code(companyId, id)
        path = "/api/v2/companies/#{companyId}/taxcodes/#{id}"
        delete(path)
      end


      # Retrieve a single tax code
      #
      # Get the taxcode object identified by this URL.
      # A 'TaxCode' represents a uniquely identified type of product, good, or service.
      # Avalara supports correct tax rates and taxability rules for all TaxCodes in all supported jurisdictions.
      # If you identify your products by tax code in your 'Create Transacion' API calls, Avalara will correctly calculate tax rates and
      # taxability rules for this product in all supported jurisdictions.
      # @param companyId [Integer] The ID of the company that owns this tax code
      # @param id [Integer] The primary key of this tax code
      # @return [Object]
      def get_tax_code(companyId, id)
        path = "/api/v2/companies/#{companyId}/taxcodes/#{id}"
        get(path)
      end


      # Retrieve tax codes for this company
      #
      # List all taxcode objects attached to this company.
      # A 'TaxCode' represents a uniquely identified type of product, good, or service.
      # Avalara supports correct tax rates and taxability rules for all TaxCodes in all supported jurisdictions.
      # If you identify your products by tax code in your 'Create Transacion' API calls, Avalara will correctly calculate tax rates and
      # taxability rules for this product in all supported jurisdictions.
      #
      # Search for specific objects using the criteria in the `$filter` parameter; full documentation is available on [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) .
      # Paginate your results using the `$top`, `$skip`, and `$orderby` parameters.
      # @param companyId [Integer] The ID of the company that owns these tax codes
      # @param filter [String] A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) .
      # @param include [String] A comma separated list of additional data to retrieve.
      # @param top [Integer] If nonzero, return no more than this number of results. Used with `$skip` to provide pagination for large datasets. Unless otherwise specified, the maximum number of records that can be returned from an API call is 1,000 records.
      # @param skip [Integer] If nonzero, skip this number of results before returning data. Used with `$top` to provide pagination for large datasets.
      # @param orderBy [String] A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`.
      # @return [FetchResult]
      def list_tax_codes_by_company(companyId, options={})
        path = "/api/v2/companies/#{companyId}/taxcodes"
        get(path, options)
      end


      # Retrieve all tax codes
      #
      # Get multiple taxcode objects across all companies.
      # A 'TaxCode' represents a uniquely identified type of product, good, or service.
      # Avalara supports correct tax rates and taxability rules for all TaxCodes in all supported jurisdictions.
      # If you identify your products by tax code in your 'Create Transacion' API calls, Avalara will correctly calculate tax rates and
      # taxability rules for this product in all supported jurisdictions.
      #
      # Search for specific objects using the criteria in the `$filter` parameter; full documentation is available on [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) .
      # Paginate your results using the `$top`, `$skip`, and `$orderby` parameters.
      # @param filter [String] A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) .
      # @param include [String] A comma separated list of additional data to retrieve.
      # @param top [Integer] If nonzero, return no more than this number of results. Used with `$skip` to provide pagination for large datasets. Unless otherwise specified, the maximum number of records that can be returned from an API call is 1,000 records.
      # @param skip [Integer] If nonzero, skip this number of results before returning data. Used with `$top` to provide pagination for large datasets.
      # @param orderBy [String] A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`.
      # @return [FetchResult]
      def query_tax_codes(options={})
        path = "/api/v2/taxcodes"
        get(path, options)
      end


      # Update a single tax code
      #
      # Replace the existing taxcode object at this URL with an updated object.
      # A 'TaxCode' represents a uniquely identified type of product, good, or service.
      # Avalara supports correct tax rates and taxability rules for all TaxCodes in all supported jurisdictions.
      # If you identify your products by tax code in your 'Create Transacion' API calls, Avalara will correctly calculate tax rates and
      # taxability rules for this product in all supported jurisdictions.
      # All data from the existing object will be replaced with data in the object you PUT.
      # To set a field's value to null, you may either set its value to null or omit that field from the object you post.
      # @param companyId [Integer] The ID of the company that this tax code belongs to.
      # @param id [Integer] The ID of the tax code you wish to update
      # @param model [Object] The tax code you wish to update.
      # @return [Object]
      def update_tax_code(companyId, id, model)
        path = "/api/v2/companies/#{companyId}/taxcodes/#{id}"
        put(path, model)
      end

    end
  end
end