Class: Billingrails::Resources::Subscriptions
- Inherits:
-
Object
- Object
- Billingrails::Resources::Subscriptions
- Defined in:
- lib/billingrails/resources/subscriptions.rb
Overview
Subscriptions resource
Instance Method Summary collapse
-
#cancel(id, data) ⇒ Hash
Cancel a subscription.
-
#create(data) ⇒ Hash
Create a subscription.
-
#get_entitlements(id, params: nil) ⇒ Hash
Get entitlements.
-
#initialize(client) ⇒ Subscriptions
constructor
A new instance of Subscriptions.
-
#list(params: nil) ⇒ Hash
List subscriptions.
-
#resume(id, data) ⇒ Hash
Resume a paused subscription.
-
#retrieve(id, params: nil) ⇒ Hash
Retrieve subscription.
-
#update(id, data) ⇒ Hash
Update a subscription.
Constructor Details
#initialize(client) ⇒ Subscriptions
Returns a new instance of Subscriptions.
10 11 12 |
# File 'lib/billingrails/resources/subscriptions.rb', line 10 def initialize(client) @client = client end |
Instance Method Details
#cancel(id, data) ⇒ Hash
Cancel a subscription
Cancels an active subscription.
67 68 69 70 |
# File 'lib/billingrails/resources/subscriptions.rb', line 67 def cancel(id, data) path = "/subscriptions/#{id}/cancel" @client.request(:post, path, body: data) end |
#create(data) ⇒ Hash
Create a subscription
Creates a subscription.
31 32 33 34 |
# File 'lib/billingrails/resources/subscriptions.rb', line 31 def create(data) path = "/subscriptions" @client.request(:post, path, body: data) end |
#get_entitlements(id, params: nil) ⇒ Hash
Get entitlements
Retrieves entitlements for a subscription grouped by benefit code.
79 80 81 82 |
# File 'lib/billingrails/resources/subscriptions.rb', line 79 def get_entitlements(id, params: nil) path = "/subscriptions/#{id}/entitlements" @client.request(:get, path, params: params) end |
#list(params: nil) ⇒ Hash
List subscriptions
Retrieves a list of subscriptions.
20 21 22 23 |
# File 'lib/billingrails/resources/subscriptions.rb', line 20 def list(params: nil) path = "/subscriptions" @client.request(:get, path, params: params) end |
#resume(id, data) ⇒ Hash
Resume a paused subscription
Creates a subscription resumption checkout session, triggers payment, and returns the payment link. The subscription must be paused. Requires an active payment integration (biller payment routes or an active integration). The customer is redirected to the payment link to pay the resumption invoice; after payment the subscription becomes active again.
91 92 93 94 |
# File 'lib/billingrails/resources/subscriptions.rb', line 91 def resume(id, data) path = "/subscriptions/#{id}/resume" @client.request(:post, path, body: data) end |
#retrieve(id, params: nil) ⇒ Hash
Retrieve subscription
Retrieves a subscription by ID.
43 44 45 46 |
# File 'lib/billingrails/resources/subscriptions.rb', line 43 def retrieve(id, params: nil) path = "/subscriptions/#{id}" @client.request(:get, path, params: params) end |
#update(id, data) ⇒ Hash
Update a subscription
Updates a subscription.
55 56 57 58 |
# File 'lib/billingrails/resources/subscriptions.rb', line 55 def update(id, data) path = "/subscriptions/#{id}" @client.request(:patch, path, body: data) end |