cbox_billing 0.1.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 +7 -0
- data/README.md +215 -0
- data/cbox_billing.gemspec +26 -0
- data/lib/cbox_billing/api/accounting_api.rb +1893 -0
- data/lib/cbox_billing/api/affiliates_api.rb +2009 -0
- data/lib/cbox_billing/api/agreements_api.rb +552 -0
- data/lib/cbox_billing/api/bank_reconciliation_api.rb +505 -0
- data/lib/cbox_billing/api/catalog_api.rb +361 -0
- data/lib/cbox_billing/api/checkout_portal_api.rb +696 -0
- data/lib/cbox_billing/api/coupons_api.rb +538 -0
- data/lib/cbox_billing/api/credit_notes_api.rb +403 -0
- data/lib/cbox_billing/api/disputes_api.rb +540 -0
- data/lib/cbox_billing/api/dunning_api.rb +902 -0
- data/lib/cbox_billing/api/enforcement_api.rb +746 -0
- data/lib/cbox_billing/api/environments_api.rb +343 -0
- data/lib/cbox_billing/api/invoices_api.rb +1662 -0
- data/lib/cbox_billing/api/licence_data_api.rb +619 -0
- data/lib/cbox_billing/api/licenses_api.rb +293 -0
- data/lib/cbox_billing/api/management_api.rb +253 -0
- data/lib/cbox_billing/api/meters_api.rb +538 -0
- data/lib/cbox_billing/api/orders_and_delivery_api.rb +1745 -0
- data/lib/cbox_billing/api/organizations_api.rb +1110 -0
- data/lib/cbox_billing/api/payment_gateways_api.rb +227 -0
- data/lib/cbox_billing/api/payment_intents_api.rb +376 -0
- data/lib/cbox_billing/api/payment_methods_api.rb +96 -0
- data/lib/cbox_billing/api/plans_api.rb +654 -0
- data/lib/cbox_billing/api/product_access_api.rb +2033 -0
- data/lib/cbox_billing/api/quotes_api.rb +1062 -0
- data/lib/cbox_billing/api/seats_api.rb +938 -0
- data/lib/cbox_billing/api/service_connections_api.rb +245 -0
- data/lib/cbox_billing/api/subscriptions_api.rb +4697 -0
- data/lib/cbox_billing/api/tax_returns_api.rb +453 -0
- data/lib/cbox_billing/api/test_mode_api.rb +96 -0
- data/lib/cbox_billing/api/usage_api.rb +1116 -0
- data/lib/cbox_billing/api/webhook_endpoints_api.rb +835 -0
- data/lib/cbox_billing/api_client.rb +441 -0
- data/lib/cbox_billing/api_error.rb +58 -0
- data/lib/cbox_billing/api_model_base.rb +88 -0
- data/lib/cbox_billing/client.rb +49 -0
- data/lib/cbox_billing/configuration.rb +408 -0
- data/lib/cbox_billing/enforcement/client.rb +665 -0
- data/lib/cbox_billing/enforcement/errors.rb +48 -0
- data/lib/cbox_billing/enforcement/stores.rb +129 -0
- data/lib/cbox_billing/enforcement/transport.rb +79 -0
- data/lib/cbox_billing/enforcement/types.rb +63 -0
- data/lib/cbox_billing/enforcement.rb +9 -0
- data/lib/cbox_billing/errors.rb +110 -0
- data/lib/cbox_billing/idempotency.rb +16 -0
- data/lib/cbox_billing/models/accept_agreement201_response.rb +177 -0
- data/lib/cbox_billing/models/accept_agreement_request.rb +294 -0
- data/lib/cbox_billing/models/accept_agreement_request_user.rb +202 -0
- data/lib/cbox_billing/models/access_balance.rb +276 -0
- data/lib/cbox_billing/models/access_balance_request.rb +309 -0
- data/lib/cbox_billing/models/access_batch.rb +321 -0
- data/lib/cbox_billing/models/access_batch_filters.rb +183 -0
- data/lib/cbox_billing/models/access_cancel_request.rb +207 -0
- data/lib/cbox_billing/models/access_commit_request.rb +207 -0
- data/lib/cbox_billing/models/access_entry.rb +383 -0
- data/lib/cbox_billing/models/access_grant.rb +287 -0
- data/lib/cbox_billing/models/access_grant_request.rb +310 -0
- data/lib/cbox_billing/models/access_invitation.rb +404 -0
- data/lib/cbox_billing/models/access_invite_request.rb +337 -0
- data/lib/cbox_billing/models/access_join_request.rb +369 -0
- data/lib/cbox_billing/models/access_program.rb +511 -0
- data/lib/cbox_billing/models/access_program_input.rb +433 -0
- data/lib/cbox_billing/models/access_redeem_request.rb +335 -0
- data/lib/cbox_billing/models/access_redemption.rb +394 -0
- data/lib/cbox_billing/models/access_report.rb +250 -0
- data/lib/cbox_billing/models/access_report_balances.rb +252 -0
- data/lib/cbox_billing/models/access_report_batches.rb +252 -0
- data/lib/cbox_billing/models/access_report_entries.rb +252 -0
- data/lib/cbox_billing/models/access_report_grants.rb +252 -0
- data/lib/cbox_billing/models/access_report_invitations.rb +252 -0
- data/lib/cbox_billing/models/access_report_redemptions.rb +252 -0
- data/lib/cbox_billing/models/access_restore_grant_request.rb +207 -0
- data/lib/cbox_billing/models/access_retry_delivery_request.rb +207 -0
- data/lib/cbox_billing/models/access_revoke_grant_request.rb +207 -0
- data/lib/cbox_billing/models/access_revoke_invitation200_response.rb +195 -0
- data/lib/cbox_billing/models/access_revoke_invitation_request.rb +207 -0
- data/lib/cbox_billing/models/access_select200_response.rb +356 -0
- data/lib/cbox_billing/models/access_select_request.rb +323 -0
- data/lib/cbox_billing/models/account_credit.rb +258 -0
- data/lib/cbox_billing/models/account_credit_movements_inner.rb +255 -0
- data/lib/cbox_billing/models/account_entitlement.rb +240 -0
- data/lib/cbox_billing/models/accounting_connection.rb +336 -0
- data/lib/cbox_billing/models/accounting_connection_company.rb +170 -0
- data/lib/cbox_billing/models/accounting_contact_conflict.rb +308 -0
- data/lib/cbox_billing/models/accounting_contact_import.rb +397 -0
- data/lib/cbox_billing/models/accounting_contact_import_counts.rb +308 -0
- data/lib/cbox_billing/models/accounting_contact_import_row.rb +363 -0
- data/lib/cbox_billing/models/accounting_contact_import_row_candidates_inner.rb +227 -0
- data/lib/cbox_billing/models/accounting_contact_sync.rb +351 -0
- data/lib/cbox_billing/models/accounting_contact_sync_failure.rb +266 -0
- data/lib/cbox_billing/models/accounting_customer_document.rb +318 -0
- data/lib/cbox_billing/models/accounting_customer_link.rb +354 -0
- data/lib/cbox_billing/models/accounting_customer_link_company.rb +180 -0
- data/lib/cbox_billing/models/accounting_customer_link_contact.rb +292 -0
- data/lib/cbox_billing/models/accounting_customer_link_contact_sync.rb +291 -0
- data/lib/cbox_billing/models/accounting_customer_link_contact_sync_conflicts_inner.rb +237 -0
- data/lib/cbox_billing/models/accounting_customer_link_several_contacts_inner.rb +227 -0
- data/lib/cbox_billing/models/accounting_customer_link_shared_with_inner.rb +203 -0
- data/lib/cbox_billing/models/accounting_invoice.rb +532 -0
- data/lib/cbox_billing/models/accounting_invoice_contact.rb +189 -0
- data/lib/cbox_billing/models/accounting_sync.rb +356 -0
- data/lib/cbox_billing/models/accounting_vendor_contact.rb +307 -0
- data/lib/cbox_billing/models/accounting_vendor_link.rb +216 -0
- data/lib/cbox_billing/models/activation_bundle.rb +293 -0
- data/lib/cbox_billing/models/add_dispute_evidence_file201_response.rb +177 -0
- data/lib/cbox_billing/models/add_dispute_evidence_file422_response.rb +104 -0
- data/lib/cbox_billing/models/add_dispute_evidence_file_request.rb +261 -0
- data/lib/cbox_billing/models/add_invoice_item201_response.rb +177 -0
- data/lib/cbox_billing/models/add_invoice_item202_response.rb +228 -0
- data/lib/cbox_billing/models/add_invoice_item_request.rb +248 -0
- data/lib/cbox_billing/models/add_on.rb +305 -0
- data/lib/cbox_billing/models/add_on_preview.rb +170 -0
- data/lib/cbox_billing/models/add_on_request.rb +434 -0
- data/lib/cbox_billing/models/add_on_result.rb +203 -0
- data/lib/cbox_billing/models/add_product_file_request1.rb +233 -0
- data/lib/cbox_billing/models/add_subscription_phase201_response.rb +177 -0
- data/lib/cbox_billing/models/adjust_affiliate_balance_request.rb +257 -0
- data/lib/cbox_billing/models/admit_service_organization200_response.rb +169 -0
- data/lib/cbox_billing/models/affiliate.rb +505 -0
- data/lib/cbox_billing/models/affiliate_commission.rb +520 -0
- data/lib/cbox_billing/models/affiliate_detail.rb +523 -0
- data/lib/cbox_billing/models/affiliate_payout.rb +443 -0
- data/lib/cbox_billing/models/affiliate_payout_run.rb +446 -0
- data/lib/cbox_billing/models/affiliate_payout_run_list.rb +229 -0
- data/lib/cbox_billing/models/affiliate_payout_settings.rb +356 -0
- data/lib/cbox_billing/models/affiliate_portal_link.rb +203 -0
- data/lib/cbox_billing/models/affiliate_program.rb +556 -0
- data/lib/cbox_billing/models/affiliate_program_commission.rb +269 -0
- data/lib/cbox_billing/models/affiliate_rate_plan.rb +273 -0
- data/lib/cbox_billing/models/affiliate_rate_plan_phases_inner.rb +316 -0
- data/lib/cbox_billing/models/affiliate_rate_rule.rb +233 -0
- data/lib/cbox_billing/models/affiliate_referral.rb +325 -0
- data/lib/cbox_billing/models/agreement_block.rb +337 -0
- data/lib/cbox_billing/models/agreement_error.rb +227 -0
- data/lib/cbox_billing/models/agreement_status.rb +453 -0
- data/lib/cbox_billing/models/agreement_status_requires_inner.rb +202 -0
- data/lib/cbox_billing/models/align_renewals_request.rb +264 -0
- data/lib/cbox_billing/models/allowance_window.rb +269 -0
- data/lib/cbox_billing/models/appendix.rb +293 -0
- data/lib/cbox_billing/models/appendix_column.rb +257 -0
- data/lib/cbox_billing/models/apply_catalog409_response.rb +369 -0
- data/lib/cbox_billing/models/apply_subscription_coupon200_response.rb +177 -0
- data/lib/cbox_billing/models/apply_subscription_coupon_request.rb +197 -0
- data/lib/cbox_billing/models/archive_affiliate_program_request.rb +162 -0
- data/lib/cbox_billing/models/auto_top_up.rb +462 -0
- data/lib/cbox_billing/models/auto_top_up_attempts_inner.rb +290 -0
- data/lib/cbox_billing/models/auto_top_up_limits.rb +230 -0
- data/lib/cbox_billing/models/bank_csv_mapping.rb +467 -0
- data/lib/cbox_billing/models/bank_import_result.rb +285 -0
- data/lib/cbox_billing/models/bank_line.rb +486 -0
- data/lib/cbox_billing/models/bank_line_detail.rb +233 -0
- data/lib/cbox_billing/models/bank_line_detail_payments_inner.rb +280 -0
- data/lib/cbox_billing/models/bank_line_detail_suggestions_inner.rb +267 -0
- data/lib/cbox_billing/models/bank_statement.rb +412 -0
- data/lib/cbox_billing/models/bank_statement_import.rb +258 -0
- data/lib/cbox_billing/models/billing_parent.rb +219 -0
- data/lib/cbox_billing/models/billing_policy.rb +299 -0
- data/lib/cbox_billing/models/billing_policy_policy.rb +228 -0
- data/lib/cbox_billing/models/billing_policy_request.rb +323 -0
- data/lib/cbox_billing/models/bundle_benefit.rb +597 -0
- data/lib/cbox_billing/models/bundle_benefit_tiers_inner.rb +230 -0
- data/lib/cbox_billing/models/bundle_consequence.rb +450 -0
- data/lib/cbox_billing/models/bundle_offer.rb +508 -0
- data/lib/cbox_billing/models/bundle_offer_plan.rb +398 -0
- data/lib/cbox_billing/models/bundle_offer_products_to_add_inner.rb +169 -0
- data/lib/cbox_billing/models/bundle_offer_saves.rb +226 -0
- data/lib/cbox_billing/models/cancel_preview.rb +264 -0
- data/lib/cbox_billing/models/cancel_request.rb +256 -0
- data/lib/cbox_billing/models/cancel_subscription200_response.rb +652 -0
- data/lib/cbox_billing/models/catalog_changes.rb +286 -0
- data/lib/cbox_billing/models/catalog_changes_changes_inner.rb +264 -0
- data/lib/cbox_billing/models/catalog_changes_diff_inner.rb +303 -0
- data/lib/cbox_billing/models/catalog_changes_diff_inner_fields_inner.rb +180 -0
- data/lib/cbox_billing/models/catalog_changes_diff_inner_fields_inner_from.rb +105 -0
- data/lib/cbox_billing/models/catalog_changes_impact.rb +215 -0
- data/lib/cbox_billing/models/catalog_changes_impact_bundle_repriced_inner.rb +224 -0
- data/lib/cbox_billing/models/catalog_changes_impact_sample_inner.rb +169 -0
- data/lib/cbox_billing/models/catalog_changes_summary.rb +178 -0
- data/lib/cbox_billing/models/catalog_manifest.rb +215 -0
- data/lib/cbox_billing/models/catalog_manifest_bundles_inner.rb +344 -0
- data/lib/cbox_billing/models/catalog_manifest_bundles_inner_applies_to.rb +199 -0
- data/lib/cbox_billing/models/catalog_manifest_bundles_inner_copy_value.rb +263 -0
- data/lib/cbox_billing/models/catalog_manifest_bundles_inner_discount.rb +286 -0
- data/lib/cbox_billing/models/catalog_manifest_bundles_inner_requires.rb +254 -0
- data/lib/cbox_billing/models/catalog_manifest_existing.rb +242 -0
- data/lib/cbox_billing/models/catalog_manifest_products_inner.rb +246 -0
- data/lib/cbox_billing/models/catalog_manifest_products_inner_features_inner.rb +269 -0
- data/lib/cbox_billing/models/catalog_manifest_products_inner_meters_inner.rb +410 -0
- data/lib/cbox_billing/models/catalog_manifest_products_inner_plans_inner.rb +258 -0
- data/lib/cbox_billing/models/catalog_manifest_products_inner_plans_inner_meters_value.rb +356 -0
- data/lib/cbox_billing/models/catalog_manifest_products_inner_plans_inner_meters_value_price_value.rb +471 -0
- data/lib/cbox_billing/models/catalog_manifest_products_inner_plans_inner_meters_value_price_value_matrix_inner.rb +274 -0
- data/lib/cbox_billing/models/catalog_manifest_products_inner_plans_inner_meters_value_price_value_rates_inner.rb +216 -0
- data/lib/cbox_billing/models/change_subscription_dates200_response.rb +187 -0
- data/lib/cbox_billing/models/change_subscription_dates_request.rb +325 -0
- data/lib/cbox_billing/models/charged_invoice.rb +322 -0
- data/lib/cbox_billing/models/check_service_admission200_response.rb +178 -0
- data/lib/cbox_billing/models/checkout_session_request.rb +354 -0
- data/lib/cbox_billing/models/checkout_session_request_items_inner.rb +217 -0
- data/lib/cbox_billing/models/choose_accounting_contact_import_row200_response.rb +177 -0
- data/lib/cbox_billing/models/clear_subscription_end_date200_response.rb +162 -0
- data/lib/cbox_billing/models/commit_request.rb +214 -0
- data/lib/cbox_billing/models/commit_request_actuals_inner.rb +212 -0
- data/lib/cbox_billing/models/commitment.rb +499 -0
- data/lib/cbox_billing/models/commitment_ramp_step.rb +221 -0
- data/lib/cbox_billing/models/commitment_refusal.rb +239 -0
- data/lib/cbox_billing/models/commitment_request.rb +409 -0
- data/lib/cbox_billing/models/commitment_response.rb +203 -0
- data/lib/cbox_billing/models/commitment_term.rb +227 -0
- data/lib/cbox_billing/models/confirm_accounting_contact_import200_response.rb +177 -0
- data/lib/cbox_billing/models/confirm_accounting_contact_import_request.rb +190 -0
- data/lib/cbox_billing/models/connect_engage_service200_response.rb +212 -0
- data/lib/cbox_billing/models/connect_engage_service_request.rb +267 -0
- data/lib/cbox_billing/models/contract_cap_discount.rb +284 -0
- data/lib/cbox_billing/models/contract_price_cap.rb +332 -0
- data/lib/cbox_billing/models/contract_price_cap_basis.rb +216 -0
- data/lib/cbox_billing/models/coupon.rb +307 -0
- data/lib/cbox_billing/models/coupon_definition.rb +520 -0
- data/lib/cbox_billing/models/coupon_definition_detail.rb +555 -0
- data/lib/cbox_billing/models/coupon_definition_detail_all_of_redemptions.rb +216 -0
- data/lib/cbox_billing/models/coupon_definition_list.rb +226 -0
- data/lib/cbox_billing/models/coupon_deleted.rb +227 -0
- data/lib/cbox_billing/models/coupon_request.rb +537 -0
- data/lib/cbox_billing/models/create_affiliate_payout_request.rb +247 -0
- data/lib/cbox_billing/models/create_affiliate_program_request.rb +423 -0
- data/lib/cbox_billing/models/create_affiliate_program_request_commission.rb +348 -0
- data/lib/cbox_billing/models/create_affiliate_referral_request.rb +178 -0
- data/lib/cbox_billing/models/create_affiliate_request.rb +415 -0
- data/lib/cbox_billing/models/create_credit_purchase422_response.rb +104 -0
- data/lib/cbox_billing/models/create_customers_from_accounting_contact_import200_response.rb +207 -0
- data/lib/cbox_billing/models/create_customers_from_accounting_contact_import200_response_created_inner.rb +204 -0
- data/lib/cbox_billing/models/create_customers_from_accounting_contact_import200_response_refused_inner.rb +204 -0
- data/lib/cbox_billing/models/create_customers_from_accounting_contact_import_request.rb +197 -0
- data/lib/cbox_billing/models/create_download_grant_request.rb +248 -0
- data/lib/cbox_billing/models/create_download_links200_response.rb +205 -0
- data/lib/cbox_billing/models/create_download_links200_response_data_inner.rb +227 -0
- data/lib/cbox_billing/models/create_download_links_request.rb +190 -0
- data/lib/cbox_billing/models/create_environment_request.rb +270 -0
- data/lib/cbox_billing/models/create_license_key_request.rb +273 -0
- data/lib/cbox_billing/models/create_order_request.rb +420 -0
- data/lib/cbox_billing/models/create_order_request_lines_inner.rb +262 -0
- data/lib/cbox_billing/models/create_private_plan_request.rb +318 -0
- data/lib/cbox_billing/models/create_spend_alert_request.rb +295 -0
- data/lib/cbox_billing/models/created_access_invitation.rb +464 -0
- data/lib/cbox_billing/models/created_environment.rb +214 -0
- data/lib/cbox_billing/models/credit_adjustment_applied.rb +247 -0
- data/lib/cbox_billing/models/credit_adjustment_pending.rb +228 -0
- data/lib/cbox_billing/models/credit_adjustment_request.rb +375 -0
- data/lib/cbox_billing/models/credit_delta.rb +229 -0
- data/lib/cbox_billing/models/credit_movement.rb +364 -0
- data/lib/cbox_billing/models/credit_movement_list.rb +226 -0
- data/lib/cbox_billing/models/credit_note.rb +455 -0
- data/lib/cbox_billing/models/credit_note_detail.rb +517 -0
- data/lib/cbox_billing/models/credit_note_detail_all_of_lines.rb +294 -0
- data/lib/cbox_billing/models/credit_note_list.rb +226 -0
- data/lib/cbox_billing/models/credit_pool.rb +567 -0
- data/lib/cbox_billing/models/credit_pool_expiries_inner.rb +241 -0
- data/lib/cbox_billing/models/credit_pool_label.rb +204 -0
- data/lib/cbox_billing/models/credit_pool_list.rb +205 -0
- data/lib/cbox_billing/models/credit_pool_pay_as_you_go.rb +218 -0
- data/lib/cbox_billing/models/credit_pool_period.rb +175 -0
- data/lib/cbox_billing/models/credit_pool_scope.rb +207 -0
- data/lib/cbox_billing/models/credit_pool_scope_conditions_inner.rb +256 -0
- data/lib/cbox_billing/models/credit_purchase.rb +306 -0
- data/lib/cbox_billing/models/credit_purchase_credit.rb +203 -0
- data/lib/cbox_billing/models/customer_contract.rb +227 -0
- data/lib/cbox_billing/models/customer_overage_cap_row.rb +345 -0
- data/lib/cbox_billing/models/customer_overage_cap_row_customer.rb +202 -0
- data/lib/cbox_billing/models/date_change_preview.rb +370 -0
- data/lib/cbox_billing/models/date_change_request.rb +272 -0
- data/lib/cbox_billing/models/delete_entitlement_override200_response.rb +204 -0
- data/lib/cbox_billing/models/delete_overage_cap200_response.rb +203 -0
- data/lib/cbox_billing/models/delete_spend_alert200_response.rb +203 -0
- data/lib/cbox_billing/models/delete_webhook_endpoint200_response.rb +239 -0
- data/lib/cbox_billing/models/delivery.rb +339 -0
- data/lib/cbox_billing/models/destroy_environment200_response.rb +178 -0
- data/lib/cbox_billing/models/detach_payment_method422_response.rb +253 -0
- data/lib/cbox_billing/models/detach_payment_method422_response_errors.rb +162 -0
- data/lib/cbox_billing/models/directory_registration.rb +244 -0
- data/lib/cbox_billing/models/directory_service.rb +472 -0
- data/lib/cbox_billing/models/disable_license_key_request.rb +161 -0
- data/lib/cbox_billing/models/dispute.rb +471 -0
- data/lib/cbox_billing/models/dispute_detail.rb +229 -0
- data/lib/cbox_billing/models/dispute_detail_evidence.rb +205 -0
- data/lib/cbox_billing/models/dispute_detail_evidence_text.rb +200 -0
- data/lib/cbox_billing/models/dispute_detail_pack.rb +193 -0
- data/lib/cbox_billing/models/dispute_detail_pack_sections_inner.rb +269 -0
- data/lib/cbox_billing/models/dispute_evidence.rb +312 -0
- data/lib/cbox_billing/models/dispute_evidence_file.rb +357 -0
- data/lib/cbox_billing/models/dispute_evidence_slot.rb +43 -0
- data/lib/cbox_billing/models/dispute_refusal.rb +256 -0
- data/lib/cbox_billing/models/dispute_status.rb +46 -0
- data/lib/cbox_billing/models/download_grant.rb +401 -0
- data/lib/cbox_billing/models/dunning_hold.rb +344 -0
- data/lib/cbox_billing/models/dunning_state.rb +217 -0
- data/lib/cbox_billing/models/dunning_state_invoice.rb +281 -0
- data/lib/cbox_billing/models/dunning_state_retry.rb +232 -0
- data/lib/cbox_billing/models/e_invoice_refusal.rb +229 -0
- data/lib/cbox_billing/models/effective_billing_policy.rb +298 -0
- data/lib/cbox_billing/models/effective_entitlement.rb +271 -0
- data/lib/cbox_billing/models/effective_usage_threshold.rb +280 -0
- data/lib/cbox_billing/models/entitlement.rb +366 -0
- data/lib/cbox_billing/models/entitlement_override.rb +557 -0
- data/lib/cbox_billing/models/entitlement_override_input.rb +353 -0
- data/lib/cbox_billing/models/entitlement_override_result.rb +591 -0
- data/lib/cbox_billing/models/entitlement_terms.rb +293 -0
- data/lib/cbox_billing/models/entitlements_response.rb +200 -0
- data/lib/cbox_billing/models/environment.rb +379 -0
- data/lib/cbox_billing/models/error_body.rb +242 -0
- data/lib/cbox_billing/models/export_catalog200_response.rb +232 -0
- data/lib/cbox_billing/models/extend_invoice_due_date_request.rb +213 -0
- data/lib/cbox_billing/models/feature.rb +277 -0
- data/lib/cbox_billing/models/feature_check.rb +310 -0
- data/lib/cbox_billing/models/feature_set.rb +179 -0
- data/lib/cbox_billing/models/feature_value.rb +105 -0
- data/lib/cbox_billing/models/first_period.rb +461 -0
- data/lib/cbox_billing/models/gateway_intent.rb +254 -0
- data/lib/cbox_billing/models/get_accounting_connection200_response.rb +163 -0
- data/lib/cbox_billing/models/get_accounting_contact200_response.rb +227 -0
- data/lib/cbox_billing/models/get_accounting_contact_sync200_response.rb +229 -0
- data/lib/cbox_billing/models/get_accounting_invoice_sync200_response.rb +293 -0
- data/lib/cbox_billing/models/get_accounting_invoice_sync200_response_settings.rb +241 -0
- data/lib/cbox_billing/models/get_accounting_invoice_sync200_response_sync.rb +318 -0
- data/lib/cbox_billing/models/get_accounting_organization200_response.rb +231 -0
- data/lib/cbox_billing/models/get_bank_statement200_response.rb +205 -0
- data/lib/cbox_billing/models/get_customer_statement200_response.rb +339 -0
- data/lib/cbox_billing/models/get_customer_statement200_response_account_credit.rb +169 -0
- data/lib/cbox_billing/models/get_customer_statement200_response_activity_inner.rb +334 -0
- data/lib/cbox_billing/models/get_customer_statement200_response_balances_inner.rb +229 -0
- data/lib/cbox_billing/models/get_customer_statement200_response_subscriptions_inner.rb +281 -0
- data/lib/cbox_billing/models/get_customer_statement200_response_subscriptions_inner_next.rb +200 -0
- data/lib/cbox_billing/models/get_latest_accounting_contact_import200_response.rb +163 -0
- data/lib/cbox_billing/models/get_product_delivery200_response.rb +217 -0
- data/lib/cbox_billing/models/get_resource_limits200_response.rb +257 -0
- data/lib/cbox_billing/models/get_service_admission_policy200_response.rb +160 -0
- data/lib/cbox_billing/models/get_service_registrations200_response.rb +179 -0
- data/lib/cbox_billing/models/get_service_registrations200_response_data_inner.rb +190 -0
- data/lib/cbox_billing/models/get_service_registrations_request.rb +284 -0
- data/lib/cbox_billing/models/grandfathered_subscriber.rb +356 -0
- data/lib/cbox_billing/models/grandfathered_subscriber_contract_cap.rb +230 -0
- data/lib/cbox_billing/models/guest_waitlist_input.rb +271 -0
- data/lib/cbox_billing/models/hold_invoice_dunning_request.rb +249 -0
- data/lib/cbox_billing/models/hold_invoice_for_review200_response.rb +177 -0
- data/lib/cbox_billing/models/hosted_session.rb +204 -0
- data/lib/cbox_billing/models/import_bank_statement201_response.rb +203 -0
- data/lib/cbox_billing/models/inline_object.rb +227 -0
- data/lib/cbox_billing/models/inline_object1.rb +255 -0
- data/lib/cbox_billing/models/inline_object2.rb +255 -0
- data/lib/cbox_billing/models/invoice.rb +523 -0
- data/lib/cbox_billing/models/invoice_balance.rb +281 -0
- data/lib/cbox_billing/models/invoice_detail.rb +655 -0
- data/lib/cbox_billing/models/invoice_draft.rb +452 -0
- data/lib/cbox_billing/models/invoice_draft_lines_inner.rb +199 -0
- data/lib/cbox_billing/models/invoice_item.rb +354 -0
- data/lib/cbox_billing/models/invoice_line.rb +295 -0
- data/lib/cbox_billing/models/invoice_list.rb +226 -0
- data/lib/cbox_billing/models/invoice_payment.rb +292 -0
- data/lib/cbox_billing/models/invoice_payment_result.rb +203 -0
- data/lib/cbox_billing/models/join_service_waitlist200_response.rb +163 -0
- data/lib/cbox_billing/models/join_service_waitlist_as_guest200_response.rb +194 -0
- data/lib/cbox_billing/models/join_service_waitlist_request.rb +378 -0
- data/lib/cbox_billing/models/keep_accounting_contact200_response.rb +231 -0
- data/lib/cbox_billing/models/keep_accounting_contact_request.rb +186 -0
- data/lib/cbox_billing/models/lease.rb +266 -0
- data/lib/cbox_billing/models/lease_request.rb +341 -0
- data/lib/cbox_billing/models/leave_feature_waitlist200_response.rb +201 -0
- data/lib/cbox_billing/models/leave_feature_waitlist_request.rb +249 -0
- data/lib/cbox_billing/models/licence_period_document.rb +408 -0
- data/lib/cbox_billing/models/licence_period_document_usage_measures_inner.rb +170 -0
- data/lib/cbox_billing/models/licence_period_list.rb +230 -0
- data/lib/cbox_billing/models/licence_period_summary.rb +344 -0
- data/lib/cbox_billing/models/licence_reportable.rb +204 -0
- data/lib/cbox_billing/models/licence_row_list.rb +244 -0
- data/lib/cbox_billing/models/licence_seat_count.rb +355 -0
- data/lib/cbox_billing/models/licence_seat_ledger_entry.rb +578 -0
- data/lib/cbox_billing/models/licence_seat_ledger_list.rb +217 -0
- data/lib/cbox_billing/models/licence_seat_snapshot_list.rb +243 -0
- data/lib/cbox_billing/models/license.rb +407 -0
- data/lib/cbox_billing/models/license_issue_request.rb +232 -0
- data/lib/cbox_billing/models/license_key.rb +503 -0
- data/lib/cbox_billing/models/license_key_detail.rb +537 -0
- data/lib/cbox_billing/models/license_key_detail_all_of_instances.rb +277 -0
- data/lib/cbox_billing/models/license_renew_request.rb +160 -0
- data/lib/cbox_billing/models/license_revoke_request.rb +160 -0
- data/lib/cbox_billing/models/license_revoke_result.rb +227 -0
- data/lib/cbox_billing/models/limit_increase_decision.rb +368 -0
- data/lib/cbox_billing/models/limit_increase_input.rb +300 -0
- data/lib/cbox_billing/models/limit_increase_request.rb +516 -0
- data/lib/cbox_billing/models/link_accounting_contact200_response.rb +177 -0
- data/lib/cbox_billing/models/link_accounting_contact_request.rb +187 -0
- data/lib/cbox_billing/models/list_access_programs200_response.rb +252 -0
- data/lib/cbox_billing/models/list_accounting_contact_duplicates200_response.rb +205 -0
- data/lib/cbox_billing/models/list_accounting_contact_duplicates200_response_duplicates_inner.rb +205 -0
- data/lib/cbox_billing/models/list_accounting_contact_duplicates200_response_duplicates_inner_organizations_inner.rb +203 -0
- data/lib/cbox_billing/models/list_accounting_contact_import_rows200_response.rb +192 -0
- data/lib/cbox_billing/models/list_accounting_contact_sync_failures200_response.rb +217 -0
- data/lib/cbox_billing/models/list_accounting_contacts200_response.rb +282 -0
- data/lib/cbox_billing/models/list_accounting_organization_invoices200_response.rb +191 -0
- data/lib/cbox_billing/models/list_accounting_syncs200_response.rb +179 -0
- data/lib/cbox_billing/models/list_affiliate_commissions200_response.rb +226 -0
- data/lib/cbox_billing/models/list_affiliate_payout_runs200_response.rb +226 -0
- data/lib/cbox_billing/models/list_affiliate_payouts200_response.rb +226 -0
- data/lib/cbox_billing/models/list_affiliate_programs200_response.rb +226 -0
- data/lib/cbox_billing/models/list_affiliates200_response.rb +226 -0
- data/lib/cbox_billing/models/list_agreements200_response.rb +179 -0
- data/lib/cbox_billing/models/list_all_invoices400_response.rb +177 -0
- data/lib/cbox_billing/models/list_bank_lines200_response.rb +215 -0
- data/lib/cbox_billing/models/list_bank_statements200_response.rb +215 -0
- data/lib/cbox_billing/models/list_connected_financial_events200_response.rb +292 -0
- data/lib/cbox_billing/models/list_connected_production_environments200_response.rb +205 -0
- data/lib/cbox_billing/models/list_connected_production_environments200_response_data_inner.rb +203 -0
- data/lib/cbox_billing/models/list_customer_dunning_holds200_response.rb +179 -0
- data/lib/cbox_billing/models/list_disputes200_response.rb +217 -0
- data/lib/cbox_billing/models/list_download_grants200_response.rb +226 -0
- data/lib/cbox_billing/models/list_entitlement_overrides200_response.rb +207 -0
- data/lib/cbox_billing/models/list_environments200_response.rb +162 -0
- data/lib/cbox_billing/models/list_financial_events200_response.rb +240 -0
- data/lib/cbox_billing/models/list_financial_events200_response_data_inner.rb +342 -0
- data/lib/cbox_billing/models/list_financial_events200_response_data_inner_data.rb +408 -0
- data/lib/cbox_billing/models/list_grandfathered_subscribers200_response.rb +244 -0
- data/lib/cbox_billing/models/list_invoice_drafts200_response.rb +215 -0
- data/lib/cbox_billing/models/list_invoice_items200_response.rb +179 -0
- data/lib/cbox_billing/models/list_invoice_payments200_response.rb +205 -0
- data/lib/cbox_billing/models/list_license_keys200_response.rb +226 -0
- data/lib/cbox_billing/models/list_limit_increase_requests200_response.rb +231 -0
- data/lib/cbox_billing/models/list_one_off_products200_response.rb +179 -0
- data/lib/cbox_billing/models/list_orders200_response.rb +226 -0
- data/lib/cbox_billing/models/list_organization_purchases200_response.rb +205 -0
- data/lib/cbox_billing/models/list_organization_subscriptions200_response.rb +179 -0
- data/lib/cbox_billing/models/list_overage_caps200_response.rb +179 -0
- data/lib/cbox_billing/models/list_plan_moves200_response.rb +179 -0
- data/lib/cbox_billing/models/list_private_plans200_response.rb +179 -0
- data/lib/cbox_billing/models/list_product_files200_response.rb +179 -0
- data/lib/cbox_billing/models/list_scheduled_catalog_changes200_response.rb +179 -0
- data/lib/cbox_billing/models/list_service_directory200_response.rb +249 -0
- data/lib/cbox_billing/models/list_signed_agreements200_response.rb +226 -0
- data/lib/cbox_billing/models/list_spend_alerts200_response.rb +218 -0
- data/lib/cbox_billing/models/list_spend_alerts200_response_spend.rb +222 -0
- data/lib/cbox_billing/models/list_subscription_date_moves200_response.rb +179 -0
- data/lib/cbox_billing/models/list_subscription_schedule200_response.rb +179 -0
- data/lib/cbox_billing/models/list_tax_return_lines200_response.rb +215 -0
- data/lib/cbox_billing/models/list_tax_returns200_response.rb +215 -0
- data/lib/cbox_billing/models/list_unmatched_accounting_invoices200_response.rb +192 -0
- data/lib/cbox_billing/models/lock_subscription_price_request.rb +162 -0
- data/lib/cbox_billing/models/mark_affiliate_payout_paid_request.rb +176 -0
- data/lib/cbox_billing/models/mark_invoice_paid_request.rb +176 -0
- data/lib/cbox_billing/models/match_bank_line_request.rb +197 -0
- data/lib/cbox_billing/models/match_bank_line_request_allocations_inner.rb +221 -0
- data/lib/cbox_billing/models/meter.rb +524 -0
- data/lib/cbox_billing/models/meter_detail.rb +587 -0
- data/lib/cbox_billing/models/meter_detail_all_of_entitlements.rb +260 -0
- data/lib/cbox_billing/models/meter_list.rb +226 -0
- data/lib/cbox_billing/models/meter_request.rb +463 -0
- data/lib/cbox_billing/models/meter_request_resets.rb +237 -0
- data/lib/cbox_billing/models/meter_resets.rb +279 -0
- data/lib/cbox_billing/models/meter_staged.rb +309 -0
- data/lib/cbox_billing/models/meter_staged_changeset.rb +265 -0
- data/lib/cbox_billing/models/money.rb +222 -0
- data/lib/cbox_billing/models/money_amount.rb +203 -0
- data/lib/cbox_billing/models/move_affiliate_referral_request.rb +213 -0
- data/lib/cbox_billing/models/move_affiliate_request.rb +188 -0
- data/lib/cbox_billing/models/negotiated_price.rb +277 -0
- data/lib/cbox_billing/models/new_auto_top_up.rb +277 -0
- data/lib/cbox_billing/models/new_credit_purchase.rb +271 -0
- data/lib/cbox_billing/models/new_invoice.rb +264 -0
- data/lib/cbox_billing/models/new_invoice_line.rb +295 -0
- data/lib/cbox_billing/models/ok.rb +201 -0
- data/lib/cbox_billing/models/one_off_product.rb +359 -0
- data/lib/cbox_billing/models/one_off_purchase.rb +396 -0
- data/lib/cbox_billing/models/one_off_purchase_items_inner.rb +255 -0
- data/lib/cbox_billing/models/one_off_quote.rb +527 -0
- data/lib/cbox_billing/models/one_off_quote_organization.rb +177 -0
- data/lib/cbox_billing/models/one_off_quote_request.rb +324 -0
- data/lib/cbox_billing/models/order.rb +573 -0
- data/lib/cbox_billing/models/order_items_inner.rb +311 -0
- data/lib/cbox_billing/models/organization.rb +545 -0
- data/lib/cbox_billing/models/organization_accounting_contact.rb +255 -0
- data/lib/cbox_billing/models/organization_bundles.rb +310 -0
- data/lib/cbox_billing/models/organization_bundles_active_inner.rb +242 -0
- data/lib/cbox_billing/models/organization_response.rb +177 -0
- data/lib/cbox_billing/models/organization_upsert_request.rb +666 -0
- data/lib/cbox_billing/models/overage_cap.rb +105 -0
- data/lib/cbox_billing/models/overage_cap_binding.rb +263 -0
- data/lib/cbox_billing/models/overage_cap_one_of.rb +186 -0
- data/lib/cbox_billing/models/overage_cap_one_of1.rb +231 -0
- data/lib/cbox_billing/models/overage_cap_state.rb +380 -0
- data/lib/cbox_billing/models/page.rb +192 -0
- data/lib/cbox_billing/models/payment_gateway_failover.rb +233 -0
- data/lib/cbox_billing/models/payment_gateway_failover_failovers_inner.rb +348 -0
- data/lib/cbox_billing/models/payment_gateway_failover_failovers_inner_hops_inner.rb +190 -0
- data/lib/cbox_billing/models/payment_gateway_failover_gateways_inner.rb +230 -0
- data/lib/cbox_billing/models/payment_gateway_failover_gateways_inner_circuit.rb +288 -0
- data/lib/cbox_billing/models/payment_gateway_failover_routing.rb +235 -0
- data/lib/cbox_billing/models/payment_intent_request.rb +254 -0
- data/lib/cbox_billing/models/payment_mandate.rb +253 -0
- data/lib/cbox_billing/models/payment_method.rb +374 -0
- data/lib/cbox_billing/models/payment_method_id_request.rb +177 -0
- data/lib/cbox_billing/models/payment_method_list.rb +226 -0
- data/lib/cbox_billing/models/payment_method_set.rb +180 -0
- data/lib/cbox_billing/models/payment_terms.rb +281 -0
- data/lib/cbox_billing/models/payment_terms_request.rb +235 -0
- data/lib/cbox_billing/models/pending_approval.rb +229 -0
- data/lib/cbox_billing/models/pending_price_change.rb +257 -0
- data/lib/cbox_billing/models/per_value_entitlements.rb +206 -0
- data/lib/cbox_billing/models/per_value_entitlements_values_value.rb +263 -0
- data/lib/cbox_billing/models/plan.rb +425 -0
- data/lib/cbox_billing/models/plan_change_input.rb +224 -0
- data/lib/cbox_billing/models/plan_change_preview.rb +478 -0
- data/lib/cbox_billing/models/plan_change_preview_seat_types_inner.rb +356 -0
- data/lib/cbox_billing/models/plan_change_price_options.rb +280 -0
- data/lib/cbox_billing/models/plan_change_price_options_keep_negotiated.rb +230 -0
- data/lib/cbox_billing/models/plan_change_request.rb +256 -0
- data/lib/cbox_billing/models/plan_change_result.rb +543 -0
- data/lib/cbox_billing/models/plan_features_value.rb +105 -0
- data/lib/cbox_billing/models/plan_list.rb +253 -0
- data/lib/cbox_billing/models/plan_meter_entitlement.rb +250 -0
- data/lib/cbox_billing/models/plan_move.rb +386 -0
- data/lib/cbox_billing/models/plan_move_subscribers.rb +188 -0
- data/lib/cbox_billing/models/plan_price.rb +256 -0
- data/lib/cbox_billing/models/plan_prices_inner.rb +241 -0
- data/lib/cbox_billing/models/plane_invoice_list.rb +226 -0
- data/lib/cbox_billing/models/plane_invoice_list_all_of_data.rb +557 -0
- data/lib/cbox_billing/models/portal_session_request.rb +309 -0
- data/lib/cbox_billing/models/prepare_tax_return200_response.rb +177 -0
- data/lib/cbox_billing/models/prepare_tax_return_request.rb +237 -0
- data/lib/cbox_billing/models/preview_renewal_alignment_request.rb +201 -0
- data/lib/cbox_billing/models/preview_service_invitation200_response.rb +161 -0
- data/lib/cbox_billing/models/preview_service_invitation200_response_invitation.rb +189 -0
- data/lib/cbox_billing/models/preview_service_invitation_request.rb +186 -0
- data/lib/cbox_billing/models/preview_subscription_cancel_request.rb +216 -0
- data/lib/cbox_billing/models/preview_subscription_coupon200_response.rb +205 -0
- data/lib/cbox_billing/models/preview_subscription_coupon_request.rb +186 -0
- data/lib/cbox_billing/models/price_lock.rb +215 -0
- data/lib/cbox_billing/models/price_lock_state.rb +190 -0
- data/lib/cbox_billing/models/price_tax.rb +348 -0
- data/lib/cbox_billing/models/private_plan.rb +380 -0
- data/lib/cbox_billing/models/product_definition_manifest.rb +269 -0
- data/lib/cbox_billing/models/product_definition_manifest_features_inner.rb +333 -0
- data/lib/cbox_billing/models/product_definition_manifest_meters_inner.rb +434 -0
- data/lib/cbox_billing/models/product_file.rb +420 -0
- data/lib/cbox_billing/models/proration_line.rb +203 -0
- data/lib/cbox_billing/models/quantity_preview.rb +321 -0
- data/lib/cbox_billing/models/quantity_request.rb +196 -0
- data/lib/cbox_billing/models/quote.rb +700 -0
- data/lib/cbox_billing/models/quote_all_of_acceptance.rb +206 -0
- data/lib/cbox_billing/models/quote_all_of_approval.rb +201 -0
- data/lib/cbox_billing/models/quote_all_of_grants.rb +205 -0
- data/lib/cbox_billing/models/quote_all_of_lines.rb +284 -0
- data/lib/cbox_billing/models/quote_all_of_terms.rb +285 -0
- data/lib/cbox_billing/models/quote_all_of_terms_ramp.rb +169 -0
- data/lib/cbox_billing/models/quote_all_of_totals.rb +255 -0
- data/lib/cbox_billing/models/quote_all_of_totals_lines.rb +223 -0
- data/lib/cbox_billing/models/quote_line_grants.rb +212 -0
- data/lib/cbox_billing/models/quote_line_grants_features_inner.rb +204 -0
- data/lib/cbox_billing/models/quote_line_grants_meters_inner.rb +260 -0
- data/lib/cbox_billing/models/quote_line_request.rb +368 -0
- data/lib/cbox_billing/models/quote_list.rb +226 -0
- data/lib/cbox_billing/models/quote_request.rb +650 -0
- data/lib/cbox_billing/models/quote_request_ramp_inner.rb +221 -0
- data/lib/cbox_billing/models/quote_signer.rb +434 -0
- data/lib/cbox_billing/models/quote_signer_request.rb +247 -0
- data/lib/cbox_billing/models/quote_signer_signature.rb +296 -0
- data/lib/cbox_billing/models/quote_signing.rb +384 -0
- data/lib/cbox_billing/models/quote_signing_request.rb +278 -0
- data/lib/cbox_billing/models/quote_signing_signed_document.rb +240 -0
- data/lib/cbox_billing/models/quote_summary.rb +440 -0
- data/lib/cbox_billing/models/rate_limit_error_body.rb +177 -0
- data/lib/cbox_billing/models/reconcile_id_signals_inclusion200_response.rb +211 -0
- data/lib/cbox_billing/models/reconcile_id_signals_inclusion_request.rb +162 -0
- data/lib/cbox_billing/models/record_invoice_payment_request.rb +223 -0
- data/lib/cbox_billing/models/recurring_price.rb +230 -0
- data/lib/cbox_billing/models/refund.rb +493 -0
- data/lib/cbox_billing/models/refund_list.rb +179 -0
- data/lib/cbox_billing/models/refund_order_request.rb +223 -0
- data/lib/cbox_billing/models/refund_request.rb +227 -0
- data/lib/cbox_billing/models/refund_result.rb +239 -0
- data/lib/cbox_billing/models/refusal.rb +205 -0
- data/lib/cbox_billing/models/release_invoice_from_review200_response.rb +205 -0
- data/lib/cbox_billing/models/remove_billing_parent_request.rb +186 -0
- data/lib/cbox_billing/models/remove_subscription_coupon200_response.rb +177 -0
- data/lib/cbox_billing/models/remove_subscription_coupon_request.rb +177 -0
- data/lib/cbox_billing/models/reserve_outcome.rb +251 -0
- data/lib/cbox_billing/models/reserve_request.rb +225 -0
- data/lib/cbox_billing/models/reserve_request_meters_inner.rb +212 -0
- data/lib/cbox_billing/models/reset_environment200_response.rb +187 -0
- data/lib/cbox_billing/models/reset_environment_request.rb +162 -0
- data/lib/cbox_billing/models/reset_period.rb +247 -0
- data/lib/cbox_billing/models/resource_limit.rb +392 -0
- data/lib/cbox_billing/models/retry_accounting_sync202_response.rb +177 -0
- data/lib/cbox_billing/models/retry_invoice_dunning_request.rb +176 -0
- data/lib/cbox_billing/models/reverse_invoice_payment_request.rb +186 -0
- data/lib/cbox_billing/models/revoke_limit_increase_request.rb +195 -0
- data/lib/cbox_billing/models/schedule_phase.rb +486 -0
- data/lib/cbox_billing/models/schedule_phase_request.rb +396 -0
- data/lib/cbox_billing/models/schedule_plan_move_request.rb +231 -0
- data/lib/cbox_billing/models/scheduled_catalog_change.rb +331 -0
- data/lib/cbox_billing/models/scheduled_catalog_change_existing.rb +215 -0
- data/lib/cbox_billing/models/seat_breakdown.rb +404 -0
- data/lib/cbox_billing/models/seat_entitlement.rb +267 -0
- data/lib/cbox_billing/models/seat_ledger_entry.rb +440 -0
- data/lib/cbox_billing/models/seat_ledger_page.rb +205 -0
- data/lib/cbox_billing/models/seat_ledger_page_meta.rb +255 -0
- data/lib/cbox_billing/models/seat_reassign_request.rb +187 -0
- data/lib/cbox_billing/models/seat_subject_request.rb +178 -0
- data/lib/cbox_billing/models/seat_type_change.rb +384 -0
- data/lib/cbox_billing/models/seat_type_entitlement.rb +269 -0
- data/lib/cbox_billing/models/seat_type_quantity_request.rb +205 -0
- data/lib/cbox_billing/models/seat_type_response.rb +177 -0
- data/lib/cbox_billing/models/seat_type_state.rb +565 -0
- data/lib/cbox_billing/models/seat_type_state_holders_inner.rb +189 -0
- data/lib/cbox_billing/models/seats_set_request.rb +186 -0
- data/lib/cbox_billing/models/service_admission_identity.rb +237 -0
- data/lib/cbox_billing/models/service_admission_input.rb +388 -0
- data/lib/cbox_billing/models/set_backup_card_consent200_response.rb +189 -0
- data/lib/cbox_billing/models/set_backup_card_consent_request.rb +177 -0
- data/lib/cbox_billing/models/set_billing_parent409_response.rb +227 -0
- data/lib/cbox_billing/models/set_billing_parent_request.rb +212 -0
- data/lib/cbox_billing/models/set_customer_contract_request.rb +197 -0
- data/lib/cbox_billing/models/set_invoice_consolidation_request.rb +177 -0
- data/lib/cbox_billing/models/set_overage_cap422_response.rb +227 -0
- data/lib/cbox_billing/models/set_product_delivery_request.rb +342 -0
- data/lib/cbox_billing/models/set_subscription_purchase_order200_response.rb +189 -0
- data/lib/cbox_billing/models/set_subscription_purchase_order_request.rb +176 -0
- data/lib/cbox_billing/models/setup_intent.rb +302 -0
- data/lib/cbox_billing/models/setup_intent_request.rb +177 -0
- data/lib/cbox_billing/models/show_environment200_response.rb +160 -0
- data/lib/cbox_billing/models/signals_source200_response.rb +214 -0
- data/lib/cbox_billing/models/signals_source200_response_meta.rb +471 -0
- data/lib/cbox_billing/models/signals_source_erasures200_response.rb +214 -0
- data/lib/cbox_billing/models/signals_source_erasures200_response_meta.rb +329 -0
- data/lib/cbox_billing/models/signed_agreement.rb +498 -0
- data/lib/cbox_billing/models/signed_agreement_document.rb +252 -0
- data/lib/cbox_billing/models/skip_accounting_contact_import_rows200_response.rb +177 -0
- data/lib/cbox_billing/models/skip_accounting_contact_import_rows_request.rb +188 -0
- data/lib/cbox_billing/models/skip_invoice_dunning_step_request.rb +186 -0
- data/lib/cbox_billing/models/spend_alert.rb +395 -0
- data/lib/cbox_billing/models/start_accounting_contact_import202_response.rb +177 -0
- data/lib/cbox_billing/models/stop_invoice_dunning_request.rb +247 -0
- data/lib/cbox_billing/models/submit_dispute_evidence_request.rb +178 -0
- data/lib/cbox_billing/models/subscribe_request.rb +373 -0
- data/lib/cbox_billing/models/subscribe_result.rb +215 -0
- data/lib/cbox_billing/models/subscription.rb +617 -0
- data/lib/cbox_billing/models/subscription_bundle.rb +200 -0
- data/lib/cbox_billing/models/subscription_change.rb +505 -0
- data/lib/cbox_billing/models/subscription_change_list.rb +226 -0
- data/lib/cbox_billing/models/subscription_contract.rb +188 -0
- data/lib/cbox_billing/models/subscription_contract_term.rb +385 -0
- data/lib/cbox_billing/models/subscription_date_move.rb +295 -0
- data/lib/cbox_billing/models/subscription_discount.rb +315 -0
- data/lib/cbox_billing/models/subscription_pending_change.rb +171 -0
- data/lib/cbox_billing/models/subscription_standing.rb +230 -0
- data/lib/cbox_billing/models/subscription_terms.rb +459 -0
- data/lib/cbox_billing/models/subscription_terms_price.rb +178 -0
- data/lib/cbox_billing/models/sync_product_definitions200_response.rb +179 -0
- data/lib/cbox_billing/models/sync_product_definitions200_response_data_inner.rb +335 -0
- data/lib/cbox_billing/models/tax_return.rb +663 -0
- data/lib/cbox_billing/models/tax_return_boxes_inner.rb +307 -0
- data/lib/cbox_billing/models/tax_return_corrections_inner.rb +178 -0
- data/lib/cbox_billing/models/tax_return_issues_inner.rb +227 -0
- data/lib/cbox_billing/models/tax_return_line.rb +550 -0
- data/lib/cbox_billing/models/tax_return_line_document.rb +214 -0
- data/lib/cbox_billing/models/tax_return_line_fx.rb +212 -0
- data/lib/cbox_billing/models/tax_return_member_states_inner.rb +250 -0
- data/lib/cbox_billing/models/tax_return_not_from_billing_inner.rb +229 -0
- data/lib/cbox_billing/models/test_clock_advance_request.rb +178 -0
- data/lib/cbox_billing/models/test_clock_advance_result.rb +334 -0
- data/lib/cbox_billing/models/test_clock_advance_result_clock.rb +230 -0
- data/lib/cbox_billing/models/upcoming_invoice.rb +440 -0
- data/lib/cbox_billing/models/upcoming_invoice_first_period.rb +251 -0
- data/lib/cbox_billing/models/upcoming_invoice_interim.rb +245 -0
- data/lib/cbox_billing/models/upcoming_invoice_interim_invoices_inner.rb +286 -0
- data/lib/cbox_billing/models/upcoming_invoice_interim_reconciliation.rb +270 -0
- data/lib/cbox_billing/models/upcoming_invoice_interim_reconciliation_credit_notes_inner.rb +282 -0
- data/lib/cbox_billing/models/upcoming_invoice_lines_inner.rb +282 -0
- data/lib/cbox_billing/models/update_affiliate_program_request.rb +398 -0
- data/lib/cbox_billing/models/update_affiliate_request.rb +321 -0
- data/lib/cbox_billing/models/update_dispute_evidence_request.rb +177 -0
- data/lib/cbox_billing/models/update_dispute_evidence_request_evidence.rb +251 -0
- data/lib/cbox_billing/models/update_entitlement_override_request.rb +309 -0
- data/lib/cbox_billing/models/update_invoice_draft_request.rb +214 -0
- data/lib/cbox_billing/models/update_invoice_draft_request_lines_inner.rb +224 -0
- data/lib/cbox_billing/models/update_license_key_request.rb +186 -0
- data/lib/cbox_billing/models/update_payment_gateway_routing_request.rb +234 -0
- data/lib/cbox_billing/models/update_product_file_request.rb +208 -0
- data/lib/cbox_billing/models/update_spend_alert_request.rb +296 -0
- data/lib/cbox_billing/models/upgrade_offer.rb +189 -0
- data/lib/cbox_billing/models/usage_correction.rb +471 -0
- data/lib/cbox_billing/models/usage_correction_actor.rb +211 -0
- data/lib/cbox_billing/models/usage_correction_adjustment.rb +411 -0
- data/lib/cbox_billing/models/usage_correction_list.rb +226 -0
- data/lib/cbox_billing/models/usage_correction_list_all_of_data.rb +506 -0
- data/lib/cbox_billing/models/usage_corrections_request.rb +246 -0
- data/lib/cbox_billing/models/usage_corrections_request_corrections_inner.rb +413 -0
- data/lib/cbox_billing/models/usage_corrections_result.rb +395 -0
- data/lib/cbox_billing/models/usage_corrections_result_rejected_inner.rb +262 -0
- data/lib/cbox_billing/models/usage_event_values.rb +252 -0
- data/lib/cbox_billing/models/usage_events_request.rb +234 -0
- data/lib/cbox_billing/models/usage_events_request_events_inner.rb +385 -0
- data/lib/cbox_billing/models/usage_events_request_events_inner_dimensions_value.rb +104 -0
- data/lib/cbox_billing/models/usage_events_result.rb +301 -0
- data/lib/cbox_billing/models/usage_events_result_rejected_inner.rb +263 -0
- data/lib/cbox_billing/models/usage_ingest_request.rb +225 -0
- data/lib/cbox_billing/models/usage_ingest_request_entries_inner.rb +290 -0
- data/lib/cbox_billing/models/usage_ingest_result.rb +374 -0
- data/lib/cbox_billing/models/usage_ingest_result_unsupported_meters_inner.rb +203 -0
- data/lib/cbox_billing/models/usage_price.rb +258 -0
- data/lib/cbox_billing/models/usage_summary.rb +205 -0
- data/lib/cbox_billing/models/usage_summary_meters_value.rb +289 -0
- data/lib/cbox_billing/models/usage_summary_meters_value_breakdown_inner.rb +205 -0
- data/lib/cbox_billing/models/usage_summary_period.rb +247 -0
- data/lib/cbox_billing/models/usage_threshold.rb +275 -0
- data/lib/cbox_billing/models/usage_threshold_level.rb +217 -0
- data/lib/cbox_billing/models/usage_threshold_request.rb +248 -0
- data/lib/cbox_billing/models/usage_threshold_subscriptions_inner.rb +201 -0
- data/lib/cbox_billing/models/validation_error_body.rb +206 -0
- data/lib/cbox_billing/models/value_rule.rb +291 -0
- data/lib/cbox_billing/models/value_rules.rb +235 -0
- data/lib/cbox_billing/models/waitlist_answer.rb +105 -0
- data/lib/cbox_billing/models/waitlist_question.rb +411 -0
- data/lib/cbox_billing/models/webhook_delivery.rb +435 -0
- data/lib/cbox_billing/models/webhook_delivery_list.rb +226 -0
- data/lib/cbox_billing/models/webhook_endpoint.rb +347 -0
- data/lib/cbox_billing/models/webhook_endpoint_list.rb +226 -0
- data/lib/cbox_billing/models/webhook_endpoint_request.rb +270 -0
- data/lib/cbox_billing/models/webhook_endpoint_with_secret.rb +367 -0
- data/lib/cbox_billing/models/withdraw_agreement_request.rb +220 -0
- data/lib/cbox_billing/models/withdraw_agreement_request_user.rb +177 -0
- data/lib/cbox_billing/pagination.rb +28 -0
- data/lib/cbox_billing/retry.rb +96 -0
- data/lib/cbox_billing/version.rb +15 -0
- data/lib/cbox_billing/webhook.rb +77 -0
- data/lib/cbox_billing.rb +765 -0
- metadata +824 -0
|
@@ -0,0 +1,665 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'securerandom'
|
|
5
|
+
require 'uri'
|
|
6
|
+
|
|
7
|
+
module CboxBilling
|
|
8
|
+
module Enforcement
|
|
9
|
+
# Meters usage against Cbox Billing without a request to Billing per call. Reservations take
|
|
10
|
+
# units from a slice of the organization's allowance leased into the store, Billing is asked
|
|
11
|
+
# only to refill, and committed usage is reported as running totals. The same client, with the
|
|
12
|
+
# same behaviour, exists in every Cbox Billing SDK; sdks/conformance/SPEC.md describes it.
|
|
13
|
+
#
|
|
14
|
+
# billing = CboxBilling::Enforcement::Client.new(token: ENV.fetch('CBOX_BILLING_TOKEN'),
|
|
15
|
+
# base_url: 'https://api.cboxbilling.com/v1')
|
|
16
|
+
# reservation = billing.reserve('org_acme', 'api.requests', 1)
|
|
17
|
+
# begin
|
|
18
|
+
# handle
|
|
19
|
+
# billing.commit(reservation, 1)
|
|
20
|
+
# ensure
|
|
21
|
+
# billing.release(reservation) # does nothing once committed
|
|
22
|
+
# end
|
|
23
|
+
class Client
|
|
24
|
+
FAILURE_POLICIES = %i[last_known allow deny].freeze
|
|
25
|
+
INVALIDATING = %w[
|
|
26
|
+
entitlements.changed customer.suspended customer.reactivated customer.deleted customer.merged
|
|
27
|
+
bundle.benefit_started bundle.benefit_ended agreement.accepted agreement.withdrawn
|
|
28
|
+
].freeze
|
|
29
|
+
ORGANIZATION_FIELDS = %w[organization_ref organization_id cbox_org_id organization].freeze
|
|
30
|
+
SWEPT_TTL = 86_400
|
|
31
|
+
|
|
32
|
+
# +token+: an API token with the enforce scope (cbl_… live, cbt_… test). +base_url+: your
|
|
33
|
+
# deployment's API root. +store+: MemoryStore by default; share a RedisStore between
|
|
34
|
+
# processes. +background_refill+: top slices up on a thread so no request waits for it.
|
|
35
|
+
# +send+ (the HTTP function) and +clock+ (milliseconds) are for tests. The other settings and
|
|
36
|
+
# their defaults are in sdks/conformance/SPEC.md.
|
|
37
|
+
def initialize(token:, base_url:, store: nil, lease_size: 100, refill_threshold: 20,
|
|
38
|
+
failure_policy: :last_known, reservation_ttl: 300, grace_units: 100, grace_window: 3600,
|
|
39
|
+
grace_meters: {}, breaker_cooldown: 30, snapshot_refresh: 300, entitlements_ttl: 60,
|
|
40
|
+
lock_ttl: 10, lock_wait: 5, timeout: 5, lease_timeout: 2, prefix: 'cbox-billing:',
|
|
41
|
+
background_refill: true, on_background_error: nil, headers: {}, send: nil, clock: nil)
|
|
42
|
+
raise ArgumentError, 'A Cbox Billing API token is required.' if token.nil? || token.empty?
|
|
43
|
+
|
|
44
|
+
policy = failure_policy.to_sym
|
|
45
|
+
unless FAILURE_POLICIES.include?(policy)
|
|
46
|
+
raise ArgumentError, "Unknown failure policy [#{failure_policy}]: use last_known, allow or deny."
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
{ lease_size:, reservation_ttl:, grace_window:, snapshot_refresh:, entitlements_ttl:, lock_ttl:,
|
|
50
|
+
timeout:, lease_timeout: }.each { |name, v| raise ArgumentError, "#{name} must be positive." unless v.positive? }
|
|
51
|
+
{ refill_threshold:, grace_units:, breaker_cooldown:, lock_wait: }.each do |name, v|
|
|
52
|
+
raise ArgumentError, "#{name} must be 0 or more." if v.negative?
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
@clock = clock || -> { (Process.clock_gettime(Process::CLOCK_REALTIME) * 1000).floor }
|
|
56
|
+
@store = store || MemoryStore.new(clock: @clock)
|
|
57
|
+
@lease_size = lease_size
|
|
58
|
+
@refill_threshold = refill_threshold
|
|
59
|
+
@policy = policy
|
|
60
|
+
@reservation_ttl = reservation_ttl
|
|
61
|
+
@grace_units = grace_units
|
|
62
|
+
@grace_window = grace_window
|
|
63
|
+
@grace_meters = grace_meters.transform_keys(&:to_s)
|
|
64
|
+
@breaker_cooldown = breaker_cooldown
|
|
65
|
+
@snapshot_refresh = snapshot_refresh
|
|
66
|
+
@entitlements_ttl = entitlements_ttl
|
|
67
|
+
@lock_ttl = lock_ttl
|
|
68
|
+
@lock_wait = lock_wait
|
|
69
|
+
@lease_timeout = lease_timeout
|
|
70
|
+
@prefix = prefix
|
|
71
|
+
@background_refill = background_refill
|
|
72
|
+
@on_background_error = on_background_error || ->(_error) {}
|
|
73
|
+
@transport = Transport.new(base_url.sub(%r{/+\z}, ''), token, send || Transport::NET_HTTP, headers, timeout)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# ---- the hot path ----
|
|
77
|
+
|
|
78
|
+
# Hold +estimate+ units of +meter+: locally when the slice covers it, otherwise after one lease.
|
|
79
|
+
# Raises QuotaExceeded, BillingRefused, BillingUnavailable (when the policy refuses) or
|
|
80
|
+
# ArgumentError (an estimate that is not a positive integer).
|
|
81
|
+
def reserve(org, meter, estimate)
|
|
82
|
+
assert_positive(estimate, 'estimate')
|
|
83
|
+
hold = hold(org, meter, estimate)
|
|
84
|
+
id = new_id
|
|
85
|
+
open_reservation(id, org, [hold])
|
|
86
|
+
refill_if_low(org, meter) if hold.kind == :lease
|
|
87
|
+
Reservation.new(id:, org:, hold:)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Hold several meters at once, in key order, all or nothing: when one cannot be held, the
|
|
91
|
+
# others go back and this raises what the failing meter raised.
|
|
92
|
+
def reserve_many(org, meters)
|
|
93
|
+
raise ArgumentError, 'A reservation set needs at least one meter.' if meters.empty?
|
|
94
|
+
|
|
95
|
+
meters = meters.to_h { |k, v| [k.to_s, v] }
|
|
96
|
+
names = meters.keys.sort
|
|
97
|
+
names.each { |name| assert_positive(meters[name], "estimate for [#{name}]") }
|
|
98
|
+
|
|
99
|
+
held = []
|
|
100
|
+
begin
|
|
101
|
+
names.each { |name| held << hold(org, name, meters[name]) }
|
|
102
|
+
rescue StandardError
|
|
103
|
+
held.each { |h| give_back(org, h, h.amount) }
|
|
104
|
+
raise
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
id = new_id
|
|
108
|
+
open_reservation(id, org, held)
|
|
109
|
+
held.each { |h| refill_if_low(org, h.meter) if h.kind == :lease }
|
|
110
|
+
ReservationSet.new(id:, org:, holds: held)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Settle a reservation to what was used: an Integer for a Reservation, a {meter => actual}
|
|
114
|
+
# hash covering every meter for a ReservationSet, each from 0 to what was held. The rest goes
|
|
115
|
+
# back; the usage is recorded for reporting. Raises ArgumentError for an actual out of range
|
|
116
|
+
# or missing, or a reservation already settled.
|
|
117
|
+
def commit(reservation, actual)
|
|
118
|
+
holds = reservation.is_a?(Reservation) ? [reservation.hold] : reservation.holds
|
|
119
|
+
actuals = actuals_for(reservation, holds, actual)
|
|
120
|
+
org = reservation.org
|
|
121
|
+
|
|
122
|
+
if @store.delete(key('res', reservation.id))
|
|
123
|
+
holds.each_with_index { |h, i| give_back(org, h, h.amount - actuals[i]) }
|
|
124
|
+
elsif @store.delete(key('swept', reservation.id))
|
|
125
|
+
# The sweeper gave every unit back; take out again what was used, as far as the slice allows.
|
|
126
|
+
holds.each_with_index { |h, i| take(org, h.meter, actuals[i]) if h.kind == :lease && actuals[i].positive? }
|
|
127
|
+
else
|
|
128
|
+
raise ArgumentError, "Reservation [#{reservation.id}] is already settled."
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
holds.each_with_index { |h, i| record(org, h.meter, actuals[i]) if actuals[i].positive? }
|
|
132
|
+
nil
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Give a reservation's units back without recording usage. Does nothing once it is settled.
|
|
136
|
+
def release(reservation)
|
|
137
|
+
holds = reservation.is_a?(Reservation) ? [reservation.hold] : reservation.holds
|
|
138
|
+
if @store.delete(key('res', reservation.id))
|
|
139
|
+
holds.each { |h| give_back(reservation.org, h, h.amount) }
|
|
140
|
+
else
|
|
141
|
+
@store.delete(key('swept', reservation.id))
|
|
142
|
+
end
|
|
143
|
+
nil
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Could +n+ units be reserved now? Refills once if short; takes nothing; never raises for Billing.
|
|
147
|
+
def can?(org, meter, n)
|
|
148
|
+
return false unless n.is_a?(Integer) && n.positive?
|
|
149
|
+
return true if balance(org, meter) >= n
|
|
150
|
+
|
|
151
|
+
begin
|
|
152
|
+
refill(org, meter, n, probe: false)
|
|
153
|
+
rescue BillingUnavailable
|
|
154
|
+
return outage_admits?(org, meter, n)
|
|
155
|
+
rescue Error
|
|
156
|
+
return false
|
|
157
|
+
end
|
|
158
|
+
balance(org, meter) >= n
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# The units in the local slice.
|
|
162
|
+
def balance(org, meter)
|
|
163
|
+
counter(key('lease', org, meter))
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# ---- reporting and upkeep ----
|
|
167
|
+
|
|
168
|
+
# Send the buffered running totals to Billing: one request per organization, its meters in key
|
|
169
|
+
# order, leaving out streams unchanged since their last accepted report. Returns how many
|
|
170
|
+
# organizations were reported; one that fails is sent again next time.
|
|
171
|
+
def report(org = nil)
|
|
172
|
+
base = "#{key('usage')}:"
|
|
173
|
+
prefix = org.nil? ? base : "#{base}#{escape(org)}:"
|
|
174
|
+
streams = Hash.new { |h, k| h[k] = [] }
|
|
175
|
+
@store.keys(prefix).each do |k|
|
|
176
|
+
parts = k[base.length..].split(':', -1)
|
|
177
|
+
next unless parts.length == 2
|
|
178
|
+
|
|
179
|
+
streams[unescape(parts[0])] << unescape(parts[1])
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
reported = 0
|
|
183
|
+
streams.keys.sort.each do |owner|
|
|
184
|
+
entries = []
|
|
185
|
+
streams[owner].sort.each do |meter|
|
|
186
|
+
# The sequence first: a commit raises the total before the sequence, so this total is at
|
|
187
|
+
# least the one this sequence names, and a later commit changes it again.
|
|
188
|
+
seq = counter(key('useq', owner, meter))
|
|
189
|
+
cumulative = counter(key('usage', owner, meter))
|
|
190
|
+
sent = @store.get(key('usent', owner, meter))
|
|
191
|
+
next if !sent.nil? && sent.to_i == seq
|
|
192
|
+
|
|
193
|
+
entries << { 'meter' => meter, 'cumulative' => cumulative, 'seq' => seq,
|
|
194
|
+
'epoch' => counter(key('uepoch', owner, meter)) }
|
|
195
|
+
end
|
|
196
|
+
next if entries.empty?
|
|
197
|
+
|
|
198
|
+
begin
|
|
199
|
+
@transport.post('/usage', { 'org' => owner, 'entries' => entries })
|
|
200
|
+
rescue Error
|
|
201
|
+
next
|
|
202
|
+
end
|
|
203
|
+
entries.each { |e| @store.put(key('usent', owner, e['meter']), e['seq'].to_s) }
|
|
204
|
+
reported += 1
|
|
205
|
+
end
|
|
206
|
+
reported
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Close every reservation older than the reservation TTL and give its units back. Returns how
|
|
210
|
+
# many. Run it on a schedule, about as often as the TTL.
|
|
211
|
+
def sweep
|
|
212
|
+
base = "#{key('res')}:"
|
|
213
|
+
now = @clock.call
|
|
214
|
+
swept = 0
|
|
215
|
+
@store.keys(base).each do |k|
|
|
216
|
+
raw = @store.get(k)
|
|
217
|
+
stored = raw && parse_reservation(raw)
|
|
218
|
+
next if stored.nil? || stored[:expires_at] > now || !@store.delete(k)
|
|
219
|
+
|
|
220
|
+
@store.put(key('swept', unescape(k[base.length..])), '1', SWEPT_TTL)
|
|
221
|
+
stored[:holds].each { |h| give_back(stored[:org], h, h.amount) }
|
|
222
|
+
swept += 1
|
|
223
|
+
end
|
|
224
|
+
swept
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
# ---- entitlements and features ----
|
|
228
|
+
|
|
229
|
+
# The organization's per-meter entitlements, cached for the entitlements TTL. When Billing
|
|
230
|
+
# cannot be reached, the last answer, marked stale.
|
|
231
|
+
def entitlements(org)
|
|
232
|
+
cached = read_meters(org)
|
|
233
|
+
return Entitlements.new(org:, meters: cached, stale: false) if cached && @store.get(key('entfresh', org))
|
|
234
|
+
|
|
235
|
+
fetch_entitlements(org)
|
|
236
|
+
rescue BillingUnavailable
|
|
237
|
+
raise if cached.nil?
|
|
238
|
+
|
|
239
|
+
Entitlements.new(org:, meters: cached, stale: true)
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
# The organization's boolean and config features, cached like entitlements.
|
|
243
|
+
def features(org)
|
|
244
|
+
raw = @store.get(key('feat', org))
|
|
245
|
+
cached = raw && features_from(org, JSON.parse(raw), false)
|
|
246
|
+
return cached if cached && @store.get(key('featfresh', org))
|
|
247
|
+
|
|
248
|
+
endpoint = "/entitlements/#{escape_path(org)}/features"
|
|
249
|
+
parsed = parse_features(@transport.get(endpoint), endpoint)
|
|
250
|
+
@store.put(key('feat', org), JSON.generate(parsed))
|
|
251
|
+
@store.put(key('featfresh', org), '1', @entitlements_ttl)
|
|
252
|
+
features_from(org, parsed, false)
|
|
253
|
+
rescue BillingUnavailable
|
|
254
|
+
raise if cached.nil?
|
|
255
|
+
|
|
256
|
+
cached.dup.tap { |f| f.stale = true }
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
# True when the feature is granted and the account is not suspended.
|
|
260
|
+
def feature?(org, key) = features(org).enabled?(key)
|
|
261
|
+
|
|
262
|
+
# A config feature's value, true for a granted boolean feature, nil otherwise.
|
|
263
|
+
def feature_value(org, key) = features(org).value(key)
|
|
264
|
+
|
|
265
|
+
# units × weight for the meter, from the cached entitlements.
|
|
266
|
+
def cost(org, meter, units) = entitlements(org).cost(meter, units)
|
|
267
|
+
|
|
268
|
+
# Make the next read for +org+ (or for everyone) ask Billing, and the next refill read the
|
|
269
|
+
# entitlements again. The old answer stays, as the fallback for an outage.
|
|
270
|
+
def invalidate(org = nil)
|
|
271
|
+
%w[entfresh featfresh claim].each do |kind|
|
|
272
|
+
if org.nil?
|
|
273
|
+
@store.keys("#{key(kind)}:").each { |k| @store.delete(k) }
|
|
274
|
+
else
|
|
275
|
+
@store.delete(key(kind, org))
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
nil
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
# Invalidate from a verified webhook event (see CboxBilling::Webhook.construct_event): a hash
|
|
282
|
+
# with 'type' and 'data'. Returns true when the event type changes what a customer holds.
|
|
283
|
+
def handle_webhook(event)
|
|
284
|
+
event = event.transform_keys(&:to_s)
|
|
285
|
+
type = event['type'].to_s
|
|
286
|
+
if type == 'plan.changed'
|
|
287
|
+
invalidate
|
|
288
|
+
return true
|
|
289
|
+
end
|
|
290
|
+
return false unless INVALIDATING.include?(type) || type.start_with?('subscription.')
|
|
291
|
+
|
|
292
|
+
data = event['data'].is_a?(Hash) ? event['data'].transform_keys(&:to_s) : {}
|
|
293
|
+
orgs = ORGANIZATION_FIELDS.map { |f| data[f] }.select { |v| v.is_a?(String) && !v.empty? }.uniq
|
|
294
|
+
invalidate if orgs.empty?
|
|
295
|
+
orgs.each { |org| invalidate(org) }
|
|
296
|
+
true
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
private
|
|
300
|
+
|
|
301
|
+
# ---- holding units ----
|
|
302
|
+
|
|
303
|
+
def hold(org, meter, estimate)
|
|
304
|
+
return Hold.new(meter:, amount: estimate, kind: :lease) if take(org, meter, estimate)
|
|
305
|
+
|
|
306
|
+
begin
|
|
307
|
+
answer = refill(org, meter, estimate, probe: false)
|
|
308
|
+
rescue BillingUnavailable => e
|
|
309
|
+
return outage_hold(org, meter, estimate, e)
|
|
310
|
+
end
|
|
311
|
+
return Hold.new(meter:, amount: estimate, kind: :lease) if take(org, meter, estimate)
|
|
312
|
+
|
|
313
|
+
raise QuotaExceeded.new(org, meter, estimate, answer&.dig(:reason) || 'quota_exhausted')
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
def outage_hold(org, meter, estimate, outage)
|
|
317
|
+
return Hold.new(meter:, amount: estimate, kind: :allowed) if @policy == :allow
|
|
318
|
+
raise outage if @policy == :deny
|
|
319
|
+
|
|
320
|
+
known = last_known(org, meter)
|
|
321
|
+
if known
|
|
322
|
+
return Hold.new(meter:, amount: estimate, kind: :admitted) if admit(org, meter, estimate, known)
|
|
323
|
+
raise QuotaExceeded.new(org, meter, estimate, 'meter_disabled') unless known.enabled
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
window = take_grace(org, meter, estimate)
|
|
327
|
+
return Hold.new(meter:, amount: estimate, kind: :grace, grace_window: window) unless window.nil?
|
|
328
|
+
raise outage if known.nil?
|
|
329
|
+
|
|
330
|
+
raise QuotaExceeded.new(org, meter, estimate, 'outage_limit')
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
def outage_admits?(org, meter, n)
|
|
334
|
+
return @policy == :allow unless @policy == :last_known
|
|
335
|
+
|
|
336
|
+
known = last_known(org, meter)
|
|
337
|
+
if known
|
|
338
|
+
return false unless known.enabled
|
|
339
|
+
return true if !known.capped? || headroom(org, meter, known) >= n
|
|
340
|
+
end
|
|
341
|
+
grace_remaining(org, meter) >= n
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
# ---- refilling ----
|
|
345
|
+
|
|
346
|
+
# Lease at least +want+ units into the slice, single flight per (organization, meter). Returns
|
|
347
|
+
# Billing's answer, or nil when another refill already filled the slice.
|
|
348
|
+
def refill(org, meter, want, probe:)
|
|
349
|
+
guard(probe)
|
|
350
|
+
lock = key('lock', org, meter)
|
|
351
|
+
token = new_id
|
|
352
|
+
deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + @lock_wait
|
|
353
|
+
acquired = @store.add(lock, token, @lock_ttl)
|
|
354
|
+
while !acquired && !probe && Process.clock_gettime(Process::CLOCK_MONOTONIC) < deadline
|
|
355
|
+
sleep 0.025
|
|
356
|
+
acquired = @store.add(lock, token, @lock_ttl)
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
unless acquired
|
|
360
|
+
return nil if probe
|
|
361
|
+
|
|
362
|
+
# Could not join the single flight in time: refill directly rather than starve.
|
|
363
|
+
guard(probe)
|
|
364
|
+
return lease(org, meter, want)
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
begin
|
|
368
|
+
return nil if balance(org, meter) >= want
|
|
369
|
+
|
|
370
|
+
guard(probe)
|
|
371
|
+
lease(org, meter, want)
|
|
372
|
+
ensure
|
|
373
|
+
@store.delete(lock) if @store.get(lock) == token
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
def lease(org, meter, want)
|
|
378
|
+
size = [@lease_size, want].max
|
|
379
|
+
begin
|
|
380
|
+
answer = parse_lease(@transport.post('/leases', { 'org' => org, 'meter' => meter, 'size' => size }, @lease_timeout))
|
|
381
|
+
rescue BillingUnavailable
|
|
382
|
+
@store.put(key('breaker'), '1', @breaker_cooldown) if @breaker_cooldown.positive?
|
|
383
|
+
raise
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
@store.delete(key('breaker'))
|
|
387
|
+
@store.increment(key('lease', org, meter), answer[:granted]) if answer[:granted].positive?
|
|
388
|
+
if @store.add(key('claim', org), '1', @snapshot_refresh)
|
|
389
|
+
begin
|
|
390
|
+
fetch_entitlements(org)
|
|
391
|
+
rescue Error
|
|
392
|
+
# Keep the previous snapshot; the next interval reads again.
|
|
393
|
+
end
|
|
394
|
+
end
|
|
395
|
+
record_lease(org, meter, size, answer[:granted])
|
|
396
|
+
answer
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
def refill_if_low(org, meter)
|
|
400
|
+
return if balance(org, meter) > @refill_threshold
|
|
401
|
+
|
|
402
|
+
if @background_refill
|
|
403
|
+
Thread.new do
|
|
404
|
+
refill(org, meter, @refill_threshold + 1, probe: true)
|
|
405
|
+
rescue StandardError => e
|
|
406
|
+
@on_background_error.call(e)
|
|
407
|
+
end
|
|
408
|
+
return
|
|
409
|
+
end
|
|
410
|
+
begin
|
|
411
|
+
refill(org, meter, @refill_threshold + 1, probe: false)
|
|
412
|
+
rescue Error
|
|
413
|
+
# The next reservation on a spent slice refills, or applies the policy.
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
def guard(probe)
|
|
418
|
+
return if probe || @breaker_cooldown <= 0 || @store.get(key('breaker')).nil?
|
|
419
|
+
|
|
420
|
+
raise BillingUnavailable.new('Billing was unreachable moments ago; the breaker is open.', '/leases')
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
# ---- the last known allowance ----
|
|
424
|
+
|
|
425
|
+
def fetch_entitlements(org)
|
|
426
|
+
endpoint = "/entitlements/#{escape_path(org)}"
|
|
427
|
+
meters = parse_meters(@transport.get(endpoint), endpoint)
|
|
428
|
+
@store.put(key('ent', org), JSON.generate({ 'meters' => meters.transform_values(&:to_h) }))
|
|
429
|
+
@store.put(key('entfresh', org), '1', @entitlements_ttl)
|
|
430
|
+
Entitlements.new(org:, meters:, stale: false)
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
def read_meters(org)
|
|
434
|
+
raw = @store.get(key('ent', org))
|
|
435
|
+
raw && parse_meters(JSON.parse(raw), '')
|
|
436
|
+
rescue JSON::ParserError, Error
|
|
437
|
+
nil
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
def last_known(org, meter) = read_meters(org)&.[](meter)
|
|
441
|
+
|
|
442
|
+
# Count a lease Billing answered. A short grant on a capped meter means Billing has nothing
|
|
443
|
+
# left; a full grant past the allowance means a new period began, so only it counts.
|
|
444
|
+
def record_lease(org, meter, requested, granted)
|
|
445
|
+
known = last_known(org, meter)
|
|
446
|
+
drawn = key('drawn', org, meter)
|
|
447
|
+
unless known&.capped?
|
|
448
|
+
@store.increment(drawn, granted) if granted.positive?
|
|
449
|
+
return
|
|
450
|
+
end
|
|
451
|
+
return @store.put(drawn, known.allowance.to_s) if granted < requested
|
|
452
|
+
return unless @store.increment(drawn, granted) > known.allowance
|
|
453
|
+
|
|
454
|
+
@store.put(drawn, granted.to_s)
|
|
455
|
+
@store.put(key('admitted', org, meter), '0')
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
def admit(org, meter, units, known)
|
|
459
|
+
return false unless known.enabled
|
|
460
|
+
|
|
461
|
+
k = key('admitted', org, meter)
|
|
462
|
+
after = @store.increment(k, units)
|
|
463
|
+
return true unless known.capped?
|
|
464
|
+
if known.allowance - counter(key('drawn', org, meter)) - after < 0
|
|
465
|
+
@store.increment(k, -units)
|
|
466
|
+
return false
|
|
467
|
+
end
|
|
468
|
+
true
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
def headroom(org, meter, known)
|
|
472
|
+
return 0 unless known.capped?
|
|
473
|
+
|
|
474
|
+
[0, known.allowance - counter(key('drawn', org, meter)) - counter(key('admitted', org, meter))].max
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
# ---- outage grace ----
|
|
478
|
+
|
|
479
|
+
def grace_limit(meter) = [0, @grace_meters.fetch(meter, @grace_units)].max
|
|
480
|
+
|
|
481
|
+
def current_window = @clock.call / (@grace_window * 1000).round
|
|
482
|
+
|
|
483
|
+
def take_grace(org, meter, units)
|
|
484
|
+
limit = grace_limit(meter)
|
|
485
|
+
return nil if units <= 0 || units > limit
|
|
486
|
+
|
|
487
|
+
window = current_window
|
|
488
|
+
k = key('grace', org, meter, window.to_s)
|
|
489
|
+
@store.add(k, '0', @grace_window)
|
|
490
|
+
if @store.increment(k, units) > limit
|
|
491
|
+
@store.increment(k, -units)
|
|
492
|
+
return nil
|
|
493
|
+
end
|
|
494
|
+
window
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
def grace_remaining(org, meter)
|
|
498
|
+
[0, grace_limit(meter) - counter(key('grace', org, meter, current_window.to_s))].max
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
# ---- store helpers ----
|
|
502
|
+
|
|
503
|
+
# Return units to where a hold took them from.
|
|
504
|
+
def give_back(org, hold, units)
|
|
505
|
+
return if units <= 0
|
|
506
|
+
|
|
507
|
+
case hold.kind
|
|
508
|
+
when :lease then @store.increment(key('lease', org, hold.meter), units)
|
|
509
|
+
when :admitted then @store.increment(key('admitted', org, hold.meter), -units)
|
|
510
|
+
when :grace
|
|
511
|
+
# Only to the window it came from, and only while it exists.
|
|
512
|
+
k = key('grace', org, hold.meter, hold.grace_window.to_s)
|
|
513
|
+
@store.increment(k, -units) unless @store.get(k).nil?
|
|
514
|
+
end
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
# Take +amount+ from the slice if it holds that much. Under concurrency it can only over-refuse.
|
|
518
|
+
def take(org, meter, amount)
|
|
519
|
+
k = key('lease', org, meter)
|
|
520
|
+
return true unless @store.increment(k, -amount).negative?
|
|
521
|
+
|
|
522
|
+
@store.increment(k, amount)
|
|
523
|
+
false
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
def record(org, meter, units)
|
|
527
|
+
@store.add(key('uepoch', org, meter), @clock.call.to_s)
|
|
528
|
+
@store.increment(key('usage', org, meter), units)
|
|
529
|
+
@store.increment(key('useq', org, meter), 1)
|
|
530
|
+
end
|
|
531
|
+
|
|
532
|
+
def open_reservation(id, org, holds)
|
|
533
|
+
@store.put(key('res', id), JSON.generate({
|
|
534
|
+
'org' => org,
|
|
535
|
+
'expires_at' => @clock.call + (@reservation_ttl * 1000).round,
|
|
536
|
+
'holds' => holds.map(&:to_h)
|
|
537
|
+
}))
|
|
538
|
+
end
|
|
539
|
+
|
|
540
|
+
def counter(k)
|
|
541
|
+
value = @store.get(k)
|
|
542
|
+
value.nil? ? 0 : Integer(value, 10)
|
|
543
|
+
rescue ArgumentError
|
|
544
|
+
0
|
|
545
|
+
end
|
|
546
|
+
|
|
547
|
+
def key(kind, *parts) = @prefix + kind + parts.map { |p| ":#{escape(p)}" }.join
|
|
548
|
+
|
|
549
|
+
# ---- parsing ----
|
|
550
|
+
|
|
551
|
+
def parse_lease(body)
|
|
552
|
+
granted = body['granted']
|
|
553
|
+
raise Transport.malformed('/leases', 'missing an integer granted of at least 0') unless granted.is_a?(Integer) && granted >= 0
|
|
554
|
+
|
|
555
|
+
if body['blocked'].is_a?(Hash)
|
|
556
|
+
reason = body['blocked']['reason']
|
|
557
|
+
return { granted:, reason: reason.is_a?(String) ? reason : 'agreement_required' }
|
|
558
|
+
end
|
|
559
|
+
reason = body['reason']
|
|
560
|
+
{ granted:, reason: reason.is_a?(String) && !reason.empty? ? reason : nil }
|
|
561
|
+
end
|
|
562
|
+
|
|
563
|
+
def parse_meters(body, endpoint)
|
|
564
|
+
raw = body['meters']
|
|
565
|
+
raw = {} if raw == []
|
|
566
|
+
raise Transport.malformed(endpoint, 'meters must be an object') unless raw.is_a?(Hash)
|
|
567
|
+
|
|
568
|
+
raw.to_h do |meter, entry|
|
|
569
|
+
unless entry.is_a?(Hash) && [true, false].include?(entry['enabled'])
|
|
570
|
+
raise Transport.malformed(endpoint, "meter [#{meter}] needs a boolean enabled")
|
|
571
|
+
end
|
|
572
|
+
|
|
573
|
+
allowance = entry['allowance']
|
|
574
|
+
weight = entry['weight']
|
|
575
|
+
overage = entry.fetch('overage', 'block') || 'block'
|
|
576
|
+
raise Transport.malformed(endpoint, "meter [#{meter}] has a non-integer allowance") unless allowance.nil? || allowance.is_a?(Integer)
|
|
577
|
+
raise Transport.malformed(endpoint, "meter [#{meter}] has a non-numeric weight") unless weight.nil? || weight.is_a?(Numeric)
|
|
578
|
+
raise Transport.malformed(endpoint, "meter [#{meter}] has a non-string overage") unless overage.is_a?(String)
|
|
579
|
+
|
|
580
|
+
[meter, MeterEntitlement.new(enabled: entry['enabled'], allowance:, weight:, overage:)]
|
|
581
|
+
end
|
|
582
|
+
end
|
|
583
|
+
|
|
584
|
+
def parse_features(body, endpoint)
|
|
585
|
+
raw = body['features']
|
|
586
|
+
raw = {} if raw == []
|
|
587
|
+
account = body['account']
|
|
588
|
+
unless raw.is_a?(Hash) && account.is_a?(Hash) && [true, false].include?(account['suspended'])
|
|
589
|
+
raise Transport.malformed(endpoint, 'expected features and account.suspended')
|
|
590
|
+
end
|
|
591
|
+
|
|
592
|
+
features = raw.to_h do |k, entry|
|
|
593
|
+
ok = entry.is_a?(Hash) && [true, false].include?(entry['enabled']) &&
|
|
594
|
+
['boolean', 'config', nil].include?(entry['type']) &&
|
|
595
|
+
(entry['value'].nil? || entry['value'].is_a?(String) || entry['value'].is_a?(Integer)) &&
|
|
596
|
+
entry.fetch('source', 'default').is_a?(String)
|
|
597
|
+
raise Transport.malformed(endpoint, "feature [#{k}] is not a feature decision") unless ok
|
|
598
|
+
|
|
599
|
+
[k, { 'type' => entry['type'], 'enabled' => entry['enabled'], 'value' => entry['value'],
|
|
600
|
+
'source' => entry.fetch('source', 'default') }]
|
|
601
|
+
end
|
|
602
|
+
{ 'features' => features, 'suspended' => account['suspended'] }
|
|
603
|
+
end
|
|
604
|
+
|
|
605
|
+
def features_from(org, stored, stale)
|
|
606
|
+
return nil unless stored.is_a?(Hash) && stored['features'].is_a?(Hash)
|
|
607
|
+
|
|
608
|
+
features = stored['features'].transform_values do |f|
|
|
609
|
+
FeatureDecision.new(type: f['type'], enabled: f['enabled'], value: f['value'], source: f['source'])
|
|
610
|
+
end
|
|
611
|
+
Features.new(org:, features:, suspended: stored['suspended'] == true, stale:)
|
|
612
|
+
end
|
|
613
|
+
|
|
614
|
+
def parse_reservation(raw)
|
|
615
|
+
data = JSON.parse(raw)
|
|
616
|
+
holds = data.fetch('holds').map do |h|
|
|
617
|
+
Hold.new(meter: h.fetch('meter'), amount: Integer(h.fetch('amount')), kind: h.fetch('kind').to_sym,
|
|
618
|
+
grace_window: h['grace_window'])
|
|
619
|
+
end
|
|
620
|
+
{ org: data.fetch('org'), expires_at: Integer(data.fetch('expires_at')), holds: }
|
|
621
|
+
rescue JSON::ParserError, KeyError, TypeError, ArgumentError
|
|
622
|
+
nil
|
|
623
|
+
end
|
|
624
|
+
|
|
625
|
+
def actuals_for(reservation, holds, actual)
|
|
626
|
+
if reservation.is_a?(Reservation)
|
|
627
|
+
raise ArgumentError, 'A single-meter reservation is committed with an Integer.' unless actual.is_a?(Integer)
|
|
628
|
+
|
|
629
|
+
return [in_range(actual, holds[0])]
|
|
630
|
+
end
|
|
631
|
+
raise ArgumentError, 'A reservation set is committed with an actual per meter.' unless actual.is_a?(Hash)
|
|
632
|
+
|
|
633
|
+
actual = actual.transform_keys(&:to_s)
|
|
634
|
+
names = holds.map(&:meter)
|
|
635
|
+
actual.each_key { |m| raise ArgumentError, "Meter [#{m}] is not in this reservation." unless names.include?(m) }
|
|
636
|
+
holds.map do |h|
|
|
637
|
+
raise ArgumentError, "Missing the actual for meter [#{h.meter}]." unless actual.key?(h.meter)
|
|
638
|
+
|
|
639
|
+
in_range(actual[h.meter], h)
|
|
640
|
+
end
|
|
641
|
+
end
|
|
642
|
+
|
|
643
|
+
def in_range(actual, hold)
|
|
644
|
+
unless actual.is_a?(Integer) && actual >= 0 && actual <= hold.amount
|
|
645
|
+
raise ArgumentError, "The actual for meter [#{hold.meter}] must be an integer from 0 to #{hold.amount}."
|
|
646
|
+
end
|
|
647
|
+
|
|
648
|
+
actual
|
|
649
|
+
end
|
|
650
|
+
|
|
651
|
+
def assert_positive(value, what)
|
|
652
|
+
raise ArgumentError, "The #{what} must be a positive integer." unless value.is_a?(Integer) && value.positive?
|
|
653
|
+
end
|
|
654
|
+
|
|
655
|
+
# Keys join parts with ':'; a part's own '%' and ':' are escaped so every key splits back.
|
|
656
|
+
def escape(part) = part.to_s.gsub('%', '%25').gsub(':', '%3A')
|
|
657
|
+
|
|
658
|
+
def unescape(part) = part.gsub('%3A', ':').gsub('%25', '%')
|
|
659
|
+
|
|
660
|
+
def escape_path(org) = URI.encode_www_form_component(org).gsub('+', '%20')
|
|
661
|
+
|
|
662
|
+
def new_id = "rsv_#{SecureRandom.hex(16)}"
|
|
663
|
+
end
|
|
664
|
+
end
|
|
665
|
+
end
|