Class: Sendara::Resources::Billing
Constant Summary
collapse
- PLANS =
%w[starter pro growth scale].freeze
- PERIODS =
%w[month year].freeze
Instance Method Summary
collapse
#initialize
Instance Method Details
#checkout(plan: nil, period: nil) ⇒ Object
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/sendara/resources/billing.rb', line 13
def checkout(plan: nil, period: nil)
plan = plan.to_s unless plan.nil?
period = period.to_s unless period.nil?
raise ArgumentError, "plan must be starter, pro, growth, or scale" if plan && !PLANS.include?(plan)
raise ArgumentError, "period must be month or year" if period && !PERIODS.include?(period)
body = compact_params("plan" => plan, "period" => period)
response = request(:post, "/v1/billing/checkout", body: body) || {}
CheckoutResult.from_response(response)
end
|
#get ⇒ Object
9
10
11
|
# File 'lib/sendara/resources/billing.rb', line 9
def get
request(:get, "/v1/billing") || {}
end
|
#portal ⇒ Object
24
25
26
27
|
# File 'lib/sendara/resources/billing.rb', line 24
def portal
response = request(:post, "/v1/billing/portal") || {}
response["url"].to_s
end
|