Class: Airwallex::BillingSubscription
- Inherits:
-
APIResource
- Object
- APIResource
- Airwallex::BillingSubscription
- Extended by:
- APIOperations::Create, APIOperations::List, APIOperations::Retrieve
- Includes:
- APIOperations::Update
- Defined in:
- lib/airwallex/resources/billing_subscription.rb
Overview
Represents a Billing subscription, e.g. a multi-part instalment plan.
Instance Attribute Summary
Attributes inherited from APIResource
Class Method Summary collapse
-
.resource_path ⇒ String
API resource path for billing subscriptions.
Instance Method Summary collapse
-
#cancel(params = {}) ⇒ BillingSubscription
Cancel this subscription.
-
#item(item_id) ⇒ BillingSubscriptionItem
Retrieve a single line item on this subscription.
-
#items(params = {}) ⇒ ListObject<BillingSubscriptionItem>
List the line items on this subscription.
Methods included from APIOperations::Create
Methods included from APIOperations::Retrieve
Methods included from APIOperations::List
Methods included from APIOperations::Update
Methods inherited from APIResource
#changed_attributes, #dirty?, #initialize, #inspect, #method_missing, #refresh, #refresh_from, resource_name, #respond_to_missing?, #to_hash, #to_json, #to_s
Constructor Details
This class inherits a constructor from Airwallex::APIResource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Airwallex::APIResource
Class Method Details
.resource_path ⇒ String
Returns API resource path for billing subscriptions.
34 35 36 |
# File 'lib/airwallex/resources/billing_subscription.rb', line 34 def self.resource_path "/api/v1/billing/subscriptions" end |
Instance Method Details
#cancel(params = {}) ⇒ BillingSubscription
Cancel this subscription
42 43 44 45 46 |
# File 'lib/airwallex/resources/billing_subscription.rb', line 42 def cancel(params = {}) response = Airwallex.client.post("#{self.class.resource_path}/#{id}/cancel", params) refresh_from(response) self end |
#item(item_id) ⇒ BillingSubscriptionItem
Retrieve a single line item on this subscription
68 69 70 71 |
# File 'lib/airwallex/resources/billing_subscription.rb', line 68 def item(item_id) response = Airwallex.client.get("#{self.class.resource_path}/#{id}/items/#{item_id}") BillingSubscriptionItem.new(response) end |
#items(params = {}) ⇒ ListObject<BillingSubscriptionItem>
List the line items on this subscription
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/airwallex/resources/billing_subscription.rb', line 52 def items(params = {}) response = Airwallex.client.get("#{self.class.resource_path}/#{id}/items", params) ListObject.new( data: extract_item_rows(response), has_more: extract_has_more(response), next_cursor: extract_next_cursor(response), resource_class: BillingSubscriptionItem, params: params ) end |