Class: Orb::Resources::Customers::BalanceTransactions
- Inherits:
-
Object
- Object
- Orb::Resources::Customers::BalanceTransactions
- Defined in:
- lib/orb/resources/customers/balance_transactions.rb
Instance Method Summary collapse
-
#create(customer_id, amount: , type: , description: nil, request_options: {}) ⇒ Orb::Models::Customers::BalanceTransactionCreateResponse
Creates an immutable balance transaction that updates the customer’s balance and returns back the newly created transaction.
-
#initialize(client:) ⇒ BalanceTransactions
constructor
private
A new instance of BalanceTransactions.
-
#list(customer_id, cursor: nil, limit: nil, operation_time_gt: nil, operation_time_gte: nil, operation_time_lt: nil, operation_time_lte: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::Customers::BalanceTransactionListResponse>
Some parameter documentations has been truncated, see Models::Customers::BalanceTransactionListParams for more details.
Constructor Details
#initialize(client:) ⇒ BalanceTransactions
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 BalanceTransactions.
102 103 104 |
# File 'lib/orb/resources/customers/balance_transactions.rb', line 102 def initialize(client:) @client = client end |
Instance Method Details
#create(customer_id, amount: , type: , description: nil, request_options: {}) ⇒ Orb::Models::Customers::BalanceTransactionCreateResponse
Creates an immutable balance transaction that updates the customer’s balance and returns back the newly created transaction.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/orb/resources/customers/balance_transactions.rb', line 25 def create(customer_id, params) parsed, = Orb::Customers::BalanceTransactionCreateParams.dump_request(params) @client.request( method: :post, path: ["customers/%1$s/balance_transactions", customer_id], body: parsed, model: Orb::Models::Customers::BalanceTransactionCreateResponse, options: ) end |
#list(customer_id, cursor: nil, limit: nil, operation_time_gt: nil, operation_time_gte: nil, operation_time_lt: nil, operation_time_lte: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::Customers::BalanceTransactionListResponse>
Some parameter documentations has been truncated, see Models::Customers::BalanceTransactionListParams for more details.
## The customer balance
The customer balance is an amount in the customer’s currency, which Orb automatically applies to subsequent invoices. This balance can be adjusted manually via Orb’s webapp on the customer details page. You can use this balance to provide a fixed mid-period credit to the customer. Commonly, this is done due to system downtime/SLA violation, or an adhoc adjustment discussed with the customer.
If the balance is a positive value at the time of invoicing, it represents that the customer has credit that should be used to offset the amount due on the next issued invoice. In this case, Orb will automatically reduce the next invoice by the balance amount, and roll over any remaining balance if the invoice is fully discounted.
If the balance is a negative value at the time of invoicing, Orb will increase the invoice’s amount due with a positive adjustment, and reset the balance to 0.
This endpoint retrieves all customer balance transactions in reverse chronological order for a single customer, providing a complete audit trail of all adjustments and invoice applications.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/orb/resources/customers/balance_transactions.rb', line 82 def list(customer_id, params = {}) parsed, = Orb::Customers::BalanceTransactionListParams.dump_request(params) @client.request( method: :get, path: ["customers/%1$s/balance_transactions", customer_id], query: parsed.transform_keys( operation_time_gt: "operation_time[gt]", operation_time_gte: "operation_time[gte]", operation_time_lt: "operation_time[lt]", operation_time_lte: "operation_time[lte]" ), page: Orb::Internal::Page, model: Orb::Models::Customers::BalanceTransactionListResponse, options: ) end |