Class: Lago::Api::Resources::AppliedTax
- Inherits:
-
Base
- Object
- Base
- Lago::Api::Resources::AppliedTax
show all
- Defined in:
- lib/lago/api/resources/applied_tax.rb
Instance Attribute Summary
Attributes inherited from Base
#client
Instance Method Summary
collapse
Methods inherited from Base
#get, #get_all, #initialize, #update
Instance Method Details
#api_resource ⇒ Object
7
8
9
|
# File 'lib/lago/api/resources/applied_tax.rb', line 7
def api_resource
'applied_tax'
end
|
#create(external_customer_id, params) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/lago/api/resources/applied_tax.rb', line 15
def create(external_customer_id, params)
path = "/api/v1/customers/#{external_customer_id}/applied_taxes"
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_code) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/lago/api/resources/applied_tax.rb', line 23
def destroy(external_customer_id, tax_code)
path = "/api/v1/customers/#{external_customer_id}/applied_taxes"
response = connection.destroy(path, identifier: tax_code)[root_name]
JSON.parse(response.to_json, object_class: OpenStruct)
end
|
#root_name ⇒ Object
11
12
13
|
# File 'lib/lago/api/resources/applied_tax.rb', line 11
def root_name
'applied_tax'
end
|
#whitelist_params(params) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/lago/api/resources/applied_tax.rb', line 30
def whitelist_params(params)
{
root_name => {
tax_code: params[:tax_code],
}.compact,
}
end
|