Class: Orb::Resources::Customers::Credits::TopUps
- Inherits:
-
Object
- Object
- Orb::Resources::Customers::Credits::TopUps
- Defined in:
- lib/orb/resources/customers/credits/top_ups.rb,
sig/orb/resources/customers/credits/top_ups.rbs
Overview
The Credit Ledger Entry resource models prepaid credits within Orb.
Instance Method Summary collapse
-
#create(customer_id, amount:, currency:, invoice_settings:, per_unit_cost_basis:, threshold:, active_from: nil, expires_after: nil, expires_after_unit: nil, request_options: {}) ⇒ Orb::Models::Customers::Credits::TopUpCreateResponse
Some parameter documentations has been truncated, see Models::Customers::Credits::TopUpCreateParams for more details.
-
#create_by_external_id(external_customer_id, amount:, currency:, invoice_settings:, per_unit_cost_basis:, threshold:, active_from: nil, expires_after: nil, expires_after_unit: nil, request_options: {}) ⇒ Orb::Models::Customers::Credits::TopUpCreateByExternalIDResponse
Some parameter documentations has been truncated, see Models::Customers::Credits::TopUpCreateByExternalIDParams for more details.
-
#delete(top_up_id, customer_id:, request_options: {}) ⇒ nil
This deactivates the top-up and voids any invoices associated with pending credit blocks purchased through the top-up.
-
#delete_by_external_id(top_up_id, external_customer_id:, request_options: {}) ⇒ nil
This deactivates the top-up and voids any invoices associated with pending credit blocks purchased through the top-up.
-
#initialize(client:) ⇒ TopUps
constructor
private
A new instance of TopUps.
-
#list(customer_id, cursor: nil, limit: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::Customers::Credits::TopUpListResponse>
Some parameter documentations has been truncated, see Models::Customers::Credits::TopUpListParams for more details.
-
#list_by_external_id(external_customer_id, cursor: nil, limit: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::Customers::Credits::TopUpListByExternalIDResponse>
Some parameter documentations has been truncated, see Models::Customers::Credits::TopUpListByExternalIDParams for more details.
Constructor Details
#initialize(client:) ⇒ TopUps
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of TopUps.
238 239 240 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 238 def initialize(client:) @client = client end |
Instance Method Details
#create(customer_id, amount:, currency:, invoice_settings:, per_unit_cost_basis:, threshold:, active_from: nil, expires_after: nil, expires_after_unit: nil, request_options: {}) ⇒ Orb::Models::Customers::Credits::TopUpCreateResponse
Some parameter documentations has been truncated, see Models::Customers::Credits::TopUpCreateParams for more details.
This endpoint allows you to create a new top-up for a specified customer's balance. While this top-up is active, the customer's balance will added in increments of the specified amount whenever the balance reaches the specified threshold.
If a top-up already exists for this customer in the same currency, the existing top-up will be replaced.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 46 def create(customer_id, params) parsed, = Orb::Customers::Credits::TopUpCreateParams.dump_request(params) @client.request( method: :post, path: ["customers/%1$s/credits/top_ups", customer_id], body: parsed, model: Orb::Models::Customers::Credits::TopUpCreateResponse, options: ) end |
#create_by_external_id(external_customer_id, amount:, currency:, invoice_settings:, per_unit_cost_basis:, threshold:, active_from: nil, expires_after: nil, expires_after_unit: nil, request_options: {}) ⇒ Orb::Models::Customers::Credits::TopUpCreateByExternalIDResponse
Some parameter documentations has been truncated, see Models::Customers::Credits::TopUpCreateByExternalIDParams for more details.
This endpoint allows you to create a new top-up for a specified customer's balance. While this top-up is active, the customer's balance will added in increments of the specified amount whenever the balance reaches the specified threshold.
If a top-up already exists for this customer in the same currency, the existing top-up will be replaced.
157 158 159 160 161 162 163 164 165 166 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 157 def create_by_external_id(external_customer_id, params) parsed, = Orb::Customers::Credits::TopUpCreateByExternalIDParams.dump_request(params) @client.request( method: :post, path: ["customers/external_customer_id/%1$s/credits/top_ups", external_customer_id], body: parsed, model: Orb::Models::Customers::Credits::TopUpCreateByExternalIDResponse, options: ) end |
#delete(top_up_id, customer_id:, request_options: {}) ⇒ nil
This deactivates the top-up and voids any invoices associated with pending credit blocks purchased through the top-up.
106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 106 def delete(top_up_id, params) parsed, = Orb::Customers::Credits::TopUpDeleteParams.dump_request(params) customer_id = parsed.delete(:customer_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :delete, path: ["customers/%1$s/credits/top_ups/%2$s", customer_id, top_up_id], model: NilClass, options: ) end |
#delete_by_external_id(top_up_id, external_customer_id:, request_options: {}) ⇒ nil
This deactivates the top-up and voids any invoices associated with pending credit blocks purchased through the top-up.
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 180 def delete_by_external_id(top_up_id, params) parsed, = Orb::Customers::Credits::TopUpDeleteByExternalIDParams.dump_request(params) external_customer_id = parsed.delete(:external_customer_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :delete, path: [ "customers/external_customer_id/%1$s/credits/top_ups/%2$s", external_customer_id, top_up_id ], model: NilClass, options: ) end |
#list(customer_id, cursor: nil, limit: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::Customers::Credits::TopUpListResponse>
Some parameter documentations has been truncated, see Models::Customers::Credits::TopUpListParams for more details.
This endpoint returns a list of a customer's active top-ups; a top-up that has been deactivated is not included. While a top-up is active, the customer's balance is increased by the top-up amount whenever it falls to the top-up's threshold.
The response also includes pagination_metadata, which lets the caller retrieve the next page of results if they exist.
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 81 def list(customer_id, params = {}) parsed, = Orb::Customers::Credits::TopUpListParams.dump_request(params) query = Orb::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["customers/%1$s/credits/top_ups", customer_id], query: query, page: Orb::Internal::Page, model: Orb::Models::Customers::Credits::TopUpListResponse, options: ) end |
#list_by_external_id(external_customer_id, cursor: nil, limit: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::Customers::Credits::TopUpListByExternalIDResponse>
Some parameter documentations has been truncated, see Models::Customers::Credits::TopUpListByExternalIDParams for more details.
This endpoint returns a list of a customer's active top-ups; a top-up that has been deactivated is not included. While a top-up is active, the customer's balance is increased by the top-up amount whenever it falls to the top-up's threshold.
The response also includes pagination_metadata, which lets the caller retrieve the next page of results if they exist.
222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 222 def list_by_external_id(external_customer_id, params = {}) parsed, = Orb::Customers::Credits::TopUpListByExternalIDParams.dump_request(params) query = Orb::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["customers/external_customer_id/%1$s/credits/top_ups", external_customer_id], query: query, page: Orb::Internal::Page, model: Orb::Models::Customers::Credits::TopUpListByExternalIDResponse, options: ) end |