orb-billing 0.1.0.pre.alpha.37 → 0.1.0.pre.alpha.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +29 -5
- data/lib/orb/client.rb +4 -0
- data/lib/orb/internal/page.rb +6 -2
- data/lib/orb/internal/transport/base_client.rb +3 -3
- data/lib/orb/internal/transport/pooled_net_requester.rb +2 -2
- data/lib/orb/internal/type/array_of.rb +5 -3
- data/lib/orb/internal/type/base_model.rb +19 -16
- data/lib/orb/internal/type/base_page.rb +4 -1
- data/lib/orb/internal/type/{boolean_model.rb → boolean.rb} +2 -2
- data/lib/orb/internal/type/converter.rb +26 -23
- data/lib/orb/internal/type/enum.rb +10 -8
- data/lib/orb/internal/type/hash_of.rb +3 -1
- data/lib/orb/internal/util.rb +29 -50
- data/lib/orb/models/alert.rb +10 -10
- data/lib/orb/models/alert_create_for_customer_params.rb +3 -3
- data/lib/orb/models/alert_create_for_external_customer_params.rb +3 -3
- data/lib/orb/models/alert_create_for_subscription_params.rb +3 -3
- data/lib/orb/models/alert_list_params.rb +5 -5
- data/lib/orb/models/alert_update_params.rb +3 -3
- data/lib/orb/models/amount_discount.rb +1 -1
- data/lib/orb/models/billable_metric.rb +7 -7
- data/lib/orb/models/coupon.rb +7 -7
- data/lib/orb/models/coupon_create_params.rb +2 -2
- data/lib/orb/models/coupon_list_params.rb +3 -3
- data/lib/orb/models/coupons/subscription_list_params.rb +1 -1
- data/lib/orb/models/credit_note.rb +1 -1
- data/lib/orb/models/credit_note_list_params.rb +5 -5
- data/lib/orb/models/customer.rb +237 -237
- data/lib/orb/models/customer_create_params.rb +229 -229
- data/lib/orb/models/customer_list_params.rb +5 -5
- data/lib/orb/models/customer_update_by_external_id_params.rb +230 -230
- data/lib/orb/models/customer_update_params.rb +230 -230
- data/lib/orb/models/customers/balance_transaction_create_response.rb +2 -2
- data/lib/orb/models/customers/balance_transaction_list_params.rb +5 -5
- data/lib/orb/models/customers/balance_transaction_list_response.rb +2 -2
- data/lib/orb/models/customers/cost_list_by_external_id_params.rb +6 -6
- data/lib/orb/models/customers/cost_list_params.rb +6 -6
- data/lib/orb/models/customers/credit_list_by_external_id_params.rb +3 -3
- data/lib/orb/models/customers/credit_list_params.rb +3 -3
- data/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_params.rb +22 -22
- data/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_response.rb +22 -22
- data/lib/orb/models/customers/credits/ledger_create_entry_params.rb +22 -22
- data/lib/orb/models/customers/credits/ledger_create_entry_response.rb +22 -22
- data/lib/orb/models/customers/credits/ledger_list_by_external_id_params.rb +5 -5
- data/lib/orb/models/customers/credits/ledger_list_by_external_id_response.rb +22 -22
- data/lib/orb/models/customers/credits/ledger_list_params.rb +5 -5
- data/lib/orb/models/customers/credits/ledger_list_response.rb +22 -22
- data/lib/orb/models/customers/credits/top_up_create_by_external_id_params.rb +10 -10
- data/lib/orb/models/customers/credits/top_up_create_by_external_id_response.rb +9 -9
- data/lib/orb/models/customers/credits/top_up_create_params.rb +10 -10
- data/lib/orb/models/customers/credits/top_up_create_response.rb +9 -9
- data/lib/orb/models/customers/credits/top_up_list_by_external_id_params.rb +1 -1
- data/lib/orb/models/customers/credits/top_up_list_by_external_id_response.rb +9 -9
- data/lib/orb/models/customers/credits/top_up_list_params.rb +1 -1
- data/lib/orb/models/customers/credits/top_up_list_response.rb +9 -9
- data/lib/orb/models/dimensional_price_group.rb +7 -7
- data/lib/orb/models/dimensional_price_group_create_params.rb +2 -2
- data/lib/orb/models/dimensional_price_group_list_params.rb +1 -1
- data/lib/orb/models/evaluate_price_group.rb +1 -1
- data/lib/orb/models/event_ingest_params.rb +8 -8
- data/lib/orb/models/event_ingest_response.rb +4 -4
- data/lib/orb/models/event_search_params.rb +5 -5
- data/lib/orb/models/event_search_response.rb +9 -9
- data/lib/orb/models/event_update_params.rb +4 -4
- data/lib/orb/models/events/backfill_close_response.rb +8 -8
- data/lib/orb/models/events/backfill_create_params.rb +12 -12
- data/lib/orb/models/events/backfill_create_response.rb +8 -8
- data/lib/orb/models/events/backfill_fetch_response.rb +8 -8
- data/lib/orb/models/events/backfill_list_params.rb +1 -1
- data/lib/orb/models/events/backfill_list_response.rb +8 -8
- data/lib/orb/models/events/backfill_revert_response.rb +8 -8
- data/lib/orb/models/events/event_volumes.rb +1 -1
- data/lib/orb/models/events/volume_list_params.rb +7 -7
- data/lib/orb/models/invoice.rb +278 -278
- data/lib/orb/models/invoice_create_params.rb +13 -12
- data/lib/orb/models/invoice_fetch_upcoming_response.rb +274 -274
- data/lib/orb/models/invoice_issue_params.rb +5 -5
- data/lib/orb/models/invoice_line_item_create_params.rb +1 -1
- data/lib/orb/models/invoice_line_item_create_response.rb +32 -32
- data/lib/orb/models/invoice_list_params.rb +13 -13
- data/lib/orb/models/invoice_update_params.rb +2 -2
- data/lib/orb/models/item.rb +2 -2
- data/lib/orb/models/item_list_params.rb +1 -1
- data/lib/orb/models/metric_create_params.rb +2 -2
- data/lib/orb/models/metric_list_params.rb +5 -5
- data/lib/orb/models/metric_update_params.rb +2 -2
- data/lib/orb/models/pagination_metadata.rb +1 -1
- data/lib/orb/models/percentage_discount.rb +2 -2
- data/lib/orb/models/plan.rb +40 -40
- data/lib/orb/models/plan_create_params.rb +292 -292
- data/lib/orb/models/plan_list_params.rb +5 -5
- data/lib/orb/models/plan_update_params.rb +4 -4
- data/lib/orb/models/plans/external_plan_id_update_params.rb +4 -4
- data/lib/orb/models/price.rb +186 -186
- data/lib/orb/models/price_create_params.rb +21 -21
- data/lib/orb/models/price_evaluate_params.rb +4 -4
- data/lib/orb/models/price_list_params.rb +1 -1
- data/lib/orb/models/price_update_params.rb +2 -2
- data/lib/orb/models/prices/external_price_id_update_params.rb +2 -2
- data/lib/orb/models/subscription.rb +120 -93
- data/lib/orb/models/subscription_cancel_params.rb +4 -4
- data/lib/orb/models/subscription_cancel_response.rb +156 -78
- data/lib/orb/models/subscription_change_apply_params.rb +33 -0
- data/lib/orb/models/subscription_change_apply_response.rb +1372 -0
- data/lib/orb/models/subscription_change_cancel_params.rb +19 -0
- data/lib/orb/models/subscription_change_cancel_response.rb +1372 -0
- data/lib/orb/models/subscription_change_retrieve_params.rb +19 -0
- data/lib/orb/models/subscription_change_retrieve_response.rb +1372 -0
- data/lib/orb/models/subscription_create_params.rb +705 -705
- data/lib/orb/models/subscription_create_response.rb +156 -78
- data/lib/orb/models/subscription_fetch_costs_params.rb +6 -6
- data/lib/orb/models/subscription_fetch_schedule_params.rb +5 -5
- data/lib/orb/models/subscription_fetch_schedule_response.rb +2 -2
- data/lib/orb/models/subscription_fetch_usage_params.rb +8 -8
- data/lib/orb/models/subscription_list_params.rb +5 -5
- data/lib/orb/models/subscription_price_intervals_params.rb +358 -358
- data/lib/orb/models/subscription_price_intervals_response.rb +158 -78
- data/lib/orb/models/subscription_schedule_plan_change_params.rb +715 -715
- data/lib/orb/models/subscription_schedule_plan_change_response.rb +158 -78
- data/lib/orb/models/subscription_trigger_phase_params.rb +4 -4
- data/lib/orb/models/subscription_trigger_phase_response.rb +158 -78
- data/lib/orb/models/subscription_unschedule_cancellation_response.rb +158 -78
- data/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_response.rb +159 -79
- data/lib/orb/models/subscription_unschedule_pending_plan_changes_response.rb +158 -78
- data/lib/orb/models/subscription_update_fixed_fee_quantity_params.rb +9 -9
- data/lib/orb/models/subscription_update_fixed_fee_quantity_response.rb +158 -78
- data/lib/orb/models/subscription_update_params.rb +11 -11
- data/lib/orb/models/subscription_update_trial_params.rb +4 -4
- data/lib/orb/models/subscription_update_trial_response.rb +158 -78
- data/lib/orb/models/trial_discount.rb +1 -1
- data/lib/orb/models/usage_discount.rb +2 -2
- data/lib/orb/request_options.rb +7 -7
- data/lib/orb/resources/alerts.rb +40 -35
- data/lib/orb/resources/coupons/subscriptions.rb +3 -3
- data/lib/orb/resources/coupons.rb +9 -9
- data/lib/orb/resources/credit_notes.rb +10 -5
- data/lib/orb/resources/customers/balance_transactions.rb +28 -23
- data/lib/orb/resources/customers/costs.rb +232 -232
- data/lib/orb/resources/customers/credits/ledger.rb +348 -338
- data/lib/orb/resources/customers/credits/top_ups.rb +12 -12
- data/lib/orb/resources/customers/credits.rb +8 -8
- data/lib/orb/resources/customers.rb +61 -56
- data/lib/orb/resources/dimensional_price_groups.rb +6 -6
- data/lib/orb/resources/events/backfills.rb +49 -49
- data/lib/orb/resources/events/volume.rb +10 -10
- data/lib/orb/resources/events.rb +295 -295
- data/lib/orb/resources/invoice_line_items.rb +1 -1
- data/lib/orb/resources/invoices.rb +40 -31
- data/lib/orb/resources/items.rb +1 -1
- data/lib/orb/resources/metrics.rb +13 -8
- data/lib/orb/resources/plans/external_plan_id.rb +14 -14
- data/lib/orb/resources/plans.rb +24 -19
- data/lib/orb/resources/prices/external_price_id.rb +4 -4
- data/lib/orb/resources/prices.rb +30 -30
- data/lib/orb/resources/subscription_changes.rb +87 -0
- data/lib/orb/resources/subscriptions.rb +817 -807
- data/lib/orb/resources/top_level.rb +4 -4
- data/lib/orb/version.rb +1 -1
- data/lib/orb.rb +8 -1
- data/rbi/lib/orb/client.rbi +5 -4
- data/rbi/lib/orb/errors.rbi +3 -6
- data/rbi/lib/orb/internal/page.rbi +3 -6
- data/rbi/lib/orb/internal/transport/base_client.rbi +13 -27
- data/rbi/lib/orb/internal/transport/pooled_net_requester.rbi +7 -13
- data/rbi/lib/orb/internal/type/array_of.rbi +10 -18
- data/rbi/lib/orb/internal/type/base_model.rbi +45 -64
- data/rbi/lib/orb/internal/type/base_page.rbi +5 -10
- data/rbi/lib/orb/internal/type/{boolean_model.rbi → boolean.rbi} +5 -9
- data/rbi/lib/orb/internal/type/converter.rbi +25 -31
- data/rbi/lib/orb/internal/type/enum.rbi +14 -20
- data/rbi/lib/orb/internal/type/hash_of.rbi +8 -16
- data/rbi/lib/orb/internal/type/request_parameters.rbi +1 -2
- data/rbi/lib/orb/internal/type/union.rbi +10 -20
- data/rbi/lib/orb/internal/type/unknown.rbi +4 -8
- data/rbi/lib/orb/internal/util.rbi +40 -72
- data/rbi/lib/orb/internal.rbi +1 -1
- data/rbi/lib/orb/models/alert.rbi +21 -33
- data/rbi/lib/orb/models/alert_create_for_customer_params.rbi +8 -13
- data/rbi/lib/orb/models/alert_create_for_external_customer_params.rbi +8 -13
- data/rbi/lib/orb/models/alert_create_for_subscription_params.rbi +8 -13
- data/rbi/lib/orb/models/alert_disable_params.rbi +2 -4
- data/rbi/lib/orb/models/alert_enable_params.rbi +2 -4
- data/rbi/lib/orb/models/alert_list_params.rbi +3 -6
- data/rbi/lib/orb/models/alert_retrieve_params.rbi +2 -4
- data/rbi/lib/orb/models/alert_update_params.rbi +7 -11
- data/rbi/lib/orb/models/amount_discount.rbi +4 -7
- data/rbi/lib/orb/models/billable_metric.rbi +10 -13
- data/rbi/lib/orb/models/billing_cycle_relative_date.rbi +1 -2
- data/rbi/lib/orb/models/coupon.rbi +9 -11
- data/rbi/lib/orb/models/coupon_archive_params.rbi +2 -4
- data/rbi/lib/orb/models/coupon_create_params.rbi +8 -14
- data/rbi/lib/orb/models/coupon_fetch_params.rbi +2 -4
- data/rbi/lib/orb/models/coupon_list_params.rbi +3 -4
- data/rbi/lib/orb/models/coupons/subscription_list_params.rbi +3 -5
- data/rbi/lib/orb/models/credit_note.rbi +22 -45
- data/rbi/lib/orb/models/credit_note_create_params.rbi +5 -10
- data/rbi/lib/orb/models/credit_note_fetch_params.rbi +2 -4
- data/rbi/lib/orb/models/credit_note_list_params.rbi +3 -6
- data/rbi/lib/orb/models/customer.rbi +256 -281
- data/rbi/lib/orb/models/customer_create_params.rbi +251 -276
- data/rbi/lib/orb/models/customer_delete_params.rbi +2 -4
- data/rbi/lib/orb/models/customer_fetch_by_external_id_params.rbi +2 -4
- data/rbi/lib/orb/models/customer_fetch_params.rbi +2 -4
- data/rbi/lib/orb/models/customer_list_params.rbi +3 -6
- data/rbi/lib/orb/models/customer_sync_payment_methods_from_gateway_by_external_customer_id_params.rbi +2 -4
- data/rbi/lib/orb/models/customer_sync_payment_methods_from_gateway_params.rbi +2 -4
- data/rbi/lib/orb/models/customer_update_by_external_id_params.rbi +252 -277
- data/rbi/lib/orb/models/customer_update_params.rbi +252 -277
- data/rbi/lib/orb/models/customers/balance_transaction_create_params.rbi +3 -6
- data/rbi/lib/orb/models/customers/balance_transaction_create_response.rbi +10 -19
- data/rbi/lib/orb/models/customers/balance_transaction_list_params.rbi +3 -6
- data/rbi/lib/orb/models/customers/balance_transaction_list_response.rbi +10 -19
- data/rbi/lib/orb/models/customers/cost_list_by_external_id_params.rbi +8 -10
- data/rbi/lib/orb/models/customers/cost_list_by_external_id_response.rbi +6 -12
- data/rbi/lib/orb/models/customers/cost_list_params.rbi +8 -10
- data/rbi/lib/orb/models/customers/cost_list_response.rbi +6 -12
- data/rbi/lib/orb/models/customers/credit_list_by_external_id_params.rbi +3 -4
- data/rbi/lib/orb/models/customers/credit_list_by_external_id_response.rbi +2 -4
- data/rbi/lib/orb/models/customers/credit_list_params.rbi +3 -4
- data/rbi/lib/orb/models/customers/credit_list_response.rbi +2 -4
- data/rbi/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_params.rbi +26 -33
- data/rbi/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_response.rbi +79 -136
- data/rbi/lib/orb/models/customers/credits/ledger_create_entry_params.rbi +26 -33
- data/rbi/lib/orb/models/customers/credits/ledger_create_entry_response.rbi +78 -135
- data/rbi/lib/orb/models/customers/credits/ledger_list_by_external_id_params.rbi +5 -10
- data/rbi/lib/orb/models/customers/credits/ledger_list_by_external_id_response.rbi +79 -136
- data/rbi/lib/orb/models/customers/credits/ledger_list_params.rbi +5 -10
- data/rbi/lib/orb/models/customers/credits/ledger_list_response.rbi +74 -131
- data/rbi/lib/orb/models/customers/credits/top_up_create_by_external_id_params.rbi +13 -19
- data/rbi/lib/orb/models/customers/credits/top_up_create_by_external_id_response.rbi +12 -18
- data/rbi/lib/orb/models/customers/credits/top_up_create_params.rbi +13 -19
- data/rbi/lib/orb/models/customers/credits/top_up_create_response.rbi +12 -18
- data/rbi/lib/orb/models/customers/credits/top_up_delete_by_external_id_params.rbi +2 -4
- data/rbi/lib/orb/models/customers/credits/top_up_delete_params.rbi +2 -4
- data/rbi/lib/orb/models/customers/credits/top_up_list_by_external_id_params.rbi +3 -5
- data/rbi/lib/orb/models/customers/credits/top_up_list_by_external_id_response.rbi +12 -18
- data/rbi/lib/orb/models/customers/credits/top_up_list_params.rbi +3 -5
- data/rbi/lib/orb/models/customers/credits/top_up_list_response.rbi +12 -18
- data/rbi/lib/orb/models/dimensional_price_group.rbi +8 -9
- data/rbi/lib/orb/models/dimensional_price_group_create_params.rbi +4 -7
- data/rbi/lib/orb/models/dimensional_price_group_list_params.rbi +3 -5
- data/rbi/lib/orb/models/dimensional_price_group_retrieve_params.rbi +2 -4
- data/rbi/lib/orb/models/dimensional_price_groups/external_dimensional_price_group_id_retrieve_params.rbi +2 -4
- data/rbi/lib/orb/models/dimensional_price_groups.rbi +2 -4
- data/rbi/lib/orb/models/discount.rbi +1 -2
- data/rbi/lib/orb/models/evaluate_price_group.rbi +3 -6
- data/rbi/lib/orb/models/event_deprecate_params.rbi +2 -4
- data/rbi/lib/orb/models/event_deprecate_response.rbi +2 -4
- data/rbi/lib/orb/models/event_ingest_params.rbi +10 -13
- data/rbi/lib/orb/models/event_ingest_response.rbi +10 -16
- data/rbi/lib/orb/models/event_search_params.rbi +7 -9
- data/rbi/lib/orb/models/event_search_response.rbi +11 -14
- data/rbi/lib/orb/models/event_update_params.rbi +5 -6
- data/rbi/lib/orb/models/event_update_response.rbi +2 -4
- data/rbi/lib/orb/models/events/backfill_close_params.rbi +2 -4
- data/rbi/lib/orb/models/events/backfill_close_response.rbi +10 -14
- data/rbi/lib/orb/models/events/backfill_create_params.rbi +13 -16
- data/rbi/lib/orb/models/events/backfill_create_response.rbi +10 -14
- data/rbi/lib/orb/models/events/backfill_fetch_params.rbi +2 -4
- data/rbi/lib/orb/models/events/backfill_fetch_response.rbi +10 -14
- data/rbi/lib/orb/models/events/backfill_list_params.rbi +3 -5
- data/rbi/lib/orb/models/events/backfill_list_response.rbi +10 -14
- data/rbi/lib/orb/models/events/backfill_revert_params.rbi +2 -4
- data/rbi/lib/orb/models/events/backfill_revert_response.rbi +10 -14
- data/rbi/lib/orb/models/events/event_volumes.rbi +5 -9
- data/rbi/lib/orb/models/events/volume_list_params.rbi +9 -11
- data/rbi/lib/orb/models/invoice.rbi +388 -465
- data/rbi/lib/orb/models/invoice_create_params.rbi +19 -26
- data/rbi/lib/orb/models/invoice_fetch_params.rbi +2 -4
- data/rbi/lib/orb/models/invoice_fetch_upcoming_params.rbi +2 -4
- data/rbi/lib/orb/models/invoice_fetch_upcoming_response.rbi +381 -460
- data/rbi/lib/orb/models/invoice_issue_params.rbi +6 -8
- data/rbi/lib/orb/models/invoice_level_discount.rbi +1 -2
- data/rbi/lib/orb/models/invoice_line_item_create_params.rbi +3 -5
- data/rbi/lib/orb/models/invoice_line_item_create_response.rbi +101 -143
- data/rbi/lib/orb/models/invoice_list_params.rbi +8 -13
- data/rbi/lib/orb/models/invoice_mark_paid_params.rbi +2 -4
- data/rbi/lib/orb/models/invoice_pay_params.rbi +2 -4
- data/rbi/lib/orb/models/invoice_update_params.rbi +4 -6
- data/rbi/lib/orb/models/invoice_void_params.rbi +2 -4
- data/rbi/lib/orb/models/item.rbi +7 -12
- data/rbi/lib/orb/models/item_create_params.rbi +2 -4
- data/rbi/lib/orb/models/item_fetch_params.rbi +2 -4
- data/rbi/lib/orb/models/item_list_params.rbi +3 -5
- data/rbi/lib/orb/models/item_update_params.rbi +5 -10
- data/rbi/lib/orb/models/metric_create_params.rbi +4 -6
- data/rbi/lib/orb/models/metric_fetch_params.rbi +2 -4
- data/rbi/lib/orb/models/metric_list_params.rbi +3 -6
- data/rbi/lib/orb/models/metric_update_params.rbi +4 -6
- data/rbi/lib/orb/models/pagination_metadata.rbi +2 -4
- data/rbi/lib/orb/models/percentage_discount.rbi +5 -8
- data/rbi/lib/orb/models/plan.rbi +180 -219
- data/rbi/lib/orb/models/plan_create_params.rbi +670 -951
- data/rbi/lib/orb/models/plan_fetch_params.rbi +2 -4
- data/rbi/lib/orb/models/plan_list_params.rbi +4 -8
- data/rbi/lib/orb/models/plan_update_params.rbi +6 -8
- data/rbi/lib/orb/models/plans/external_plan_id_fetch_params.rbi +2 -4
- data/rbi/lib/orb/models/plans/external_plan_id_update_params.rbi +6 -8
- data/rbi/lib/orb/models/price.rbi +827 -1494
- data/rbi/lib/orb/models/price_create_params.rbi +60 -101
- data/rbi/lib/orb/models/price_evaluate_params.rbi +6 -9
- data/rbi/lib/orb/models/price_evaluate_response.rbi +2 -4
- data/rbi/lib/orb/models/price_fetch_params.rbi +2 -4
- data/rbi/lib/orb/models/price_list_params.rbi +3 -5
- data/rbi/lib/orb/models/price_update_params.rbi +4 -6
- data/rbi/lib/orb/models/prices/external_price_id_fetch_params.rbi +2 -4
- data/rbi/lib/orb/models/prices/external_price_id_update_params.rbi +4 -6
- data/rbi/lib/orb/models/subscription.rbi +167 -187
- data/rbi/lib/orb/models/subscription_cancel_params.rbi +5 -7
- data/rbi/lib/orb/models/subscription_cancel_response.rbi +224 -178
- data/rbi/lib/orb/models/subscription_change_apply_params.rbi +40 -0
- data/rbi/lib/orb/models/subscription_change_apply_response.rbi +1554 -0
- data/rbi/lib/orb/models/subscription_change_cancel_params.rbi +18 -0
- data/rbi/lib/orb/models/subscription_change_cancel_response.rbi +1565 -0
- data/rbi/lib/orb/models/subscription_change_retrieve_params.rbi +18 -0
- data/rbi/lib/orb/models/subscription_change_retrieve_response.rbi +1581 -0
- data/rbi/lib/orb/models/subscription_create_params.rbi +1372 -1968
- data/rbi/lib/orb/models/subscription_create_response.rbi +224 -178
- data/rbi/lib/orb/models/subscription_fetch_costs_params.rbi +8 -10
- data/rbi/lib/orb/models/subscription_fetch_costs_response.rbi +6 -12
- data/rbi/lib/orb/models/subscription_fetch_params.rbi +2 -4
- data/rbi/lib/orb/models/subscription_fetch_schedule_params.rbi +3 -6
- data/rbi/lib/orb/models/subscription_fetch_schedule_response.rbi +6 -10
- data/rbi/lib/orb/models/subscription_fetch_usage_params.rbi +12 -17
- data/rbi/lib/orb/models/subscription_list_params.rbi +4 -8
- data/rbi/lib/orb/models/subscription_price_intervals_params.rbi +772 -1124
- data/rbi/lib/orb/models/subscription_price_intervals_response.rbi +228 -178
- data/rbi/lib/orb/models/subscription_schedule_plan_change_params.rbi +1396 -1993
- data/rbi/lib/orb/models/subscription_schedule_plan_change_response.rbi +238 -182
- data/rbi/lib/orb/models/subscription_trigger_phase_params.rbi +5 -7
- data/rbi/lib/orb/models/subscription_trigger_phase_response.rbi +224 -178
- data/rbi/lib/orb/models/subscription_unschedule_cancellation_params.rbi +2 -4
- data/rbi/lib/orb/models/subscription_unschedule_cancellation_response.rbi +238 -182
- data/rbi/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_params.rbi +2 -4
- data/rbi/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_response.rbi +265 -199
- data/rbi/lib/orb/models/subscription_unschedule_pending_plan_changes_params.rbi +2 -4
- data/rbi/lib/orb/models/subscription_unschedule_pending_plan_changes_response.rbi +264 -198
- data/rbi/lib/orb/models/subscription_update_fixed_fee_quantity_params.rbi +11 -15
- data/rbi/lib/orb/models/subscription_update_fixed_fee_quantity_response.rbi +238 -182
- data/rbi/lib/orb/models/subscription_update_params.rbi +12 -15
- data/rbi/lib/orb/models/subscription_update_trial_params.rbi +6 -9
- data/rbi/lib/orb/models/subscription_update_trial_response.rbi +224 -178
- data/rbi/lib/orb/models/subscription_usage.rbi +24 -43
- data/rbi/lib/orb/models/subscriptions.rbi +2 -4
- data/rbi/lib/orb/models/top_level_ping_params.rbi +2 -4
- data/rbi/lib/orb/models/top_level_ping_response.rbi +2 -4
- data/rbi/lib/orb/models/trial_discount.rbi +4 -8
- data/rbi/lib/orb/models/usage_discount.rbi +5 -8
- data/rbi/lib/orb/request_options.rbi +9 -11
- data/rbi/lib/orb/resources/alerts.rbi +44 -60
- data/rbi/lib/orb/resources/coupons/subscriptions.rbi +6 -9
- data/rbi/lib/orb/resources/coupons.rbi +18 -25
- data/rbi/lib/orb/resources/credit_notes.rbi +9 -15
- data/rbi/lib/orb/resources/customers/balance_transactions.rbi +26 -31
- data/rbi/lib/orb/resources/customers/costs.rbi +241 -246
- data/rbi/lib/orb/resources/customers/credits/ledger.rbi +387 -396
- data/rbi/lib/orb/resources/customers/credits/top_ups.rbi +29 -40
- data/rbi/lib/orb/resources/customers/credits.rbi +15 -20
- data/rbi/lib/orb/resources/customers.rbi +407 -417
- data/rbi/lib/orb/resources/dimensional_price_groups/external_dimensional_price_group_id.rbi +2 -4
- data/rbi/lib/orb/resources/dimensional_price_groups.rbi +13 -19
- data/rbi/lib/orb/resources/events/backfills.rbi +61 -69
- data/rbi/lib/orb/resources/events/volume.rbi +19 -22
- data/rbi/lib/orb/resources/events.rbi +311 -319
- data/rbi/lib/orb/resources/invoice_line_items.rbi +4 -7
- data/rbi/lib/orb/resources/invoices.rbi +62 -76
- data/rbi/lib/orb/resources/items.rbi +7 -14
- data/rbi/lib/orb/resources/metrics.rbi +17 -25
- data/rbi/lib/orb/resources/plans/external_plan_id.rbi +21 -25
- data/rbi/lib/orb/resources/plans.rbi +63 -71
- data/rbi/lib/orb/resources/prices/external_price_id.rbi +9 -13
- data/rbi/lib/orb/resources/prices.rbi +77 -87
- data/rbi/lib/orb/resources/subscription_changes.rbi +61 -0
- data/rbi/lib/orb/resources/subscriptions.rbi +933 -963
- data/rbi/lib/orb/resources/top_level.rbi +6 -8
- data/rbi/lib/orb/version.rbi +1 -1
- data/sig/orb/client.rbs +2 -0
- data/sig/orb/internal/type/array_of.rbs +2 -2
- data/sig/orb/internal/type/{boolean_model.rbs → boolean.rbs} +1 -1
- data/sig/orb/internal/util.rbs +5 -5
- data/sig/orb/models/subscription.rbs +14 -0
- data/sig/orb/models/subscription_cancel_response.rbs +47 -2
- data/sig/orb/models/subscription_change_apply_params.rbs +24 -0
- data/sig/orb/models/subscription_change_apply_response.rbs +784 -0
- data/sig/orb/models/subscription_change_cancel_params.rbs +15 -0
- data/sig/orb/models/subscription_change_cancel_response.rbs +784 -0
- data/sig/orb/models/subscription_change_retrieve_params.rbs +15 -0
- data/sig/orb/models/subscription_change_retrieve_response.rbs +784 -0
- data/sig/orb/models/subscription_create_response.rbs +47 -2
- data/sig/orb/models/subscription_price_intervals_response.rbs +47 -2
- data/sig/orb/models/subscription_schedule_plan_change_response.rbs +47 -2
- data/sig/orb/models/subscription_trigger_phase_response.rbs +47 -2
- data/sig/orb/models/subscription_unschedule_cancellation_response.rbs +47 -2
- data/sig/orb/models/subscription_unschedule_fixed_fee_quantity_updates_response.rbs +47 -2
- data/sig/orb/models/subscription_unschedule_pending_plan_changes_response.rbs +47 -2
- data/sig/orb/models/subscription_update_fixed_fee_quantity_response.rbs +47 -2
- data/sig/orb/models/subscription_update_trial_response.rbs +47 -2
- data/sig/orb/resources/customers.rbs +2 -2
- data/sig/orb/resources/subscription_changes.rbs +24 -0
- data/sig/orb/version.rbs +1 -1
- metadata +26 -5
@@ -6,86 +6,86 @@ module Orb
|
|
6
6
|
class Credits
|
7
7
|
class Ledger
|
8
8
|
# The credits ledger provides _auditing_ functionality over Orb's credits system
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
9
|
+
# with a list of actions that have taken place to modify a customer's credit
|
10
|
+
# balance. This [paginated endpoint](/api-reference/pagination) lists these
|
11
|
+
# entries, starting from the most recent ledger entry.
|
12
12
|
#
|
13
|
-
#
|
14
|
-
#
|
13
|
+
# More details on using Orb's real-time credit feature are
|
14
|
+
# [here](/product-catalog/prepurchase).
|
15
15
|
#
|
16
|
-
#
|
16
|
+
# There are four major types of modifications to credit balance, detailed below.
|
17
17
|
#
|
18
|
-
#
|
18
|
+
# ## Increment
|
19
19
|
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
20
|
+
# Credits (which optionally expire on a future date) can be added via the API
|
21
|
+
# ([Add Ledger Entry](create-ledger-entry)). The ledger entry for such an action
|
22
|
+
# will always contain the total eligible starting and ending balance for the
|
23
|
+
# customer at the time the entry was added to the ledger.
|
24
24
|
#
|
25
|
-
#
|
25
|
+
# ## Decrement
|
26
26
|
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
27
|
+
# Deductions can occur as a result of an API call to create a ledger entry (see
|
28
|
+
# [Add Ledger Entry](create-ledger-entry)), or automatically as a result of
|
29
|
+
# incurring usage. Both ledger entries present the `decrement` entry type.
|
30
30
|
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
31
|
+
# As usage for a customer is reported into Orb, credits may be deducted according
|
32
|
+
# to the customer's plan configuration. An automated deduction of this type will
|
33
|
+
# result in a ledger entry, also with a starting and ending balance. In order to
|
34
|
+
# provide better tracing capabilities for automatic deductions, Orb always
|
35
|
+
# associates each automatic deduction with the `event_id` at the time of
|
36
|
+
# ingestion, used to pinpoint _why_ credit deduction took place and to ensure that
|
37
|
+
# credits are never deducted without an associated usage event.
|
38
38
|
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
39
|
+
# By default, Orb uses an algorithm that automatically deducts from the _soonest
|
40
|
+
# expiring credit block_ first in order to ensure that all credits are utilized
|
41
|
+
# appropriately. As an example, if trial credits with an expiration date of 2
|
42
|
+
# weeks from now are present for a customer, they will be used before any
|
43
|
+
# deductions take place from a non-expiring credit block.
|
44
44
|
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
45
|
+
# If there are multiple blocks with the same expiration date, Orb will deduct from
|
46
|
+
# the block with the _lower cost basis_ first (e.g. trial credits with a $0 cost
|
47
|
+
# basis before paid credits with a $5.00 cost basis).
|
48
48
|
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
49
|
+
# It's also possible for a single usage event's deduction to _span_ credit blocks.
|
50
|
+
# In this case, Orb will deduct from the next block, ending at the credit block
|
51
|
+
# which consists of unexpiring credits. Each of these deductions will lead to a
|
52
|
+
# _separate_ ledger entry, one per credit block that is deducted from. By default,
|
53
|
+
# the customer's total credit balance in Orb can be negative as a result of a
|
54
|
+
# decrement.
|
55
55
|
#
|
56
|
-
#
|
56
|
+
# ## Expiration change
|
57
57
|
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
58
|
+
# The expiry of credits can be changed as a result of the API (See
|
59
|
+
# [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that
|
60
|
+
# specifies the balance as well as the initial and target expiry dates.
|
61
61
|
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
62
|
+
# Note that for this entry type, `starting_balance` will equal `ending_balance`,
|
63
|
+
# and the `amount` represents the balance transferred. The credit block linked to
|
64
|
+
# the ledger entry is the source credit block from which there was an expiration
|
65
|
+
# change
|
66
66
|
#
|
67
|
-
#
|
67
|
+
# ## Credits expiry
|
68
68
|
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
69
|
+
# When a set of credits expire on pre-set expiration date, the customer's balance
|
70
|
+
# automatically reflects this change and adds an entry to the ledger indicating
|
71
|
+
# this event. Note that credit expiry should always happen close to a date
|
72
|
+
# boundary in the customer's timezone.
|
73
73
|
#
|
74
|
-
#
|
74
|
+
# ## Void initiated
|
75
75
|
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
76
|
+
# Credit blocks can be voided via the API. The `amount` on this entry corresponds
|
77
|
+
# to the number of credits that were remaining in the block at time of void.
|
78
|
+
# `void_reason` will be populated if the void is created with a reason.
|
79
79
|
#
|
80
|
-
#
|
80
|
+
# ## Void
|
81
81
|
#
|
82
|
-
#
|
83
|
-
#
|
82
|
+
# When a set of credits is voided, the customer's balance automatically reflects
|
83
|
+
# this change and adds an entry to the ledger indicating this event.
|
84
84
|
#
|
85
|
-
#
|
85
|
+
# ## Amendment
|
86
86
|
#
|
87
|
-
#
|
88
|
-
#
|
87
|
+
# When credits are added to a customer's balance as a result of a correction, this
|
88
|
+
# entry will be added to the ledger to indicate the adjustment of credits.
|
89
89
|
sig do
|
90
90
|
params(
|
91
91
|
customer_id: String,
|
@@ -103,15 +103,15 @@ module Orb
|
|
103
103
|
)
|
104
104
|
.returns(
|
105
105
|
Orb::Internal::Page[
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
106
|
+
T.any(
|
107
|
+
Orb::Models::Customers::Credits::LedgerListResponse::IncrementLedgerEntry,
|
108
|
+
Orb::Models::Customers::Credits::LedgerListResponse::DecrementLedgerEntry,
|
109
|
+
Orb::Models::Customers::Credits::LedgerListResponse::ExpirationChangeLedgerEntry,
|
110
|
+
Orb::Models::Customers::Credits::LedgerListResponse::CreditBlockExpiryLedgerEntry,
|
111
|
+
Orb::Models::Customers::Credits::LedgerListResponse::VoidLedgerEntry,
|
112
|
+
Orb::Models::Customers::Credits::LedgerListResponse::VoidInitiatedLedgerEntry,
|
113
|
+
Orb::Models::Customers::Credits::LedgerListResponse::AmendmentLedgerEntry
|
114
|
+
)
|
115
115
|
]
|
116
116
|
)
|
117
117
|
end
|
@@ -124,7 +124,7 @@ module Orb
|
|
124
124
|
# The ledger currency or custom pricing unit to use.
|
125
125
|
currency: nil,
|
126
126
|
# Cursor for pagination. This can be populated by the `next_cursor` value returned
|
127
|
-
#
|
127
|
+
# from the initial request.
|
128
128
|
cursor: nil,
|
129
129
|
entry_status: nil,
|
130
130
|
entry_type: nil,
|
@@ -132,119 +132,117 @@ module Orb
|
|
132
132
|
limit: nil,
|
133
133
|
minimum_amount: nil,
|
134
134
|
request_options: {}
|
135
|
-
)
|
136
|
-
end
|
137
|
-
|
135
|
+
); end
|
138
136
|
# This endpoint allows you to create a new ledger entry for a specified customer's
|
139
|
-
#
|
140
|
-
#
|
141
|
-
#
|
142
|
-
#
|
143
|
-
#
|
144
|
-
#
|
145
|
-
#
|
146
|
-
#
|
147
|
-
#
|
148
|
-
#
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
153
|
-
#
|
154
|
-
#
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
#
|
159
|
-
#
|
160
|
-
#
|
161
|
-
#
|
162
|
-
#
|
163
|
-
#
|
164
|
-
#
|
165
|
-
#
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
172
|
-
#
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
#
|
177
|
-
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
#
|
182
|
-
#
|
183
|
-
#
|
184
|
-
#
|
185
|
-
#
|
186
|
-
#
|
187
|
-
#
|
188
|
-
#
|
189
|
-
#
|
190
|
-
#
|
191
|
-
#
|
192
|
-
#
|
193
|
-
#
|
194
|
-
#
|
195
|
-
#
|
196
|
-
#
|
197
|
-
#
|
198
|
-
#
|
199
|
-
#
|
200
|
-
#
|
201
|
-
#
|
202
|
-
#
|
203
|
-
#
|
204
|
-
#
|
205
|
-
#
|
206
|
-
#
|
207
|
-
#
|
208
|
-
#
|
209
|
-
#
|
210
|
-
#
|
211
|
-
#
|
212
|
-
#
|
213
|
-
#
|
214
|
-
#
|
215
|
-
#
|
216
|
-
#
|
217
|
-
#
|
218
|
-
#
|
219
|
-
#
|
220
|
-
#
|
221
|
-
#
|
222
|
-
#
|
223
|
-
#
|
224
|
-
#
|
225
|
-
#
|
226
|
-
#
|
227
|
-
#
|
228
|
-
#
|
229
|
-
#
|
230
|
-
#
|
231
|
-
#
|
232
|
-
#
|
233
|
-
#
|
234
|
-
#
|
235
|
-
#
|
236
|
-
#
|
237
|
-
#
|
238
|
-
#
|
239
|
-
#
|
240
|
-
#
|
241
|
-
#
|
242
|
-
#
|
243
|
-
#
|
244
|
-
#
|
245
|
-
#
|
246
|
-
#
|
247
|
-
#
|
137
|
+
# balance. This can be used to increment balance, deduct credits, and change the
|
138
|
+
# expiry date of existing credits.
|
139
|
+
#
|
140
|
+
# ## Effects of adding a ledger entry
|
141
|
+
#
|
142
|
+
# 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits)
|
143
|
+
# will return a credit block that represents the changes (i.e. balance changes
|
144
|
+
# or transfers).
|
145
|
+
# 2. A ledger entry will be added to the credits ledger for this customer, and
|
146
|
+
# therefore returned in the
|
147
|
+
# [View Credits Ledger](fetch-customer-credits-ledger) response as well as
|
148
|
+
# serialized in the response to this request. In the case of deductions without
|
149
|
+
# a specified block, multiple ledger entries may be created if the deduction
|
150
|
+
# spans credit blocks.
|
151
|
+
# 3. If `invoice_settings` is specified, an invoice will be created that reflects
|
152
|
+
# the cost of the credits (based on `amount` and `per_unit_cost_basis`).
|
153
|
+
#
|
154
|
+
# ## Adding credits
|
155
|
+
#
|
156
|
+
# Adding credits is done by creating an entry of type `increment`. This requires
|
157
|
+
# the caller to specify a number of credits as well as an optional expiry date in
|
158
|
+
# `YYYY-MM-DD` format. Orb also recommends specifying a description to assist with
|
159
|
+
# auditing. When adding credits, the caller can also specify a cost basis
|
160
|
+
# per-credit, to indicate how much in USD a customer paid for a single credit in a
|
161
|
+
# block. This can later be used for revenue recognition.
|
162
|
+
#
|
163
|
+
# The following snippet illustrates a sample request body to increment credits
|
164
|
+
# which will expire in January of 2022.
|
165
|
+
#
|
166
|
+
# ```json
|
167
|
+
# {
|
168
|
+
# "entry_type": "increment",
|
169
|
+
# "amount": 100,
|
170
|
+
# "expiry_date": "2022-12-28",
|
171
|
+
# "per_unit_cost_basis": "0.20",
|
172
|
+
# "description": "Purchased 100 credits"
|
173
|
+
# }
|
174
|
+
# ```
|
175
|
+
#
|
176
|
+
# Note that by default, Orb will always first increment any _negative_ balance in
|
177
|
+
# existing blocks before adding the remaining amount to the desired credit block.
|
178
|
+
#
|
179
|
+
# ### Invoicing for credits
|
180
|
+
#
|
181
|
+
# By default, Orb manipulates the credit ledger but does not charge for credits.
|
182
|
+
# However, if you pass `invoice_settings` in the body of this request, Orb will
|
183
|
+
# also generate a one-off invoice for the customer for the credits pre-purchase.
|
184
|
+
# Note that you _must_ provide the `per_unit_cost_basis`, since the total charges
|
185
|
+
# on the invoice are calculated by multiplying the cost basis with the number of
|
186
|
+
# credit units added.
|
187
|
+
#
|
188
|
+
# ## Deducting Credits
|
189
|
+
#
|
190
|
+
# Orb allows you to deduct credits from a customer by creating an entry of type
|
191
|
+
# `decrement`. Orb matches the algorithm for automatic deductions for determining
|
192
|
+
# which credit blocks to decrement from. In the case that the deduction leads to
|
193
|
+
# multiple ledger entries, the response from this endpoint will be the final
|
194
|
+
# deduction. Orb also optionally allows specifying a description to assist with
|
195
|
+
# auditing.
|
196
|
+
#
|
197
|
+
# The following snippet illustrates a sample request body to decrement credits.
|
198
|
+
#
|
199
|
+
# ```json
|
200
|
+
# {
|
201
|
+
# "entry_type": "decrement",
|
202
|
+
# "amount": 20,
|
203
|
+
# "description": "Removing excess credits"
|
204
|
+
# }
|
205
|
+
# ```
|
206
|
+
#
|
207
|
+
# ## Changing credits expiry
|
208
|
+
#
|
209
|
+
# If you'd like to change when existing credits expire, you should create a ledger
|
210
|
+
# entry of type `expiration_change`. For this entry, the required parameter
|
211
|
+
# `expiry_date` identifies the _originating_ block, and the required parameter
|
212
|
+
# `target_expiry_date` identifies when the transferred credits should now expire.
|
213
|
+
# A new credit block will be created with expiry date `target_expiry_date`, with
|
214
|
+
# the same cost basis data as the original credit block, if present.
|
215
|
+
#
|
216
|
+
# Note that the balance of the block with the given `expiry_date` must be at least
|
217
|
+
# equal to the desired transfer amount determined by the `amount` parameter.
|
218
|
+
#
|
219
|
+
# The following snippet illustrates a sample request body to extend the expiration
|
220
|
+
# date of credits by one year:
|
221
|
+
#
|
222
|
+
# ```json
|
223
|
+
# {
|
224
|
+
# "entry_type": "expiration_change",
|
225
|
+
# "amount": 10,
|
226
|
+
# "expiry_date": "2022-12-28",
|
227
|
+
# "block_id": "UiUhFWeLHPrBY4Ad",
|
228
|
+
# "target_expiry_date": "2023-12-28",
|
229
|
+
# "description": "Extending credit validity"
|
230
|
+
# }
|
231
|
+
# ```
|
232
|
+
#
|
233
|
+
# ## Voiding credits
|
234
|
+
#
|
235
|
+
# If you'd like to void a credit block, create a ledger entry of type `void`. For
|
236
|
+
# this entry, `block_id` is required to identify the block, and `amount` indicates
|
237
|
+
# how many credits to void, up to the block's initial balance. Pass in a
|
238
|
+
# `void_reason` of `refund` if the void is due to a refund.
|
239
|
+
#
|
240
|
+
# ## Amendment
|
241
|
+
#
|
242
|
+
# If you'd like to undo a decrement on a credit block, create a ledger entry of
|
243
|
+
# type `amendment`. For this entry, `block_id` is required to identify the block
|
244
|
+
# that was originally decremented from, and `amount` indicates how many credits to
|
245
|
+
# return to the customer, up to the block's initial balance.
|
248
246
|
sig do
|
249
247
|
params(
|
250
248
|
customer_id: String,
|
@@ -279,155 +277,153 @@ module Orb
|
|
279
277
|
def create_entry(
|
280
278
|
customer_id,
|
281
279
|
# The number of credits to effect. Note that this is required for increment,
|
282
|
-
#
|
280
|
+
# decrement or void operations.
|
283
281
|
amount:,
|
284
282
|
entry_type:,
|
285
283
|
# An ISO 8601 format date that identifies the origination credit block to expire
|
286
284
|
expiry_date:,
|
287
285
|
# A future date (specified in YYYY-MM-DD format) used for expiration change,
|
288
|
-
#
|
289
|
-
#
|
286
|
+
# denoting when credits transferred (as part of a partial block expiration) should
|
287
|
+
# expire.
|
290
288
|
target_expiry_date:,
|
291
289
|
# The ID of the block to reverse a decrement from.
|
292
290
|
block_id:,
|
293
291
|
# The currency or custom pricing unit to use for this ledger entry. If this is a
|
294
|
-
#
|
292
|
+
# real-world currency, it must match the customer's invoicing currency.
|
295
293
|
currency: nil,
|
296
294
|
# Optional metadata that can be specified when adding ledger results via the API.
|
297
|
-
#
|
298
|
-
#
|
295
|
+
# For example, this can be used to note an increment refers to trial credits, or
|
296
|
+
# for noting corrections as a result of an incident, etc.
|
299
297
|
description: nil,
|
300
298
|
# An ISO 8601 format date that denotes when this credit balance should become
|
301
|
-
#
|
299
|
+
# available for use.
|
302
300
|
effective_date: nil,
|
303
301
|
# Passing `invoice_settings` automatically generates an invoice for the newly
|
304
|
-
#
|
305
|
-
#
|
306
|
-
#
|
302
|
+
# added credits. If `invoice_settings` is passed, you must specify
|
303
|
+
# per_unit_cost_basis, as the calculation of the invoice total is done on that
|
304
|
+
# basis.
|
307
305
|
invoice_settings: nil,
|
308
306
|
# User-specified key/value pairs for the resource. Individual keys can be removed
|
309
|
-
#
|
310
|
-
#
|
307
|
+
# by setting the value to `null`, and the entire metadata mapping can be cleared
|
308
|
+
# by setting `metadata` to `null`.
|
311
309
|
metadata: nil,
|
312
310
|
# Can only be specified when entry_type=increment. How much, in the customer's
|
313
|
-
#
|
311
|
+
# currency, a customer paid for a single credit in this block
|
314
312
|
per_unit_cost_basis: nil,
|
315
313
|
# Can only be specified when `entry_type=void`. The reason for the void.
|
316
314
|
void_reason: nil,
|
317
315
|
request_options: {}
|
318
|
-
)
|
319
|
-
end
|
320
|
-
|
316
|
+
); end
|
321
317
|
# This endpoint allows you to create a new ledger entry for a specified customer's
|
322
|
-
#
|
323
|
-
#
|
324
|
-
#
|
325
|
-
#
|
326
|
-
#
|
327
|
-
#
|
328
|
-
#
|
329
|
-
#
|
330
|
-
#
|
331
|
-
#
|
332
|
-
#
|
333
|
-
#
|
334
|
-
#
|
335
|
-
#
|
336
|
-
#
|
337
|
-
#
|
338
|
-
#
|
339
|
-
#
|
340
|
-
#
|
341
|
-
#
|
342
|
-
#
|
343
|
-
#
|
344
|
-
#
|
345
|
-
#
|
346
|
-
#
|
347
|
-
#
|
348
|
-
#
|
349
|
-
#
|
350
|
-
#
|
351
|
-
#
|
352
|
-
#
|
353
|
-
#
|
354
|
-
#
|
355
|
-
#
|
356
|
-
#
|
357
|
-
#
|
358
|
-
#
|
359
|
-
#
|
360
|
-
#
|
361
|
-
#
|
362
|
-
#
|
363
|
-
#
|
364
|
-
#
|
365
|
-
#
|
366
|
-
#
|
367
|
-
#
|
368
|
-
#
|
369
|
-
#
|
370
|
-
#
|
371
|
-
#
|
372
|
-
#
|
373
|
-
#
|
374
|
-
#
|
375
|
-
#
|
376
|
-
#
|
377
|
-
#
|
378
|
-
#
|
379
|
-
#
|
380
|
-
#
|
381
|
-
#
|
382
|
-
#
|
383
|
-
#
|
384
|
-
#
|
385
|
-
#
|
386
|
-
#
|
387
|
-
#
|
388
|
-
#
|
389
|
-
#
|
390
|
-
#
|
391
|
-
#
|
392
|
-
#
|
393
|
-
#
|
394
|
-
#
|
395
|
-
#
|
396
|
-
#
|
397
|
-
#
|
398
|
-
#
|
399
|
-
#
|
400
|
-
#
|
401
|
-
#
|
402
|
-
#
|
403
|
-
#
|
404
|
-
#
|
405
|
-
#
|
406
|
-
#
|
407
|
-
#
|
408
|
-
#
|
409
|
-
#
|
410
|
-
#
|
411
|
-
#
|
412
|
-
#
|
413
|
-
#
|
414
|
-
#
|
415
|
-
#
|
416
|
-
#
|
417
|
-
#
|
418
|
-
#
|
419
|
-
#
|
420
|
-
#
|
421
|
-
#
|
422
|
-
#
|
423
|
-
#
|
424
|
-
#
|
425
|
-
#
|
426
|
-
#
|
427
|
-
#
|
428
|
-
#
|
429
|
-
#
|
430
|
-
#
|
318
|
+
# balance. This can be used to increment balance, deduct credits, and change the
|
319
|
+
# expiry date of existing credits.
|
320
|
+
#
|
321
|
+
# ## Effects of adding a ledger entry
|
322
|
+
#
|
323
|
+
# 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits)
|
324
|
+
# will return a credit block that represents the changes (i.e. balance changes
|
325
|
+
# or transfers).
|
326
|
+
# 2. A ledger entry will be added to the credits ledger for this customer, and
|
327
|
+
# therefore returned in the
|
328
|
+
# [View Credits Ledger](fetch-customer-credits-ledger) response as well as
|
329
|
+
# serialized in the response to this request. In the case of deductions without
|
330
|
+
# a specified block, multiple ledger entries may be created if the deduction
|
331
|
+
# spans credit blocks.
|
332
|
+
# 3. If `invoice_settings` is specified, an invoice will be created that reflects
|
333
|
+
# the cost of the credits (based on `amount` and `per_unit_cost_basis`).
|
334
|
+
#
|
335
|
+
# ## Adding credits
|
336
|
+
#
|
337
|
+
# Adding credits is done by creating an entry of type `increment`. This requires
|
338
|
+
# the caller to specify a number of credits as well as an optional expiry date in
|
339
|
+
# `YYYY-MM-DD` format. Orb also recommends specifying a description to assist with
|
340
|
+
# auditing. When adding credits, the caller can also specify a cost basis
|
341
|
+
# per-credit, to indicate how much in USD a customer paid for a single credit in a
|
342
|
+
# block. This can later be used for revenue recognition.
|
343
|
+
#
|
344
|
+
# The following snippet illustrates a sample request body to increment credits
|
345
|
+
# which will expire in January of 2022.
|
346
|
+
#
|
347
|
+
# ```json
|
348
|
+
# {
|
349
|
+
# "entry_type": "increment",
|
350
|
+
# "amount": 100,
|
351
|
+
# "expiry_date": "2022-12-28",
|
352
|
+
# "per_unit_cost_basis": "0.20",
|
353
|
+
# "description": "Purchased 100 credits"
|
354
|
+
# }
|
355
|
+
# ```
|
356
|
+
#
|
357
|
+
# Note that by default, Orb will always first increment any _negative_ balance in
|
358
|
+
# existing blocks before adding the remaining amount to the desired credit block.
|
359
|
+
#
|
360
|
+
# ### Invoicing for credits
|
361
|
+
#
|
362
|
+
# By default, Orb manipulates the credit ledger but does not charge for credits.
|
363
|
+
# However, if you pass `invoice_settings` in the body of this request, Orb will
|
364
|
+
# also generate a one-off invoice for the customer for the credits pre-purchase.
|
365
|
+
# Note that you _must_ provide the `per_unit_cost_basis`, since the total charges
|
366
|
+
# on the invoice are calculated by multiplying the cost basis with the number of
|
367
|
+
# credit units added.
|
368
|
+
#
|
369
|
+
# ## Deducting Credits
|
370
|
+
#
|
371
|
+
# Orb allows you to deduct credits from a customer by creating an entry of type
|
372
|
+
# `decrement`. Orb matches the algorithm for automatic deductions for determining
|
373
|
+
# which credit blocks to decrement from. In the case that the deduction leads to
|
374
|
+
# multiple ledger entries, the response from this endpoint will be the final
|
375
|
+
# deduction. Orb also optionally allows specifying a description to assist with
|
376
|
+
# auditing.
|
377
|
+
#
|
378
|
+
# The following snippet illustrates a sample request body to decrement credits.
|
379
|
+
#
|
380
|
+
# ```json
|
381
|
+
# {
|
382
|
+
# "entry_type": "decrement",
|
383
|
+
# "amount": 20,
|
384
|
+
# "description": "Removing excess credits"
|
385
|
+
# }
|
386
|
+
# ```
|
387
|
+
#
|
388
|
+
# ## Changing credits expiry
|
389
|
+
#
|
390
|
+
# If you'd like to change when existing credits expire, you should create a ledger
|
391
|
+
# entry of type `expiration_change`. For this entry, the required parameter
|
392
|
+
# `expiry_date` identifies the _originating_ block, and the required parameter
|
393
|
+
# `target_expiry_date` identifies when the transferred credits should now expire.
|
394
|
+
# A new credit block will be created with expiry date `target_expiry_date`, with
|
395
|
+
# the same cost basis data as the original credit block, if present.
|
396
|
+
#
|
397
|
+
# Note that the balance of the block with the given `expiry_date` must be at least
|
398
|
+
# equal to the desired transfer amount determined by the `amount` parameter.
|
399
|
+
#
|
400
|
+
# The following snippet illustrates a sample request body to extend the expiration
|
401
|
+
# date of credits by one year:
|
402
|
+
#
|
403
|
+
# ```json
|
404
|
+
# {
|
405
|
+
# "entry_type": "expiration_change",
|
406
|
+
# "amount": 10,
|
407
|
+
# "expiry_date": "2022-12-28",
|
408
|
+
# "block_id": "UiUhFWeLHPrBY4Ad",
|
409
|
+
# "target_expiry_date": "2023-12-28",
|
410
|
+
# "description": "Extending credit validity"
|
411
|
+
# }
|
412
|
+
# ```
|
413
|
+
#
|
414
|
+
# ## Voiding credits
|
415
|
+
#
|
416
|
+
# If you'd like to void a credit block, create a ledger entry of type `void`. For
|
417
|
+
# this entry, `block_id` is required to identify the block, and `amount` indicates
|
418
|
+
# how many credits to void, up to the block's initial balance. Pass in a
|
419
|
+
# `void_reason` of `refund` if the void is due to a refund.
|
420
|
+
#
|
421
|
+
# ## Amendment
|
422
|
+
#
|
423
|
+
# If you'd like to undo a decrement on a credit block, create a ledger entry of
|
424
|
+
# type `amendment`. For this entry, `block_id` is required to identify the block
|
425
|
+
# that was originally decremented from, and `amount` indicates how many credits to
|
426
|
+
# return to the customer, up to the block's initial balance.
|
431
427
|
sig do
|
432
428
|
params(
|
433
429
|
external_customer_id: String,
|
@@ -465,126 +461,124 @@ module Orb
|
|
465
461
|
def create_entry_by_external_id(
|
466
462
|
external_customer_id,
|
467
463
|
# The number of credits to effect. Note that this is required for increment,
|
468
|
-
#
|
464
|
+
# decrement or void operations.
|
469
465
|
amount:,
|
470
466
|
entry_type:,
|
471
467
|
# An ISO 8601 format date that identifies the origination credit block to expire
|
472
468
|
expiry_date:,
|
473
469
|
# A future date (specified in YYYY-MM-DD format) used for expiration change,
|
474
|
-
#
|
475
|
-
#
|
470
|
+
# denoting when credits transferred (as part of a partial block expiration) should
|
471
|
+
# expire.
|
476
472
|
target_expiry_date:,
|
477
473
|
# The ID of the block to reverse a decrement from.
|
478
474
|
block_id:,
|
479
475
|
# The currency or custom pricing unit to use for this ledger entry. If this is a
|
480
|
-
#
|
476
|
+
# real-world currency, it must match the customer's invoicing currency.
|
481
477
|
currency: nil,
|
482
478
|
# Optional metadata that can be specified when adding ledger results via the API.
|
483
|
-
#
|
484
|
-
#
|
479
|
+
# For example, this can be used to note an increment refers to trial credits, or
|
480
|
+
# for noting corrections as a result of an incident, etc.
|
485
481
|
description: nil,
|
486
482
|
# An ISO 8601 format date that denotes when this credit balance should become
|
487
|
-
#
|
483
|
+
# available for use.
|
488
484
|
effective_date: nil,
|
489
485
|
# Passing `invoice_settings` automatically generates an invoice for the newly
|
490
|
-
#
|
491
|
-
#
|
492
|
-
#
|
486
|
+
# added credits. If `invoice_settings` is passed, you must specify
|
487
|
+
# per_unit_cost_basis, as the calculation of the invoice total is done on that
|
488
|
+
# basis.
|
493
489
|
invoice_settings: nil,
|
494
490
|
# User-specified key/value pairs for the resource. Individual keys can be removed
|
495
|
-
#
|
496
|
-
#
|
491
|
+
# by setting the value to `null`, and the entire metadata mapping can be cleared
|
492
|
+
# by setting `metadata` to `null`.
|
497
493
|
metadata: nil,
|
498
494
|
# Can only be specified when entry_type=increment. How much, in the customer's
|
499
|
-
#
|
495
|
+
# currency, a customer paid for a single credit in this block
|
500
496
|
per_unit_cost_basis: nil,
|
501
497
|
# Can only be specified when `entry_type=void`. The reason for the void.
|
502
498
|
void_reason: nil,
|
503
499
|
request_options: {}
|
504
|
-
)
|
505
|
-
end
|
506
|
-
|
500
|
+
); end
|
507
501
|
# The credits ledger provides _auditing_ functionality over Orb's credits system
|
508
|
-
#
|
509
|
-
#
|
510
|
-
#
|
502
|
+
# with a list of actions that have taken place to modify a customer's credit
|
503
|
+
# balance. This [paginated endpoint](/api-reference/pagination) lists these
|
504
|
+
# entries, starting from the most recent ledger entry.
|
511
505
|
#
|
512
|
-
#
|
513
|
-
#
|
506
|
+
# More details on using Orb's real-time credit feature are
|
507
|
+
# [here](/product-catalog/prepurchase).
|
514
508
|
#
|
515
|
-
#
|
509
|
+
# There are four major types of modifications to credit balance, detailed below.
|
516
510
|
#
|
517
|
-
#
|
511
|
+
# ## Increment
|
518
512
|
#
|
519
|
-
#
|
520
|
-
#
|
521
|
-
#
|
522
|
-
#
|
513
|
+
# Credits (which optionally expire on a future date) can be added via the API
|
514
|
+
# ([Add Ledger Entry](create-ledger-entry)). The ledger entry for such an action
|
515
|
+
# will always contain the total eligible starting and ending balance for the
|
516
|
+
# customer at the time the entry was added to the ledger.
|
523
517
|
#
|
524
|
-
#
|
518
|
+
# ## Decrement
|
525
519
|
#
|
526
|
-
#
|
527
|
-
#
|
528
|
-
#
|
520
|
+
# Deductions can occur as a result of an API call to create a ledger entry (see
|
521
|
+
# [Add Ledger Entry](create-ledger-entry)), or automatically as a result of
|
522
|
+
# incurring usage. Both ledger entries present the `decrement` entry type.
|
529
523
|
#
|
530
|
-
#
|
531
|
-
#
|
532
|
-
#
|
533
|
-
#
|
534
|
-
#
|
535
|
-
#
|
536
|
-
#
|
524
|
+
# As usage for a customer is reported into Orb, credits may be deducted according
|
525
|
+
# to the customer's plan configuration. An automated deduction of this type will
|
526
|
+
# result in a ledger entry, also with a starting and ending balance. In order to
|
527
|
+
# provide better tracing capabilities for automatic deductions, Orb always
|
528
|
+
# associates each automatic deduction with the `event_id` at the time of
|
529
|
+
# ingestion, used to pinpoint _why_ credit deduction took place and to ensure that
|
530
|
+
# credits are never deducted without an associated usage event.
|
537
531
|
#
|
538
|
-
#
|
539
|
-
#
|
540
|
-
#
|
541
|
-
#
|
542
|
-
#
|
532
|
+
# By default, Orb uses an algorithm that automatically deducts from the _soonest
|
533
|
+
# expiring credit block_ first in order to ensure that all credits are utilized
|
534
|
+
# appropriately. As an example, if trial credits with an expiration date of 2
|
535
|
+
# weeks from now are present for a customer, they will be used before any
|
536
|
+
# deductions take place from a non-expiring credit block.
|
543
537
|
#
|
544
|
-
#
|
545
|
-
#
|
546
|
-
#
|
538
|
+
# If there are multiple blocks with the same expiration date, Orb will deduct from
|
539
|
+
# the block with the _lower cost basis_ first (e.g. trial credits with a $0 cost
|
540
|
+
# basis before paid credits with a $5.00 cost basis).
|
547
541
|
#
|
548
|
-
#
|
549
|
-
#
|
550
|
-
#
|
551
|
-
#
|
552
|
-
#
|
553
|
-
#
|
542
|
+
# It's also possible for a single usage event's deduction to _span_ credit blocks.
|
543
|
+
# In this case, Orb will deduct from the next block, ending at the credit block
|
544
|
+
# which consists of unexpiring credits. Each of these deductions will lead to a
|
545
|
+
# _separate_ ledger entry, one per credit block that is deducted from. By default,
|
546
|
+
# the customer's total credit balance in Orb can be negative as a result of a
|
547
|
+
# decrement.
|
554
548
|
#
|
555
|
-
#
|
549
|
+
# ## Expiration change
|
556
550
|
#
|
557
|
-
#
|
558
|
-
#
|
559
|
-
#
|
551
|
+
# The expiry of credits can be changed as a result of the API (See
|
552
|
+
# [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that
|
553
|
+
# specifies the balance as well as the initial and target expiry dates.
|
560
554
|
#
|
561
|
-
#
|
562
|
-
#
|
563
|
-
#
|
564
|
-
#
|
555
|
+
# Note that for this entry type, `starting_balance` will equal `ending_balance`,
|
556
|
+
# and the `amount` represents the balance transferred. The credit block linked to
|
557
|
+
# the ledger entry is the source credit block from which there was an expiration
|
558
|
+
# change
|
565
559
|
#
|
566
|
-
#
|
560
|
+
# ## Credits expiry
|
567
561
|
#
|
568
|
-
#
|
569
|
-
#
|
570
|
-
#
|
571
|
-
#
|
562
|
+
# When a set of credits expire on pre-set expiration date, the customer's balance
|
563
|
+
# automatically reflects this change and adds an entry to the ledger indicating
|
564
|
+
# this event. Note that credit expiry should always happen close to a date
|
565
|
+
# boundary in the customer's timezone.
|
572
566
|
#
|
573
|
-
#
|
567
|
+
# ## Void initiated
|
574
568
|
#
|
575
|
-
#
|
576
|
-
#
|
577
|
-
#
|
569
|
+
# Credit blocks can be voided via the API. The `amount` on this entry corresponds
|
570
|
+
# to the number of credits that were remaining in the block at time of void.
|
571
|
+
# `void_reason` will be populated if the void is created with a reason.
|
578
572
|
#
|
579
|
-
#
|
573
|
+
# ## Void
|
580
574
|
#
|
581
|
-
#
|
582
|
-
#
|
575
|
+
# When a set of credits is voided, the customer's balance automatically reflects
|
576
|
+
# this change and adds an entry to the ledger indicating this event.
|
583
577
|
#
|
584
|
-
#
|
578
|
+
# ## Amendment
|
585
579
|
#
|
586
|
-
#
|
587
|
-
#
|
580
|
+
# When credits are added to a customer's balance as a result of a correction, this
|
581
|
+
# entry will be added to the ledger to indicate the adjustment of credits.
|
588
582
|
sig do
|
589
583
|
params(
|
590
584
|
external_customer_id: String,
|
@@ -602,15 +596,15 @@ module Orb
|
|
602
596
|
)
|
603
597
|
.returns(
|
604
598
|
Orb::Internal::Page[
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
599
|
+
T.any(
|
600
|
+
Orb::Models::Customers::Credits::LedgerListByExternalIDResponse::IncrementLedgerEntry,
|
601
|
+
Orb::Models::Customers::Credits::LedgerListByExternalIDResponse::DecrementLedgerEntry,
|
602
|
+
Orb::Models::Customers::Credits::LedgerListByExternalIDResponse::ExpirationChangeLedgerEntry,
|
603
|
+
Orb::Models::Customers::Credits::LedgerListByExternalIDResponse::CreditBlockExpiryLedgerEntry,
|
604
|
+
Orb::Models::Customers::Credits::LedgerListByExternalIDResponse::VoidLedgerEntry,
|
605
|
+
Orb::Models::Customers::Credits::LedgerListByExternalIDResponse::VoidInitiatedLedgerEntry,
|
606
|
+
Orb::Models::Customers::Credits::LedgerListByExternalIDResponse::AmendmentLedgerEntry
|
607
|
+
)
|
614
608
|
]
|
615
609
|
)
|
616
610
|
end
|
@@ -623,7 +617,7 @@ module Orb
|
|
623
617
|
# The ledger currency or custom pricing unit to use.
|
624
618
|
currency: nil,
|
625
619
|
# Cursor for pagination. This can be populated by the `next_cursor` value returned
|
626
|
-
#
|
620
|
+
# from the initial request.
|
627
621
|
cursor: nil,
|
628
622
|
entry_status: nil,
|
629
623
|
entry_type: nil,
|
@@ -631,13 +625,10 @@ module Orb
|
|
631
625
|
limit: nil,
|
632
626
|
minimum_amount: nil,
|
633
627
|
request_options: {}
|
634
|
-
)
|
635
|
-
end
|
636
|
-
|
628
|
+
); end
|
637
629
|
# @api private
|
638
630
|
sig { params(client: Orb::Client).returns(T.attached_class) }
|
639
|
-
def self.new(client:)
|
640
|
-
end
|
631
|
+
def self.new(client:); end
|
641
632
|
end
|
642
633
|
end
|
643
634
|
end
|