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.
226 227 228 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 226 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.
151 152 153 154 155 156 157 158 159 160 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 151 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.
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 100 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.
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 174 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.
List top-ups
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 75 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.
List top-ups by external ID
210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 210 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 |