Class: Orb::Resources::Customers::Credits::TopUps
- Inherits:
-
Object
- Object
- Orb::Resources::Customers::Credits::TopUps
- Defined in:
- lib/orb/resources/customers/credits/top_ups.rb
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.
222 223 224 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 222 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.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 44 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.
148 149 150 151 152 153 154 155 156 157 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 148 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.
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 97 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.
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 171 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
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 73 def list(customer_id, params = {}) parsed, = Orb::Customers::Credits::TopUpListParams.dump_request(params) @client.request( method: :get, path: ["customers/%1$s/credits/top_ups", customer_id], query: parsed, 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
207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/orb/resources/customers/credits/top_ups.rb', line 207 def list_by_external_id(external_customer_id, params = {}) parsed, = Orb::Customers::Credits::TopUpListByExternalIDParams.dump_request(params) @client.request( method: :get, path: ["customers/external_customer_id/%1$s/credits/top_ups", external_customer_id], query: parsed, page: Orb::Internal::Page, model: Orb::Models::Customers::Credits::TopUpListByExternalIDResponse, options: ) end |