Class: Billingrails::Resources::Benefits
- Inherits:
-
Object
- Object
- Billingrails::Resources::Benefits
- Defined in:
- lib/billingrails/resources/benefits.rb
Overview
Benefits resource
Instance Method Summary collapse
-
#archive(id) ⇒ Hash
Archive a benefit.
-
#create(data) ⇒ Hash
Create a benefit.
-
#delete(id) ⇒ Hash
Delete a benefit.
-
#initialize(client) ⇒ Benefits
constructor
A new instance of Benefits.
-
#list(params: nil) ⇒ Hash
List benefits.
-
#retrieve(id, params: nil) ⇒ Hash
Retrieve a benefit.
-
#unarchive(id) ⇒ Hash
Unarchive a benefit.
-
#update(id, data) ⇒ Hash
Update a benefit.
Constructor Details
#initialize(client) ⇒ Benefits
Returns a new instance of Benefits.
10 11 12 |
# File 'lib/billingrails/resources/benefits.rb', line 10 def initialize(client) @client = client end |
Instance Method Details
#archive(id) ⇒ Hash
Archive a benefit
Archives a benefit.
77 78 79 80 |
# File 'lib/billingrails/resources/benefits.rb', line 77 def archive(id) path = "/benefits/#{id}/archive" @client.request(:post, path) end |
#create(data) ⇒ Hash
Create a benefit
Creates a benefit.
31 32 33 34 |
# File 'lib/billingrails/resources/benefits.rb', line 31 def create(data) path = "/benefits" @client.request(:post, path, body: data) end |
#delete(id) ⇒ Hash
Delete a benefit
Deletes a benefit by ID. Allowed only when the benefit is not assigned to any product, price or entitlements.
66 67 68 69 |
# File 'lib/billingrails/resources/benefits.rb', line 66 def delete(id) path = "/benefits/#{id}" @client.request(:delete, path) end |
#list(params: nil) ⇒ Hash
List benefits
Retrieves a list of benefits.
20 21 22 23 |
# File 'lib/billingrails/resources/benefits.rb', line 20 def list(params: nil) path = "/benefits" @client.request(:get, path, params: params) end |
#retrieve(id, params: nil) ⇒ Hash
Retrieve a benefit
Retrieves a benefit by ID.
43 44 45 46 |
# File 'lib/billingrails/resources/benefits.rb', line 43 def retrieve(id, params: nil) path = "/benefits/#{id}" @client.request(:get, path, params: params) end |
#unarchive(id) ⇒ Hash
Unarchive a benefit
Unarchives a benefit.
88 89 90 91 |
# File 'lib/billingrails/resources/benefits.rb', line 88 def unarchive(id) path = "/benefits/#{id}/unarchive" @client.request(:post, path) end |
#update(id, data) ⇒ Hash
Update a benefit
Updates a benefit.
55 56 57 58 |
# File 'lib/billingrails/resources/benefits.rb', line 55 def update(id, data) path = "/benefits/#{id}" @client.request(:patch, path, body: data) end |