orb-billing 0.1.3 → 0.3.0
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/.ignore +2 -0
- data/CHANGELOG.md +65 -0
- data/README.md +61 -51
- data/lib/orb/client.rb +7 -6
- data/lib/orb/file_part.rb +55 -0
- data/lib/orb/internal/page.rb +37 -39
- data/lib/orb/internal/transport/base_client.rb +21 -11
- data/lib/orb/internal/transport/pooled_net_requester.rb +3 -3
- data/lib/orb/internal/type/array_of.rb +28 -2
- data/lib/orb/internal/type/base_model.rb +83 -21
- data/lib/orb/internal/type/base_page.rb +10 -1
- data/lib/orb/internal/type/boolean.rb +6 -0
- data/lib/orb/internal/type/converter.rb +28 -1
- data/lib/orb/internal/type/enum.rb +28 -8
- data/lib/orb/internal/type/{io_like.rb → file_input.rb} +35 -15
- data/lib/orb/internal/type/hash_of.rb +28 -2
- data/lib/orb/internal/type/request_parameters.rb +1 -2
- data/lib/orb/internal/type/union.rb +27 -4
- data/lib/orb/internal/type/unknown.rb +6 -0
- data/lib/orb/internal/util.rb +105 -70
- data/lib/orb/internal.rb +5 -2
- data/lib/orb/models/alert.rb +68 -71
- data/lib/orb/models/alert_create_for_customer_params.rb +20 -25
- data/lib/orb/models/alert_create_for_external_customer_params.rb +20 -25
- data/lib/orb/models/alert_create_for_subscription_params.rb +20 -25
- data/lib/orb/models/alert_disable_params.rb +5 -9
- data/lib/orb/models/alert_enable_params.rb +5 -9
- data/lib/orb/models/alert_list_params.rb +26 -36
- data/lib/orb/models/alert_retrieve_params.rb +3 -8
- data/lib/orb/models/alert_update_params.rb +14 -18
- data/lib/orb/models/amount_discount.rb +14 -14
- data/lib/orb/models/billable_metric.rb +23 -20
- data/lib/orb/models/billing_cycle_relative_date.rb +2 -5
- data/lib/orb/models/coupon.rb +28 -21
- data/lib/orb/models/coupon_archive_params.rb +3 -8
- data/lib/orb/models/coupon_create_params.rb +24 -29
- data/lib/orb/models/coupon_fetch_params.rb +3 -8
- data/lib/orb/models/coupon_list_params.rb +17 -17
- data/lib/orb/models/coupons/subscription_list_params.rb +12 -15
- data/lib/orb/models/credit_note.rb +100 -166
- data/lib/orb/models/credit_note_create_params.rb +15 -23
- data/lib/orb/models/credit_note_fetch_params.rb +3 -8
- data/lib/orb/models/credit_note_list_params.rb +20 -30
- data/lib/orb/models/customer.rb +224 -271
- data/lib/orb/models/customer_create_params.rb +211 -252
- data/lib/orb/models/customer_delete_params.rb +3 -8
- data/lib/orb/models/customer_fetch_by_external_id_params.rb +3 -8
- data/lib/orb/models/customer_fetch_params.rb +3 -8
- data/lib/orb/models/customer_list_params.rb +20 -30
- data/lib/orb/models/customer_sync_payment_methods_from_gateway_by_external_customer_id_params.rb +3 -8
- data/lib/orb/models/customer_sync_payment_methods_from_gateway_params.rb +3 -8
- data/lib/orb/models/customer_update_by_external_id_params.rb +207 -250
- data/lib/orb/models/customer_update_params.rb +207 -250
- data/lib/orb/models/customers/balance_transaction_create_params.rb +11 -16
- data/lib/orb/models/customers/balance_transaction_create_response.rb +33 -51
- data/lib/orb/models/customers/balance_transaction_list_params.rb +20 -30
- data/lib/orb/models/customers/balance_transaction_list_response.rb +33 -51
- data/lib/orb/models/customers/cost_list_by_external_id_params.rb +17 -17
- data/lib/orb/models/customers/cost_list_by_external_id_response.rb +22 -26
- data/lib/orb/models/customers/cost_list_params.rb +17 -17
- data/lib/orb/models/customers/cost_list_response.rb +22 -26
- data/lib/orb/models/customers/credit_list_by_external_id_params.rb +18 -22
- data/lib/orb/models/customers/credit_list_by_external_id_response.rb +10 -17
- data/lib/orb/models/customers/credit_list_params.rb +18 -22
- data/lib/orb/models/customers/credit_list_response.rb +10 -17
- data/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_params.rb +64 -66
- data/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_response.rb +300 -406
- data/lib/orb/models/customers/credits/ledger_create_entry_params.rb +63 -66
- data/lib/orb/models/customers/credits/ledger_create_entry_response.rb +300 -406
- data/lib/orb/models/customers/credits/ledger_list_by_external_id_params.rb +33 -48
- data/lib/orb/models/customers/credits/ledger_list_by_external_id_response.rb +300 -406
- data/lib/orb/models/customers/credits/ledger_list_params.rb +32 -48
- data/lib/orb/models/customers/credits/ledger_list_response.rb +300 -406
- data/lib/orb/models/customers/credits/top_up_create_by_external_id_params.rb +47 -50
- data/lib/orb/models/customers/credits/top_up_create_by_external_id_response.rb +43 -46
- data/lib/orb/models/customers/credits/top_up_create_params.rb +46 -50
- data/lib/orb/models/customers/credits/top_up_create_response.rb +42 -46
- data/lib/orb/models/customers/credits/top_up_delete_by_external_id_params.rb +4 -9
- data/lib/orb/models/customers/credits/top_up_delete_params.rb +4 -9
- data/lib/orb/models/customers/credits/top_up_list_by_external_id_params.rb +12 -15
- data/lib/orb/models/customers/credits/top_up_list_by_external_id_response.rb +43 -46
- data/lib/orb/models/customers/credits/top_up_list_params.rb +12 -15
- data/lib/orb/models/customers/credits/top_up_list_response.rb +42 -46
- data/lib/orb/models/dimensional_price_group.rb +21 -15
- data/lib/orb/models/dimensional_price_group_create_params.rb +17 -23
- data/lib/orb/models/dimensional_price_group_list_params.rb +12 -15
- data/lib/orb/models/dimensional_price_group_retrieve_params.rb +3 -8
- data/lib/orb/models/dimensional_price_groups/external_dimensional_price_group_id_retrieve_params.rb +3 -8
- data/lib/orb/models/dimensional_price_groups.rb +3 -7
- data/lib/orb/models/discount.rb +2 -3
- data/lib/orb/models/evaluate_price_group.rb +8 -11
- data/lib/orb/models/event_deprecate_params.rb +3 -8
- data/lib/orb/models/event_deprecate_response.rb +2 -6
- data/lib/orb/models/event_ingest_params.rb +33 -27
- data/lib/orb/models/event_ingest_response.rb +23 -24
- data/lib/orb/models/event_search_params.rb +15 -11
- data/lib/orb/models/event_search_response.rb +27 -22
- data/lib/orb/models/event_update_params.rb +19 -13
- data/lib/orb/models/event_update_response.rb +2 -6
- data/lib/orb/models/events/backfill_close_params.rb +3 -8
- data/lib/orb/models/events/backfill_close_response.rb +34 -39
- data/lib/orb/models/events/backfill_create_params.rb +28 -32
- data/lib/orb/models/events/backfill_create_response.rb +34 -39
- data/lib/orb/models/events/backfill_fetch_params.rb +3 -8
- data/lib/orb/models/events/backfill_fetch_response.rb +34 -39
- data/lib/orb/models/events/backfill_list_params.rb +12 -15
- data/lib/orb/models/events/backfill_list_response.rb +34 -39
- data/lib/orb/models/events/backfill_revert_params.rb +3 -8
- data/lib/orb/models/events/backfill_revert_response.rb +34 -39
- data/lib/orb/models/events/event_volumes.rb +11 -17
- data/lib/orb/models/events/volume_list_params.rb +19 -22
- data/lib/orb/models/invoice.rb +589 -637
- data/lib/orb/models/invoice_create_params.rb +52 -61
- data/lib/orb/models/invoice_fetch_params.rb +3 -8
- data/lib/orb/models/invoice_fetch_upcoming_params.rb +4 -9
- data/lib/orb/models/invoice_fetch_upcoming_response.rb +584 -631
- data/lib/orb/models/invoice_issue_params.rb +10 -14
- data/lib/orb/models/invoice_level_discount.rb +2 -3
- data/lib/orb/models/invoice_line_item_create_params.rb +19 -14
- data/lib/orb/models/invoice_line_item_create_response.rb +247 -269
- data/lib/orb/models/invoice_list_params.rb +51 -66
- data/lib/orb/models/invoice_mark_paid_params.rb +9 -11
- data/lib/orb/models/invoice_pay_params.rb +3 -8
- data/lib/orb/models/invoice_update_params.rb +9 -9
- data/lib/orb/models/invoice_void_params.rb +3 -8
- data/lib/orb/models/item.rb +14 -25
- data/lib/orb/models/item_create_params.rb +5 -9
- data/lib/orb/models/item_fetch_params.rb +3 -8
- data/lib/orb/models/item_list_params.rb +12 -15
- data/lib/orb/models/item_update_params.rb +10 -22
- data/lib/orb/models/metric_create_params.rb +17 -13
- data/lib/orb/models/metric_fetch_params.rb +3 -8
- data/lib/orb/models/metric_list_params.rb +20 -30
- data/lib/orb/models/metric_update_params.rb +9 -9
- data/lib/orb/models/pagination_metadata.rb +3 -7
- data/lib/orb/models/percentage_discount.rb +15 -14
- data/lib/orb/models/plan.rb +250 -279
- data/lib/orb/models/plan_create_params.rb +1623 -1984
- data/lib/orb/models/plan_fetch_params.rb +3 -8
- data/lib/orb/models/plan_list_params.rb +25 -42
- data/lib/orb/models/plan_update_params.rb +12 -10
- data/lib/orb/models/plans/external_plan_id_fetch_params.rb +3 -8
- data/lib/orb/models/plans/external_plan_id_update_params.rb +12 -10
- data/lib/orb/models/price.rb +2709 -3820
- data/lib/orb/models/price_create_params.rb +203 -244
- data/lib/orb/models/price_evaluate_params.rb +21 -30
- data/lib/orb/models/price_evaluate_response.rb +2 -6
- data/lib/orb/models/price_fetch_params.rb +3 -8
- data/lib/orb/models/price_list_params.rb +12 -15
- data/lib/orb/models/price_update_params.rb +9 -9
- data/lib/orb/models/prices/external_price_id_fetch_params.rb +3 -8
- data/lib/orb/models/prices/external_price_id_update_params.rb +9 -9
- data/lib/orb/models/subscription.rb +343 -382
- data/lib/orb/models/subscription_cancel_params.rb +16 -16
- data/lib/orb/models/subscription_cancel_response.rb +339 -377
- data/lib/orb/models/subscription_change_apply_params.rb +7 -10
- data/lib/orb/models/subscription_change_apply_response.rb +365 -398
- data/lib/orb/models/subscription_change_cancel_params.rb +3 -8
- data/lib/orb/models/subscription_change_cancel_response.rb +365 -398
- data/lib/orb/models/subscription_change_retrieve_params.rb +3 -8
- data/lib/orb/models/subscription_change_retrieve_response.rb +366 -398
- data/lib/orb/models/subscription_create_params.rb +3771 -4402
- data/lib/orb/models/subscription_create_response.rb +339 -377
- data/lib/orb/models/subscription_fetch_costs_params.rb +17 -17
- data/lib/orb/models/subscription_fetch_costs_response.rb +22 -26
- data/lib/orb/models/subscription_fetch_params.rb +3 -8
- data/lib/orb/models/subscription_fetch_schedule_params.rb +20 -30
- data/lib/orb/models/subscription_fetch_schedule_response.rb +15 -17
- data/lib/orb/models/subscription_fetch_usage_params.rb +32 -43
- data/lib/orb/models/subscription_list_params.rb +28 -41
- data/lib/orb/models/subscription_price_intervals_params.rb +2018 -2472
- data/lib/orb/models/subscription_price_intervals_response.rb +342 -377
- data/lib/orb/models/subscription_schedule_plan_change_params.rb +3764 -4392
- data/lib/orb/models/subscription_schedule_plan_change_response.rb +342 -377
- data/lib/orb/models/subscription_trigger_phase_params.rb +12 -10
- data/lib/orb/models/subscription_trigger_phase_response.rb +341 -377
- data/lib/orb/models/subscription_unschedule_cancellation_params.rb +3 -8
- data/lib/orb/models/subscription_unschedule_cancellation_response.rb +342 -377
- data/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_params.rb +5 -9
- data/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_response.rb +343 -377
- data/lib/orb/models/subscription_unschedule_pending_plan_changes_params.rb +3 -8
- data/lib/orb/models/subscription_unschedule_pending_plan_changes_response.rb +343 -377
- data/lib/orb/models/subscription_update_fixed_fee_quantity_params.rb +22 -33
- data/lib/orb/models/subscription_update_fixed_fee_quantity_response.rb +342 -377
- data/lib/orb/models/subscription_update_params.rb +21 -23
- data/lib/orb/models/subscription_update_trial_params.rb +15 -18
- data/lib/orb/models/subscription_update_trial_response.rb +341 -377
- data/lib/orb/models/subscription_usage.rb +37 -80
- data/lib/orb/models/subscriptions.rb +3 -7
- data/lib/orb/models/top_level_ping_params.rb +3 -8
- data/lib/orb/models/top_level_ping_response.rb +2 -6
- data/lib/orb/models/trial_discount.rb +16 -24
- data/lib/orb/models/usage_discount.rb +15 -14
- data/lib/orb/request_options.rb +3 -4
- data/lib/orb/resources/alerts.rb +48 -17
- data/lib/orb/resources/coupons/subscriptions.rb +9 -2
- data/lib/orb/resources/coupons.rb +25 -7
- data/lib/orb/resources/credit_notes.rb +17 -4
- data/lib/orb/resources/customers/balance_transactions.rb +18 -3
- data/lib/orb/resources/customers/costs.rb +26 -8
- data/lib/orb/resources/customers/credits/ledger.rb +108 -28
- data/lib/orb/resources/customers/credits/top_ups.rb +67 -20
- data/lib/orb/resources/customers/credits.rb +28 -8
- data/lib/orb/resources/customers.rb +135 -36
- data/lib/orb/resources/dimensional_price_groups.rb +19 -4
- data/lib/orb/resources/events/backfills.rb +32 -9
- data/lib/orb/resources/events/volume.rb +14 -4
- data/lib/orb/resources/events.rb +40 -11
- data/lib/orb/resources/invoice_line_items.rb +16 -6
- data/lib/orb/resources/invoices.rb +77 -17
- data/lib/orb/resources/items.rb +10 -3
- data/lib/orb/resources/metrics.rb +33 -8
- data/lib/orb/resources/plans/external_plan_id.rb +10 -2
- data/lib/orb/resources/plans.rb +47 -11
- data/lib/orb/resources/prices/external_price_id.rb +7 -1
- data/lib/orb/resources/prices.rb +97 -22
- data/lib/orb/resources/subscription_changes.rb +5 -2
- data/lib/orb/resources/subscriptions.rb +292 -78
- data/lib/orb/version.rb +1 -1
- data/lib/orb.rb +2 -10
- data/rbi/lib/orb/client.rbi +7 -6
- data/rbi/lib/orb/file_part.rbi +34 -0
- data/rbi/lib/orb/internal/page.rbi +1 -0
- data/rbi/lib/orb/internal/transport/base_client.rbi +18 -3
- data/rbi/lib/orb/internal/type/array_of.rbi +15 -9
- data/rbi/lib/orb/internal/type/base_model.rbi +22 -0
- data/rbi/lib/orb/internal/type/base_page.rbi +2 -0
- data/rbi/lib/orb/internal/type/boolean.rbi +4 -5
- data/rbi/lib/orb/internal/type/converter.rbi +8 -0
- data/rbi/lib/orb/internal/type/enum.rbi +7 -6
- data/rbi/lib/orb/internal/type/{io_like.rbi → file_input.rbi} +9 -7
- data/rbi/lib/orb/internal/type/hash_of.rbi +15 -9
- data/rbi/lib/orb/internal/type/union.rbi +7 -0
- data/rbi/lib/orb/internal/type/unknown.rbi +4 -5
- data/rbi/lib/orb/internal/util.rbi +39 -19
- data/rbi/lib/orb/internal.rbi +1 -2
- data/rbi/lib/orb/models/alert.rbi +28 -8
- data/rbi/lib/orb/models/alert_create_for_customer_params.rbi +16 -6
- data/rbi/lib/orb/models/alert_create_for_external_customer_params.rbi +16 -6
- data/rbi/lib/orb/models/alert_create_for_subscription_params.rbi +16 -6
- data/rbi/lib/orb/models/alert_disable_params.rbi +5 -2
- data/rbi/lib/orb/models/alert_enable_params.rbi +5 -2
- data/rbi/lib/orb/models/alert_list_params.rbi +6 -0
- data/rbi/lib/orb/models/alert_update_params.rbi +11 -4
- data/rbi/lib/orb/models/amount_discount.rbi +10 -4
- data/rbi/lib/orb/models/billable_metric.rbi +16 -3
- data/rbi/lib/orb/models/billing_cycle_relative_date.rbi +1 -1
- data/rbi/lib/orb/models/coupon.rbi +10 -3
- data/rbi/lib/orb/models/coupon_create_params.rbi +6 -3
- data/rbi/lib/orb/models/coupon_list_params.rbi +13 -3
- data/rbi/lib/orb/models/coupons/subscription_list_params.rbi +8 -2
- data/rbi/lib/orb/models/credit_note.rbi +44 -12
- data/rbi/lib/orb/models/credit_note_create_params.rbi +15 -6
- data/rbi/lib/orb/models/credit_note_list_params.rbi +3 -0
- data/rbi/lib/orb/models/customer.rbi +130 -11
- data/rbi/lib/orb/models/customer_create_params.rbi +142 -8
- data/rbi/lib/orb/models/customer_list_params.rbi +3 -0
- data/rbi/lib/orb/models/customer_update_by_external_id_params.rbi +140 -8
- data/rbi/lib/orb/models/customer_update_params.rbi +140 -8
- data/rbi/lib/orb/models/customers/balance_transaction_create_params.rbi +8 -4
- data/rbi/lib/orb/models/customers/balance_transaction_create_response.rbi +18 -8
- data/rbi/lib/orb/models/customers/balance_transaction_list_params.rbi +3 -0
- data/rbi/lib/orb/models/customers/balance_transaction_list_response.rbi +18 -8
- data/rbi/lib/orb/models/customers/cost_list_by_external_id_params.rbi +9 -5
- data/rbi/lib/orb/models/customers/cost_list_by_external_id_response.rbi +21 -4
- data/rbi/lib/orb/models/customers/cost_list_params.rbi +9 -5
- data/rbi/lib/orb/models/customers/cost_list_response.rbi +21 -4
- data/rbi/lib/orb/models/customers/credit_list_by_external_id_params.rbi +13 -3
- data/rbi/lib/orb/models/customers/credit_list_by_external_id_response.rbi +1 -2
- data/rbi/lib/orb/models/customers/credit_list_params.rbi +13 -3
- data/rbi/lib/orb/models/customers/credit_list_response.rbi +1 -2
- data/rbi/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_params.rbi +40 -18
- data/rbi/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_response.rbi +35 -56
- data/rbi/lib/orb/models/customers/credits/ledger_create_entry_params.rbi +40 -6
- data/rbi/lib/orb/models/customers/credits/ledger_create_entry_response.rbi +35 -56
- data/rbi/lib/orb/models/customers/credits/ledger_list_by_external_id_params.rbi +6 -16
- data/rbi/lib/orb/models/customers/credits/ledger_list_by_external_id_response.rbi +35 -56
- data/rbi/lib/orb/models/customers/credits/ledger_list_params.rbi +6 -4
- data/rbi/lib/orb/models/customers/credits/ledger_list_response.rbi +35 -56
- data/rbi/lib/orb/models/customers/credits/top_up_create_by_external_id_params.rbi +27 -10
- data/rbi/lib/orb/models/customers/credits/top_up_create_by_external_id_response.rbi +25 -10
- data/rbi/lib/orb/models/customers/credits/top_up_create_params.rbi +27 -4
- data/rbi/lib/orb/models/customers/credits/top_up_create_response.rbi +25 -10
- data/rbi/lib/orb/models/customers/credits/top_up_list_by_external_id_params.rbi +8 -2
- data/rbi/lib/orb/models/customers/credits/top_up_list_by_external_id_response.rbi +25 -10
- data/rbi/lib/orb/models/customers/credits/top_up_list_params.rbi +8 -2
- data/rbi/lib/orb/models/customers/credits/top_up_list_response.rbi +25 -4
- data/rbi/lib/orb/models/dimensional_price_group.rbi +11 -3
- data/rbi/lib/orb/models/dimensional_price_group_create_params.rbi +4 -0
- data/rbi/lib/orb/models/dimensional_price_group_list_params.rbi +8 -2
- data/rbi/lib/orb/models/evaluate_price_group.rbi +8 -2
- data/rbi/lib/orb/models/event_deprecate_response.rbi +4 -2
- data/rbi/lib/orb/models/event_ingest_params.rbi +22 -5
- data/rbi/lib/orb/models/event_ingest_response.rbi +15 -4
- data/rbi/lib/orb/models/event_search_params.rbi +14 -2
- data/rbi/lib/orb/models/event_search_response.rbi +14 -3
- data/rbi/lib/orb/models/event_update_params.rbi +10 -3
- data/rbi/lib/orb/models/event_update_response.rbi +4 -2
- data/rbi/lib/orb/models/events/backfill_close_response.rbi +14 -2
- data/rbi/lib/orb/models/events/backfill_create_params.rbi +18 -0
- data/rbi/lib/orb/models/events/backfill_create_response.rbi +14 -2
- data/rbi/lib/orb/models/events/backfill_fetch_response.rbi +14 -2
- data/rbi/lib/orb/models/events/backfill_list_params.rbi +8 -2
- data/rbi/lib/orb/models/events/backfill_list_response.rbi +14 -2
- data/rbi/lib/orb/models/events/backfill_revert_response.rbi +14 -2
- data/rbi/lib/orb/models/events/event_volumes.rbi +6 -2
- data/rbi/lib/orb/models/events/volume_list_params.rbi +18 -2
- data/rbi/lib/orb/models/invoice.rbi +375 -46
- data/rbi/lib/orb/models/invoice_create_params.rbi +38 -6
- data/rbi/lib/orb/models/invoice_fetch_upcoming_response.rbi +375 -66
- data/rbi/lib/orb/models/invoice_issue_params.rbi +9 -2
- data/rbi/lib/orb/models/invoice_line_item_create_params.rbi +16 -2
- data/rbi/lib/orb/models/invoice_line_item_create_response.rbi +141 -20
- data/rbi/lib/orb/models/invoice_list_params.rbi +9 -2
- data/rbi/lib/orb/models/invoice_mark_paid_params.rbi +9 -2
- data/rbi/lib/orb/models/invoice_update_params.rbi +7 -2
- data/rbi/lib/orb/models/item.rbi +1 -2
- data/rbi/lib/orb/models/item_create_params.rbi +5 -2
- data/rbi/lib/orb/models/item_list_params.rbi +8 -2
- data/rbi/lib/orb/models/item_update_params.rbi +1 -8
- data/rbi/lib/orb/models/metric_create_params.rbi +15 -2
- data/rbi/lib/orb/models/metric_list_params.rbi +3 -0
- data/rbi/lib/orb/models/metric_update_params.rbi +7 -2
- data/rbi/lib/orb/models/percentage_discount.rbi +11 -4
- data/rbi/lib/orb/models/plan.rbi +102 -15
- data/rbi/lib/orb/models/plan_create_params.rbi +997 -679
- data/rbi/lib/orb/models/plan_list_params.rbi +5 -1
- data/rbi/lib/orb/models/plan_update_params.rbi +11 -2
- data/rbi/lib/orb/models/plans/external_plan_id_update_params.rbi +11 -2
- data/rbi/lib/orb/models/price.rbi +717 -688
- data/rbi/lib/orb/models/price_create_params.rbi +137 -53
- data/rbi/lib/orb/models/price_evaluate_params.rbi +10 -0
- data/rbi/lib/orb/models/price_list_params.rbi +8 -2
- data/rbi/lib/orb/models/price_update_params.rbi +7 -2
- data/rbi/lib/orb/models/prices/external_price_id_update_params.rbi +7 -2
- data/rbi/lib/orb/models/subscription.rbi +174 -11
- data/rbi/lib/orb/models/subscription_cancel_params.rbi +8 -5
- data/rbi/lib/orb/models/subscription_cancel_response.rbi +187 -14
- data/rbi/lib/orb/models/subscription_change_apply_params.rbi +7 -2
- data/rbi/lib/orb/models/subscription_change_apply_response.rbi +199 -18
- data/rbi/lib/orb/models/subscription_change_cancel_response.rbi +199 -18
- data/rbi/lib/orb/models/subscription_change_retrieve_response.rbi +199 -18
- data/rbi/lib/orb/models/subscription_create_params.rbi +2282 -1536
- data/rbi/lib/orb/models/subscription_create_response.rbi +187 -14
- data/rbi/lib/orb/models/subscription_fetch_costs_params.rbi +9 -5
- data/rbi/lib/orb/models/subscription_fetch_costs_response.rbi +21 -4
- data/rbi/lib/orb/models/subscription_fetch_schedule_params.rbi +3 -0
- data/rbi/lib/orb/models/subscription_fetch_schedule_response.rbi +8 -2
- data/rbi/lib/orb/models/subscription_fetch_usage_params.rbi +13 -4
- data/rbi/lib/orb/models/subscription_list_params.rbi +4 -2
- data/rbi/lib/orb/models/subscription_price_intervals_params.rbi +1228 -861
- data/rbi/lib/orb/models/subscription_price_intervals_response.rbi +187 -14
- data/rbi/lib/orb/models/subscription_schedule_plan_change_params.rbi +2288 -1544
- data/rbi/lib/orb/models/subscription_schedule_plan_change_response.rbi +187 -14
- data/rbi/lib/orb/models/subscription_trigger_phase_params.rbi +10 -2
- data/rbi/lib/orb/models/subscription_trigger_phase_response.rbi +187 -14
- data/rbi/lib/orb/models/subscription_unschedule_cancellation_response.rbi +187 -14
- data/rbi/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_params.rbi +5 -2
- data/rbi/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_response.rbi +187 -20
- data/rbi/lib/orb/models/subscription_unschedule_pending_plan_changes_response.rbi +187 -14
- data/rbi/lib/orb/models/subscription_update_fixed_fee_quantity_params.rbi +11 -2
- data/rbi/lib/orb/models/subscription_update_fixed_fee_quantity_response.rbi +187 -14
- data/rbi/lib/orb/models/subscription_update_params.rbi +15 -0
- data/rbi/lib/orb/models/subscription_update_trial_params.rbi +11 -5
- data/rbi/lib/orb/models/subscription_update_trial_response.rbi +187 -14
- data/rbi/lib/orb/models/subscription_usage.rbi +2 -16
- data/rbi/lib/orb/models/trial_discount.rbi +5 -1
- data/rbi/lib/orb/models/usage_discount.rbi +11 -3
- data/sig/orb/file_part.rbs +21 -0
- data/sig/orb/internal/transport/base_client.rbs +9 -3
- data/sig/orb/internal/type/array_of.rbs +4 -0
- data/sig/orb/internal/type/base_model.rbs +12 -0
- data/sig/orb/internal/type/converter.rbs +4 -0
- data/sig/orb/internal/type/enum.rbs +4 -2
- data/sig/orb/internal/type/{io_like.rbs → file_input.rbs} +1 -1
- data/sig/orb/internal/type/hash_of.rbs +4 -0
- data/sig/orb/internal/type/union.rbs +4 -0
- data/sig/orb/internal/util.rbs +16 -12
- data/sig/orb/internal.rbs +1 -1
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6367789d025f1cbcd45171eca19809e1cb2cdff2c24af5335fac8641c876b093
|
4
|
+
data.tar.gz: 57a3c5bcb71ebf4f3e78b4412b386616cc1e37fc6adc682f38f13a129bc9aed4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62f9112f730c3b05638d410aba2302c4ce137f46ad72e4a888636eff8eacc0f6649a41d69726f05e05ffb82d2de1fe9996f72556e537f065b43d415ffeb1024d
|
7
|
+
data.tar.gz: a0f8bd39183054afa8f172d776b20c54c08019b04001b00b33878fb4a69e6c0a0b54038bd7072e930fb85b2a070012fabf6319b4b2ce34195844b9f3b2cbe90a
|
data/.ignore
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,70 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.3.0 (2025-04-25)
|
4
|
+
|
5
|
+
Full Changelog: [v0.2.0...v0.3.0](https://github.com/orbcorp/orb-ruby/compare/v0.2.0...v0.3.0)
|
6
|
+
|
7
|
+
### Features
|
8
|
+
|
9
|
+
* implement `#hash` for data containers ([ba49d29](https://github.com/orbcorp/orb-ruby/commit/ba49d294bfa09eca64b9a137c730c452318a56d4))
|
10
|
+
* support specifying content-type with FilePart class ([200103f](https://github.com/orbcorp/orb-ruby/commit/200103fddf8b1d524caa1cb3a126d72b476315f4))
|
11
|
+
* support webmock for testing ([ca1c497](https://github.com/orbcorp/orb-ruby/commit/ca1c497d57309c0bd2518070a0f8af3e0c639be4))
|
12
|
+
|
13
|
+
|
14
|
+
### Bug Fixes
|
15
|
+
|
16
|
+
* ensure gem release is unaffected by renaming ([3e0fd9e](https://github.com/orbcorp/orb-ruby/commit/3e0fd9e21bb02529c0513b7a1e2fbdfa7d80b049))
|
17
|
+
* make a typo for `FilePart.content` ([f62d185](https://github.com/orbcorp/orb-ruby/commit/f62d18544ccd90a55bdfc520cbea03c1ea7583d1))
|
18
|
+
|
19
|
+
|
20
|
+
### Chores
|
21
|
+
|
22
|
+
* broadly detect json family of content-type headers ([d4e5904](https://github.com/orbcorp/orb-ruby/commit/d4e5904287b32db4efe997b617310670961be6b1))
|
23
|
+
* **ci:** add timeout thresholds for CI jobs ([450f552](https://github.com/orbcorp/orb-ruby/commit/450f552e892e75242d3ec3e3e0c98605e1ac0b61))
|
24
|
+
* **ci:** only use depot for staging repos ([fd387ce](https://github.com/orbcorp/orb-ruby/commit/fd387ce6f9dff526039887480712e8b0c35595b5))
|
25
|
+
* **ci:** run on more branches and use depot runners ([7f5a6c3](https://github.com/orbcorp/orb-ruby/commit/7f5a6c320853a23d5ac339ea368d7cad7bbc35c5))
|
26
|
+
* documentation improvements ([6e04e50](https://github.com/orbcorp/orb-ruby/commit/6e04e5062b468fdf1f40fe3cd491b9fbb610bc5c))
|
27
|
+
* explicitly mark apis public under `Internal` module ([d19524a](https://github.com/orbcorp/orb-ruby/commit/d19524a2a412b98ac4529b46c02e249e8a587c34))
|
28
|
+
* **internal:** improve response envelope unwrap functionality ([b3f0632](https://github.com/orbcorp/orb-ruby/commit/b3f0632eae23d838395933fe4a334fd23dff46fd))
|
29
|
+
* **internal:** minor type annotation improvements ([cf871bc](https://github.com/orbcorp/orb-ruby/commit/cf871bca5feacf6e95351418a3553c774889ccee))
|
30
|
+
* **internal:** version bump ([6b83db6](https://github.com/orbcorp/orb-ruby/commit/6b83db65c3d405b7f7c5e20a93be6428dcf7fc08))
|
31
|
+
* make sorbet enums easier to read ([3793346](https://github.com/orbcorp/orb-ruby/commit/3793346c4a6cd6ff18aad64e4c48933a5159ebe1))
|
32
|
+
* show truncated parameter docs in yard ([0fb86bd](https://github.com/orbcorp/orb-ruby/commit/0fb86bd1313bb300e565f873e5a181f652ce88fa))
|
33
|
+
* simplify yard annotations by removing most `@!parse` directives ([a94843b](https://github.com/orbcorp/orb-ruby/commit/a94843be3f13ed22ae07ded47bff22e044525f0b))
|
34
|
+
* update README with recommended editor plugins ([50771fd](https://github.com/orbcorp/orb-ruby/commit/50771fdf28dcee2856522c5c29a491873ec14a4a))
|
35
|
+
* use `@!method` instead of `@!parse` for virtual method type definitions ([21cfdfc](https://github.com/orbcorp/orb-ruby/commit/21cfdfcc91f9dbd04831e502b990f9118f4b5eb0))
|
36
|
+
|
37
|
+
## 0.2.0 (2025-04-17)
|
38
|
+
|
39
|
+
Full Changelog: [v0.1.3...v0.2.0](https://github.com/orbcorp/orb-ruby/compare/v0.1.3...v0.2.0)
|
40
|
+
|
41
|
+
### Features
|
42
|
+
|
43
|
+
* **client:** enable setting base URL from environment variable ([a472f4c](https://github.com/orbcorp/orb-ruby/commit/a472f4cdee0d969b7e240a9519acccd3877f3de6))
|
44
|
+
|
45
|
+
|
46
|
+
### Bug Fixes
|
47
|
+
|
48
|
+
* always send idempotency header when specified as a request option ([f570e93](https://github.com/orbcorp/orb-ruby/commit/f570e93e8fe1a2f6d6df495021ea1152aeaf1e58))
|
49
|
+
|
50
|
+
|
51
|
+
### Chores
|
52
|
+
|
53
|
+
* **internal:** always run post-processing when formatting when syntax_tree ([9df6d63](https://github.com/orbcorp/orb-ruby/commit/9df6d6382e67f6f28f1cedff4ee1c949ffd70237))
|
54
|
+
* **internal:** codegen related update ([202fff4](https://github.com/orbcorp/orb-ruby/commit/202fff413ad9e9be16b67a07270dd4ac2c4f14e4))
|
55
|
+
* **internal:** codegen related update ([2b99ae2](https://github.com/orbcorp/orb-ruby/commit/2b99ae2ea108ad4e6227bd5ab7e9a7dd064a8ded))
|
56
|
+
* **internal:** contribute.md and contributor QoL improvements ([cb204de](https://github.com/orbcorp/orb-ruby/commit/cb204de43549ee6aa9ead2d1e071ec5df0c58cb2))
|
57
|
+
* **internal:** loosen internal type restrictions ([9dc6b52](https://github.com/orbcorp/orb-ruby/commit/9dc6b52d1bfa57e3fab328bf8673872522ab7f25))
|
58
|
+
* **internal:** minor touch ups on sdk internals ([9297be8](https://github.com/orbcorp/orb-ruby/commit/9297be8eaa459f14cb0b4118066ecd59877686ab))
|
59
|
+
* **internal:** protect SSE parsing pipeline from broken UTF-8 characters ([bb2243a](https://github.com/orbcorp/orb-ruby/commit/bb2243a19fbd077687be4b2a4a001e4b7381c54d))
|
60
|
+
* **internal:** version bump ([c664f2f](https://github.com/orbcorp/orb-ruby/commit/c664f2fb5019cabca07ce026410d6951f9412d69))
|
61
|
+
* refine `#inspect` and `#to_s` for model classes ([86f8280](https://github.com/orbcorp/orb-ruby/commit/86f8280e1126e5bd4013f4c1e5ddd09190044fa3))
|
62
|
+
|
63
|
+
|
64
|
+
### Documentation
|
65
|
+
|
66
|
+
* update documentation links to be more uniform ([a0bfe42](https://github.com/orbcorp/orb-ruby/commit/a0bfe42c34e09819e4948069670cfdf895cb51af))
|
67
|
+
|
3
68
|
## 0.1.3 (2025-04-11)
|
4
69
|
|
5
70
|
Full Changelog: [v0.1.2...v0.1.3](https://github.com/orbcorp/orb-ruby/compare/v0.1.2...v0.1.3)
|
data/README.md
CHANGED
@@ -4,9 +4,9 @@ The Orb Ruby library provides convenient access to the Orb REST API from any Rub
|
|
4
4
|
|
5
5
|
## Documentation
|
6
6
|
|
7
|
-
Documentation for
|
7
|
+
Documentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/orb-billing).
|
8
8
|
|
9
|
-
The
|
9
|
+
The REST API documentation can be found on [docs.withorb.com](https://docs.withorb.com/reference/api-reference).
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
@@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
|
|
15
15
|
<!-- x-release-please-start-version -->
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
gem "orb-billing", "~> 0.
|
18
|
+
gem "orb-billing", "~> 0.3.0"
|
19
19
|
```
|
20
20
|
|
21
21
|
<!-- x-release-please-end -->
|
@@ -35,6 +35,16 @@ customer = orb.customers.create(email: "example-customer@withorb.com", name: "My
|
|
35
35
|
puts(customer.id)
|
36
36
|
```
|
37
37
|
|
38
|
+
## Sorbet
|
39
|
+
|
40
|
+
This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the `sorbet-runtime`.
|
41
|
+
|
42
|
+
When using sorbet, it is recommended to use model classes as below. This provides stronger type checking and tooling integration.
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
orb.customers.create(email: "example-customer@withorb.com", name: "My Customer")
|
46
|
+
```
|
47
|
+
|
38
48
|
### Pagination
|
39
49
|
|
40
50
|
List methods in the Orb API are paginated.
|
@@ -126,61 +136,33 @@ orb.customers.create(
|
|
126
136
|
)
|
127
137
|
```
|
128
138
|
|
129
|
-
##
|
130
|
-
|
131
|
-
### Solargraph
|
132
|
-
|
133
|
-
This library includes [Solargraph](https://solargraph.org) support for both auto completion and go to definition.
|
134
|
-
|
135
|
-
```ruby
|
136
|
-
gem "solargraph", group: :development
|
137
|
-
```
|
138
|
-
|
139
|
-
After Solargraph is installed, **you must populate its index** either via the provided editor command, or by running the following in your terminal:
|
140
|
-
|
141
|
-
```sh
|
142
|
-
bundle exec solargraph gems
|
143
|
-
```
|
144
|
-
|
145
|
-
Note: if you had installed the gem either using a `git:` or `github:` URL, or had vendored the gem using bundler, you will need to set up your [`.solargraph.yml`](https://solargraph.org/guides/configuration) to include the path to the gem's `lib` directory.
|
146
|
-
|
147
|
-
```yaml
|
148
|
-
include:
|
149
|
-
- 'vendor/bundle/ruby/*/gems/orb-billing-*/lib/**/*.rb'
|
150
|
-
```
|
151
|
-
|
152
|
-
Otherwise Solargraph will not be able to provide type information or auto-completion for any non-indexed libraries.
|
153
|
-
|
154
|
-
### Sorbet
|
155
|
-
|
156
|
-
This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the `sorbet-runtime`.
|
139
|
+
## Model DSL
|
157
140
|
|
158
|
-
|
141
|
+
This library uses a simple DSL to represent request parameters and response shapes in `lib/orb/models`.
|
159
142
|
|
160
|
-
|
143
|
+
With the right [editor plugins](https://shopify.github.io/ruby-lsp), you can ctrl-click on elements of the DSL to navigate around and explore the library.
|
161
144
|
|
162
|
-
|
145
|
+
In all places where a `BaseModel` type is specified, vanilla Ruby `Hash` can also be used. For example, the following are interchangeable as arguments:
|
163
146
|
|
164
147
|
```ruby
|
148
|
+
# This has tooling readability, for auto-completion, static analysis, and goto definition with supported language services
|
165
149
|
params = Orb::Models::CustomerCreateParams.new(email: "example-customer@withorb.com", name: "My Customer")
|
166
150
|
|
167
|
-
|
151
|
+
# This also works
|
152
|
+
params = {
|
153
|
+
email: "example-customer@withorb.com",
|
154
|
+
name: "My Customer"
|
155
|
+
}
|
168
156
|
```
|
169
157
|
|
170
|
-
|
171
|
-
|
172
|
-
### Ruby LSP
|
158
|
+
## Editor support
|
173
159
|
|
174
|
-
|
160
|
+
A combination of [Shopify LSP](https://shopify.github.io/ruby-lsp) and [Solargraph](https://solargraph.org/) is recommended for non-[Sorbet](https://sorbet.org) users. The former is especially good at go to definition, while the latter has much better auto-completion support.
|
175
161
|
|
176
|
-
## Advanced
|
162
|
+
## Advanced concepts
|
177
163
|
|
178
164
|
### Making custom/undocumented requests
|
179
165
|
|
180
|
-
This library is typed for convenient access to the documented API.
|
181
|
-
|
182
|
-
If you need to access undocumented endpoints, params, or response properties, the library can still be used.
|
183
|
-
|
184
166
|
#### Undocumented request params
|
185
167
|
|
186
168
|
If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a requests as seen in examples above.
|
@@ -191,15 +173,15 @@ To make requests to undocumented endpoints, you can make requests using `client.
|
|
191
173
|
|
192
174
|
```ruby
|
193
175
|
response = client.request(
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
176
|
+
method: :post,
|
177
|
+
path: '/undocumented/endpoint',
|
178
|
+
query: {"dog": "woof"},
|
179
|
+
headers: {"useful-header": "interesting-value"},
|
180
|
+
body: {"he": "llo"},
|
181
|
+
)
|
200
182
|
```
|
201
183
|
|
202
|
-
### Concurrency &
|
184
|
+
### Concurrency & connection pooling
|
203
185
|
|
204
186
|
The `Orb::Client` instances are thread-safe, and should be re-used across multiple threads. By default, each `Client` have their own HTTP connection pool, with a maximum number of connections equal to thread count.
|
205
187
|
|
@@ -209,6 +191,30 @@ Unless otherwise specified, other classes in the SDK do not have locks protectin
|
|
209
191
|
|
210
192
|
Currently, `Orb::Client` instances are only fork-safe if there are no in-flight HTTP requests.
|
211
193
|
|
194
|
+
### Sorbet
|
195
|
+
|
196
|
+
#### Enums
|
197
|
+
|
198
|
+
Sorbet's typed enums require sub-classing of the [`T::Enum` class](https://sorbet.org/docs/tenum) from the `sorbet-runtime` gem.
|
199
|
+
|
200
|
+
Since this library does not depend on `sorbet-runtime`, it uses a [`T.all` intersection type](https://sorbet.org/docs/intersection-types) with a ruby primitive type to construct a "tagged alias" instead.
|
201
|
+
|
202
|
+
```ruby
|
203
|
+
module Orb::Models::BillingCycleRelativeDate
|
204
|
+
# This alias aids language service driven navigation.
|
205
|
+
TaggedSymbol = T.type_alias { T.all(Symbol, Orb::Models::BillingCycleRelativeDate) }
|
206
|
+
end
|
207
|
+
```
|
208
|
+
|
209
|
+
#### Argument passing trick
|
210
|
+
|
211
|
+
It is possible to pass a compatible model / parameter class to a method that expects keyword arguments by using the `**` splat operator.
|
212
|
+
|
213
|
+
```ruby
|
214
|
+
params = Orb::Models::CustomerCreateParams.new(email: "example-customer@withorb.com", name: "My Customer")
|
215
|
+
orb.customers.create(**params)
|
216
|
+
```
|
217
|
+
|
212
218
|
## Versioning
|
213
219
|
|
214
220
|
This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.
|
@@ -218,3 +224,7 @@ This package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` typ
|
|
218
224
|
## Requirements
|
219
225
|
|
220
226
|
Ruby 3.1.0 or higher.
|
227
|
+
|
228
|
+
## Contributing
|
229
|
+
|
230
|
+
See [the contributing documentation](https://github.com/orbcorp/orb-ruby/tree/main/CONTRIBUTING.md).
|
data/lib/orb/client.rb
CHANGED
@@ -76,7 +76,8 @@ module Orb
|
|
76
76
|
#
|
77
77
|
# @param api_key [String, nil] Defaults to `ENV["ORB_API_KEY"]`
|
78
78
|
#
|
79
|
-
# @param base_url [String, nil] Override the default base URL for the API, e.g.,
|
79
|
+
# @param base_url [String, nil] Override the default base URL for the API, e.g.,
|
80
|
+
# `"https://api.example.com/v2/"`. Defaults to `ENV["ORB_BASE_URL"]`
|
80
81
|
#
|
81
82
|
# @param max_retries [Integer] Max number of retries to attempt after a failed retryable request.
|
82
83
|
#
|
@@ -89,11 +90,11 @@ module Orb
|
|
89
90
|
# @param idempotency_header [String]
|
90
91
|
def initialize(
|
91
92
|
api_key: ENV["ORB_API_KEY"],
|
92
|
-
base_url:
|
93
|
-
max_retries: DEFAULT_MAX_RETRIES,
|
94
|
-
timeout: DEFAULT_TIMEOUT_IN_SECONDS,
|
95
|
-
initial_retry_delay: DEFAULT_INITIAL_RETRY_DELAY,
|
96
|
-
max_retry_delay: DEFAULT_MAX_RETRY_DELAY,
|
93
|
+
base_url: ENV["ORB_BASE_URL"],
|
94
|
+
max_retries: Orb::Client::DEFAULT_MAX_RETRIES,
|
95
|
+
timeout: Orb::Client::DEFAULT_TIMEOUT_IN_SECONDS,
|
96
|
+
initial_retry_delay: Orb::Client::DEFAULT_INITIAL_RETRY_DELAY,
|
97
|
+
max_retry_delay: Orb::Client::DEFAULT_MAX_RETRY_DELAY,
|
97
98
|
idempotency_header: "Idempotency-Key"
|
98
99
|
)
|
99
100
|
base_url ||= "https://api.withorb.com/v1"
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orb
|
4
|
+
class FilePart
|
5
|
+
# @return [Pathname, StringIO, IO, String]
|
6
|
+
attr_reader :content
|
7
|
+
|
8
|
+
# @return [String, nil]
|
9
|
+
attr_reader :content_type
|
10
|
+
|
11
|
+
# @return [String, nil]
|
12
|
+
attr_reader :filename
|
13
|
+
|
14
|
+
# @api private
|
15
|
+
#
|
16
|
+
# @return [String]
|
17
|
+
private def read
|
18
|
+
case content
|
19
|
+
in Pathname
|
20
|
+
content.read(binmode: true)
|
21
|
+
in StringIO
|
22
|
+
content.string
|
23
|
+
in IO
|
24
|
+
content.read
|
25
|
+
in String
|
26
|
+
content
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# @param a [Object]
|
31
|
+
#
|
32
|
+
# @return [String]
|
33
|
+
def to_json(*a) = read.to_json(*a)
|
34
|
+
|
35
|
+
# @param a [Object]
|
36
|
+
#
|
37
|
+
# @return [String]
|
38
|
+
def to_yaml(*a) = read.to_yaml(*a)
|
39
|
+
|
40
|
+
# @param content [Pathname, StringIO, IO, String]
|
41
|
+
# @param filename [String, nil]
|
42
|
+
# @param content_type [String, nil]
|
43
|
+
def initialize(content, filename: nil, content_type: nil)
|
44
|
+
@content = content
|
45
|
+
@filename =
|
46
|
+
case content
|
47
|
+
in Pathname
|
48
|
+
filename.nil? ? content.basename.to_path : File.basename(filename)
|
49
|
+
else
|
50
|
+
filename.nil? ? nil : File.basename(filename)
|
51
|
+
end
|
52
|
+
@content_type = content_type
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/orb/internal/page.rb
CHANGED
@@ -22,40 +22,13 @@ module Orb
|
|
22
22
|
# @return [PaginationMetadata]
|
23
23
|
attr_accessor :pagination_metadata
|
24
24
|
|
25
|
-
# @api private
|
26
|
-
#
|
27
|
-
# @param client [Orb::Internal::Transport::BaseClient]
|
28
|
-
# @param req [Hash{Symbol=>Object}]
|
29
|
-
# @param headers [Hash{String=>String}, Net::HTTPHeader]
|
30
|
-
# @param page_data [Hash{Symbol=>Object}]
|
31
|
-
def initialize(client:, req:, headers:, page_data:)
|
32
|
-
super
|
33
|
-
model = req.fetch(:model)
|
34
|
-
|
35
|
-
case page_data
|
36
|
-
in {data: Array | nil => data}
|
37
|
-
@data = data&.map { Orb::Internal::Type::Converter.coerce(model, _1) }
|
38
|
-
else
|
39
|
-
end
|
40
|
-
|
41
|
-
case page_data
|
42
|
-
in {pagination_metadata: Hash | nil => pagination_metadata}
|
43
|
-
@pagination_metadata =
|
44
|
-
Orb::Internal::Type::Converter.coerce(
|
45
|
-
Orb::Internal::Page::PaginationMetadata,
|
46
|
-
pagination_metadata
|
47
|
-
)
|
48
|
-
else
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
25
|
# @return [Boolean]
|
53
26
|
def next_page?
|
54
27
|
!pagination_metadata&.next_cursor.nil?
|
55
28
|
end
|
56
29
|
|
57
30
|
# @raise [Orb::HTTP::Error]
|
58
|
-
# @return [
|
31
|
+
# @return [self]
|
59
32
|
def next_page
|
60
33
|
unless next_page?
|
61
34
|
message = "No more pages available. Please check #next_page? before calling ##{__method__}"
|
@@ -73,19 +46,48 @@ module Orb
|
|
73
46
|
unless block_given?
|
74
47
|
raise ArgumentError.new("A block must be given to ##{__method__}")
|
75
48
|
end
|
49
|
+
|
76
50
|
page = self
|
77
51
|
loop do
|
78
|
-
page.data&.each
|
52
|
+
page.data&.each(&blk)
|
53
|
+
|
79
54
|
break unless page.next_page?
|
80
55
|
page = page.next_page
|
81
56
|
end
|
82
57
|
end
|
83
58
|
|
59
|
+
# @api private
|
60
|
+
#
|
61
|
+
# @param client [Orb::Internal::Transport::BaseClient]
|
62
|
+
# @param req [Hash{Symbol=>Object}]
|
63
|
+
# @param headers [Hash{String=>String}, Net::HTTPHeader]
|
64
|
+
# @param page_data [Hash{Symbol=>Object}]
|
65
|
+
def initialize(client:, req:, headers:, page_data:)
|
66
|
+
super
|
67
|
+
|
68
|
+
case page_data
|
69
|
+
in {data: Array | nil => data}
|
70
|
+
@data = data&.map { Orb::Internal::Type::Converter.coerce(@model, _1) }
|
71
|
+
else
|
72
|
+
end
|
73
|
+
case page_data
|
74
|
+
in {pagination_metadata: Hash | nil => pagination_metadata}
|
75
|
+
@pagination_metadata =
|
76
|
+
Orb::Internal::Type::Converter.coerce(
|
77
|
+
Orb::Internal::Page::PaginationMetadata,
|
78
|
+
pagination_metadata
|
79
|
+
)
|
80
|
+
else
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# @api private
|
85
|
+
#
|
84
86
|
# @return [String]
|
85
87
|
def inspect
|
86
|
-
|
87
|
-
|
88
|
-
#
|
88
|
+
model = Orb::Internal::Type::Converter.inspect(@model, depth: 1)
|
89
|
+
|
90
|
+
"#<#{self.class}[#{model}]:0x#{object_id.to_s(16)}>"
|
89
91
|
end
|
90
92
|
|
91
93
|
class PaginationMetadata < Orb::Internal::Type::BaseModel
|
@@ -99,13 +101,9 @@ module Orb
|
|
99
101
|
# @return [String, nil]
|
100
102
|
required :next_cursor, String, nil?: true
|
101
103
|
|
102
|
-
# @!
|
103
|
-
#
|
104
|
-
#
|
105
|
-
# #
|
106
|
-
# def initialize(has_more:, next_cursor:, **) = super
|
107
|
-
|
108
|
-
# def initialize: (Hash | Orb::Internal::Type::BaseModel) -> void
|
104
|
+
# @!method initialize(has_more:, next_cursor:)
|
105
|
+
# @param has_more [Boolean]
|
106
|
+
# @param next_cursor [String, nil]
|
109
107
|
end
|
110
108
|
end
|
111
109
|
end
|
@@ -93,7 +93,11 @@ module Orb
|
|
93
93
|
URI.join(url, response_headers["location"])
|
94
94
|
rescue ArgumentError
|
95
95
|
message = "Server responded with status #{status} but no valid location header."
|
96
|
-
raise Orb::Errors::APIConnectionError.new(
|
96
|
+
raise Orb::Errors::APIConnectionError.new(
|
97
|
+
url: url,
|
98
|
+
response: response_headers,
|
99
|
+
message: message
|
100
|
+
)
|
97
101
|
end
|
98
102
|
|
99
103
|
request = {**request, url: location}
|
@@ -101,7 +105,11 @@ module Orb
|
|
101
105
|
case [url.scheme, location.scheme]
|
102
106
|
in ["https", "http"]
|
103
107
|
message = "Tried to redirect to a insecure URL"
|
104
|
-
raise Orb::Errors::APIConnectionError.new(
|
108
|
+
raise Orb::Errors::APIConnectionError.new(
|
109
|
+
url: url,
|
110
|
+
response: response_headers,
|
111
|
+
message: message
|
112
|
+
)
|
105
113
|
else
|
106
114
|
nil
|
107
115
|
end
|
@@ -145,7 +153,7 @@ module Orb
|
|
145
153
|
|
146
154
|
# @api private
|
147
155
|
# @return [Orb::Internal::Transport::PooledNetRequester]
|
148
|
-
|
156
|
+
attr_reader :requester
|
149
157
|
|
150
158
|
# @api private
|
151
159
|
#
|
@@ -206,11 +214,11 @@ module Orb
|
|
206
214
|
#
|
207
215
|
# @option req [Object, nil] :body
|
208
216
|
#
|
209
|
-
# @option req [Symbol, nil] :unwrap
|
217
|
+
# @option req [Symbol, Integer, Array<Symbol, Integer>, Proc, nil] :unwrap
|
210
218
|
#
|
211
|
-
# @option req [Class
|
219
|
+
# @option req [Class<Orb::Internal::Type::BasePage>, nil] :page
|
212
220
|
#
|
213
|
-
# @option req [Class
|
221
|
+
# @option req [Class<Orb::Internal::Type::BaseStream>, nil] :stream
|
214
222
|
#
|
215
223
|
# @option req [Orb::Internal::Type::Converter, Class, nil] :model
|
216
224
|
#
|
@@ -245,7 +253,7 @@ module Orb
|
|
245
253
|
|
246
254
|
if @idempotency_header &&
|
247
255
|
!headers.key?(@idempotency_header) &&
|
248
|
-
!Net::HTTP::IDEMPOTENT_METHODS_.include?(method.to_s.upcase)
|
256
|
+
(!Net::HTTP::IDEMPOTENT_METHODS_.include?(method.to_s.upcase) || opts.key?(:idempotency_key))
|
249
257
|
headers[@idempotency_header] = opts.fetch(:idempotency_key) { generate_idempotency_key }
|
250
258
|
end
|
251
259
|
|
@@ -350,7 +358,7 @@ module Orb
|
|
350
358
|
self.class.reap_connection!(status, stream: stream)
|
351
359
|
|
352
360
|
message = "Failed to complete the request within #{self.class::MAX_REDIRECTS} redirects."
|
353
|
-
raise Orb::Errors::APIConnectionError.new(url: url, message: message)
|
361
|
+
raise Orb::Errors::APIConnectionError.new(url: url, response: response, message: message)
|
354
362
|
in 300..399
|
355
363
|
self.class.reap_connection!(status, stream: stream)
|
356
364
|
|
@@ -407,11 +415,11 @@ module Orb
|
|
407
415
|
#
|
408
416
|
# @param body [Object, nil]
|
409
417
|
#
|
410
|
-
# @param unwrap [Symbol, nil]
|
418
|
+
# @param unwrap [Symbol, Integer, Array<Symbol, Integer>, Proc, nil]
|
411
419
|
#
|
412
|
-
# @param page [Class
|
420
|
+
# @param page [Class<Orb::Internal::Type::BasePage>, nil]
|
413
421
|
#
|
414
|
-
# @param stream [Class
|
422
|
+
# @param stream [Class<Orb::Internal::Type::BaseStream>, nil]
|
415
423
|
#
|
416
424
|
# @param model [Orb::Internal::Type::Converter, Class, nil]
|
417
425
|
#
|
@@ -460,6 +468,8 @@ module Orb
|
|
460
468
|
end
|
461
469
|
end
|
462
470
|
|
471
|
+
# @api private
|
472
|
+
#
|
463
473
|
# @return [String]
|
464
474
|
def inspect
|
465
475
|
# rubocop:disable Layout/LineLength
|
@@ -61,7 +61,7 @@ module Orb
|
|
61
61
|
method.to_s.upcase,
|
62
62
|
!body.nil?,
|
63
63
|
method != :head,
|
64
|
-
url.to_s
|
64
|
+
URI(url.to_s) # ensure we construct a URI class of the right scheme
|
65
65
|
)
|
66
66
|
|
67
67
|
headers.each { req[_1] = _2 }
|
@@ -149,7 +149,7 @@ module Orb
|
|
149
149
|
break if finished
|
150
150
|
|
151
151
|
rsp.read_body do |bytes|
|
152
|
-
y << bytes
|
152
|
+
y << bytes.force_encoding(Encoding::BINARY)
|
153
153
|
break if finished
|
154
154
|
|
155
155
|
self.class.calibrate_socket_timeout(conn, deadline)
|
@@ -176,7 +176,7 @@ module Orb
|
|
176
176
|
conn.finish if !eof && conn&.started?
|
177
177
|
closing&.call
|
178
178
|
end
|
179
|
-
[Integer(response.code), response,
|
179
|
+
[Integer(response.code), response, body]
|
180
180
|
end
|
181
181
|
|
182
182
|
# @api private
|
@@ -13,6 +13,10 @@ module Orb
|
|
13
13
|
class ArrayOf
|
14
14
|
include Orb::Internal::Type::Converter
|
15
15
|
|
16
|
+
private_class_method :new
|
17
|
+
|
18
|
+
# @overload [](type_info, spec = {})
|
19
|
+
#
|
16
20
|
# @param type_info [Hash{Symbol=>Object}, Proc, Orb::Internal::Type::Converter, Class]
|
17
21
|
#
|
18
22
|
# @param spec [Hash{Symbol=>Object}] .
|
@@ -24,13 +28,19 @@ module Orb
|
|
24
28
|
# @option spec [Proc] :union
|
25
29
|
#
|
26
30
|
# @option spec [Boolean] :"nil?"
|
27
|
-
|
31
|
+
#
|
32
|
+
# @return [Orb::Internal::Type::ArrayOf]
|
33
|
+
def self.[](...) = new(...)
|
28
34
|
|
35
|
+
# @api public
|
36
|
+
#
|
29
37
|
# @param other [Object]
|
30
38
|
#
|
31
39
|
# @return [Boolean]
|
32
40
|
def ===(other) = other.is_a?(Array) && other.all?(item_type)
|
33
41
|
|
42
|
+
# @api public
|
43
|
+
#
|
34
44
|
# @param other [Object]
|
35
45
|
#
|
36
46
|
# @return [Boolean]
|
@@ -40,6 +50,11 @@ module Orb
|
|
40
50
|
# rubocop:enable Layout/LineLength
|
41
51
|
end
|
42
52
|
|
53
|
+
# @api public
|
54
|
+
#
|
55
|
+
# @return [Integer]
|
56
|
+
def hash = [self.class, item_type].hash
|
57
|
+
|
43
58
|
# @api private
|
44
59
|
#
|
45
60
|
# @param value [Array<Object>, Object]
|
@@ -120,7 +135,18 @@ module Orb
|
|
120
135
|
# @option spec [Boolean] :"nil?"
|
121
136
|
def initialize(type_info, spec = {})
|
122
137
|
@item_type_fn = Orb::Internal::Type::Converter.type_info(type_info || spec)
|
123
|
-
@nilable = spec
|
138
|
+
@nilable = spec.fetch(:nil?, false)
|
139
|
+
end
|
140
|
+
|
141
|
+
# @api private
|
142
|
+
#
|
143
|
+
# @param depth [Integer]
|
144
|
+
#
|
145
|
+
# @return [String]
|
146
|
+
def inspect(depth: 0)
|
147
|
+
items = Orb::Internal::Type::Converter.inspect(item_type, depth: depth.succ)
|
148
|
+
|
149
|
+
"#{self.class}[#{[items, nilable? ? 'nil' : nil].compact.join(' | ')}]"
|
124
150
|
end
|
125
151
|
end
|
126
152
|
end
|