Module: Invoicexpress::Client::Taxes

Included in:
Invoicexpress::Client
Defined in:
lib/invoicexpress/client/taxes.rb

Instance Method Summary collapse

Instance Method Details

#create_tax(tax, options = {}) ⇒ Object

Creates a tax.

Parameters:

Returns:

  • Invoicexpress::Models::Tax The tax created

Raises:

  • Invoicexpress::Unauthorized When the client is unauthorized

  • Invoicexpress::UnprocessableEntity When there are errors on the submission



33
34
35
36
37
38
# File 'lib/invoicexpress/client/taxes.rb', line 33

def create_tax(tax, options={})
  raise(ArgumentError, "tax has the wrong type") unless tax.is_a?(Invoicexpress::Models::Tax)

  params = { :klass => Invoicexpress::Models::Tax, :body => tax }
  post("taxes.xml", params.merge(options))
end

#delete_tax(tax, options = {}) ⇒ Object

Deletes a tax.

Parameters:

Raises:

  • Invoicexpress::Unauthorized When the client is unauthorized

  • Invoicexpress::NotFound When the tax doesn’t exist



61
62
63
64
65
# File 'lib/invoicexpress/client/taxes.rb', line 61

def delete_tax(tax, options={})
  params = { :klass => Invoicexpress::Models::Tax }

  delete("taxes/#{id_from_tax(tax)}.xml", params.merge(options))
end

#tax(tax, options = {}) ⇒ Object

Returns a specific tax.

Parameters:

Returns:

  • Invoicexpress::Models::Tax The tax

Raises:

  • Invoicexpress::Unauthorized When the client is unauthorized

  • Invoicexpress::NotFound When the tax doesn’t exist



21
22
23
24
25
# File 'lib/invoicexpress/client/taxes.rb', line 21

def tax(tax, options={})
  params = { :klass => Invoicexpress::Models::Tax }

  get("taxes/#{id_from_tax(tax)}.xml", params.merge(options))
end

#taxes(options = {}) ⇒ Array<Invoicexpress::Models::Tax>

Returns all your taxes (lol)

Returns:

Raises:

  • Invoicexpress::Unauthorized When the client is unauthorized



9
10
11
12
13
# File 'lib/invoicexpress/client/taxes.rb', line 9

def taxes(options = {})
  params = { :klass => Invoicexpress::Models::Tax }

  get("taxes.xml", params.merge(options))
end

#update_tax(tax, options = {}) ⇒ Object

Updates a tax.

Parameters:

Raises:

  • Invoicexpress::Unauthorized When the client is unauthorized

  • Invoicexpress::NotFound When the tax doesn’t exist

  • Invoicexpress::UnprocessableEntity When there are errors on the submission



46
47
48
49
50
51
52
53
54
# File 'lib/invoicexpress/client/taxes.rb', line 46

def update_tax(tax, options={})
  raise(ArgumentError, "tax has the wrong type") unless tax.is_a?(Invoicexpress::Models::Tax)

  if !tax.id
    raise ArgumentError, "Tax ID is required"
  end
  params = { :klass => Invoicexpress::Models::Tax, :body => tax }
  put("taxes/#{tax.id}.xml", params.merge(options))
end