Class: Lago::Api::Resources::AppliedTaxRate

Inherits:
Base
  • Object
show all
Defined in:
lib/lago/api/resources/applied_tax_rate.rb

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#get, #get_all, #initialize, #update

Constructor Details

This class inherits a constructor from Lago::Api::Resources::Base

Instance Method Details

#api_resourceObject



7
8
9
# File 'lib/lago/api/resources/applied_tax_rate.rb', line 7

def api_resource
  'applied_tax_rates'
end

#create(external_customer_id, params) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/lago/api/resources/applied_tax_rate.rb', line 15

def create(external_customer_id, params)
  path = "/api/v1/customers/#{external_customer_id}/applied_tax_rates"
  payload = whitelist_params(params)
  response = connection.post(payload, path)[root_name]
  
  JSON.parse(response.to_json, object_class: OpenStruct)
end

#destroy(external_customer_id, tax_rate_code) ⇒ Object



23
24
25
26
27
28
# File 'lib/lago/api/resources/applied_tax_rate.rb', line 23

def destroy(external_customer_id, tax_rate_code)
  path = "/api/v1/customers/#{external_customer_id}/applied_tax_rates"
  response = connection.destroy(path, identifier: tax_rate_code)[root_name]

  JSON.parse(response.to_json, object_class: OpenStruct)
end

#root_nameObject



11
12
13
# File 'lib/lago/api/resources/applied_tax_rate.rb', line 11

def root_name
  'applied_tax_rate'
end

#whitelist_params(params) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/lago/api/resources/applied_tax_rate.rb', line 30

def whitelist_params(params)
  {
    root_name => {
      tax_rate_code: params[:tax_rate_code],
    }.compact
  }
end