Class: Lago::Api::Resources::Plan
- Inherits:
-
Base
- Object
- Base
- Lago::Api::Resources::Plan
show all
- Defined in:
- lib/lago/api/resources/plan.rb
Instance Attribute Summary
Attributes inherited from Base
#client
Instance Method Summary
collapse
Methods inherited from Base
#create, #destroy, #get, #get_all, #initialize, #update
Instance Method Details
#api_resource ⇒ Object
7
8
9
|
# File 'lib/lago/api/resources/plan.rb', line 7
def api_resource
'plans'
end
|
#root_name ⇒ Object
11
12
13
|
# File 'lib/lago/api/resources/plan.rb', line 11
def root_name
'plan'
end
|
#whitelist_charges(charges) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/lago/api/resources/plan.rb', line 35
def whitelist_charges(charges)
processed_charges = []
charges.each do |c|
result = (c || {}).slice(:id, :billable_metric_id, :amount_currency, :charge_model, :properties)
processed_charges << result unless result.empty?
end
processed_charges
end
|
#whitelist_params(params) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/lago/api/resources/plan.rb', line 15
def whitelist_params(params)
result_hash = {
name: params[:name],
code: params[:code],
interval: params[:interval],
description: params[:description],
amount_cents: params[:amount_cents],
amount_currency: params[:amount_currency],
trial_period: params[:trial_period],
pay_in_advance: params[:pay_in_advance],
bill_charges_monthly: params[:bill_charges_monthly]
}.compact
whitelist_charges(params[:charges]).tap do |charges|
result_hash[:charges] = charges unless charges.empty?
end
{ root_name => result_hash }
end
|