schematichq 1.5.3 → 1.5.5
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/.fern/metadata.json +4 -4
- data/.fern/replay.lock +13 -1
- data/.fernignore +2 -0
- data/.rubocop.yml +4 -0
- data/README.md +1 -1
- data/WASM_VERSION +1 -1
- data/lib/schematic/accesstokens/client.rb +9 -1
- data/lib/schematic/accounts/client.rb +183 -21
- data/lib/schematic/billing/client.rb +748 -34
- data/lib/schematic/billing/types/count_native_invoices_params.rb +20 -0
- data/lib/schematic/billing/types/count_native_invoices_request.rb +19 -0
- data/lib/schematic/billing/types/count_native_invoices_response.rb +13 -0
- data/lib/schematic/billing/types/create_billing_price_request_body.rb +1 -1
- data/lib/schematic/billing/types/create_billing_product_request_body.rb +1 -1
- data/lib/schematic/billing/types/create_billing_subscription_request_body.rb +1 -1
- data/lib/schematic/billing/types/create_coupon_request_body.rb +2 -2
- data/lib/schematic/billing/types/create_invoice_request_body.rb +1 -1
- data/lib/schematic/billing/types/finalize_native_invoice_response.rb +13 -0
- data/lib/schematic/billing/types/get_billing_settings_response.rb +13 -0
- data/lib/schematic/billing/types/get_company_native_subscription_response.rb +13 -0
- data/lib/schematic/billing/types/get_native_invoice_response.rb +13 -0
- data/lib/schematic/billing/types/list_billing_prices_params.rb +1 -1
- data/lib/schematic/billing/types/list_billing_prices_request.rb +1 -1
- data/lib/schematic/billing/types/list_billing_product_prices_params.rb +1 -1
- data/lib/schematic/billing/types/list_billing_product_prices_request.rb +1 -1
- data/lib/schematic/billing/types/list_native_invoices_params.rb +20 -0
- data/lib/schematic/billing/types/list_native_invoices_request.rb +19 -0
- data/lib/schematic/billing/types/list_native_invoices_response.rb +13 -0
- data/lib/schematic/billing/types/mark_invoice_paid_request_body.rb +19 -0
- data/lib/schematic/billing/types/mark_native_invoice_paid_response.rb +13 -0
- data/lib/schematic/billing/types/update_billing_settings_request_body.rb +11 -0
- data/lib/schematic/billing/types/update_billing_settings_response.rb +13 -0
- data/lib/schematic/billing/types/void_native_invoice_response.rb +13 -0
- data/lib/schematic/catalogs/client.rb +121 -14
- data/lib/schematic/checkout/client.rb +80 -9
- data/lib/schematic/checkout/types/checkout_data_request_body.rb +1 -1
- data/lib/schematic/client.rb +5 -3
- data/lib/schematic/companies/client.rb +380 -44
- data/lib/schematic/components/client.rb +70 -8
- data/lib/schematic/components/types/create_component_request_body.rb +1 -1
- data/lib/schematic/components/types/update_component_request_body.rb +1 -1
- data/lib/schematic/componentspublic/client.rb +8 -1
- data/lib/schematic/credits/client.rb +409 -41
- data/lib/schematic/credits/types/acquire_credit_lease_request_body.rb +1 -1
- data/lib/schematic/credits/types/create_billing_credit_request_body.rb +1 -1
- data/lib/schematic/credits/types/create_company_credit_grant.rb +1 -1
- data/lib/schematic/credits/types/create_credit_bundle_request_body.rb +1 -1
- data/lib/schematic/credits/types/create_credit_spend_policy_request_body.rb +2 -2
- data/lib/schematic/credits/types/extend_credit_lease_request_body.rb +1 -1
- data/lib/schematic/credits/types/get_credit_balance_time_series_params.rb +18 -0
- data/lib/schematic/credits/types/get_credit_balance_time_series_request.rb +17 -0
- data/lib/schematic/credits/types/get_credit_balance_time_series_response.rb +13 -0
- data/lib/schematic/credits/types/reserve_credits_request_body.rb +1 -1
- data/lib/schematic/credits/types/update_credit_spend_policy_request_body.rb +2 -2
- data/lib/schematic/dataexports/client.rb +36 -6
- data/lib/schematic/entitlements/client.rb +244 -28
- data/lib/schematic/entitlements/types/create_billing_linked_plan_entitlement_request_body.rb +4 -2
- data/lib/schematic/entitlements/types/create_company_override_request_body.rb +3 -1
- data/lib/schematic/entitlements/types/create_plan_entitlement_request_body.rb +4 -2
- data/lib/schematic/entitlements/types/update_company_override_request_body.rb +3 -1
- data/lib/schematic/entitlements/types/update_plan_entitlement_request_body.rb +4 -2
- data/lib/schematic/errors/connection_error.rb +11 -0
- data/lib/schematic/errors/response_error.rb +23 -2
- data/lib/schematic/events/client.rb +78 -9
- data/lib/schematic/features/client.rb +160 -20
- data/lib/schematic/features/types/check_and_reserve_flag_request_body.rb +1 -1
- data/lib/schematic/features/types/create_billing_linked_feature_request_body.rb +2 -0
- data/lib/schematic/features/types/create_feature_request_body.rb +2 -0
- data/lib/schematic/features/types/update_feature_request_body.rb +2 -0
- data/lib/schematic/insights/client.rb +48 -6
- data/lib/schematic/integrationsapi/client.rb +120 -14
- data/lib/schematic/internal/http/base_request.rb +30 -0
- data/lib/schematic/internal/http/raw_client.rb +35 -5
- data/lib/schematic/internal/iterators/cursor_item_iterator.rb +9 -4
- data/lib/schematic/internal/iterators/cursor_page_iterator.rb +78 -15
- data/lib/schematic/internal/iterators/item_iterator.rb +70 -15
- data/lib/schematic/internal/iterators/offset_item_iterator.rb +9 -4
- data/lib/schematic/internal/iterators/offset_page_iterator.rb +71 -14
- data/lib/schematic/internal/json/request.rb +11 -2
- data/lib/schematic/internal/multipart/multipart_request.rb +1 -0
- data/lib/schematic/internal/types/model.rb +24 -4
- data/lib/schematic/internal/types/utils.rb +7 -0
- data/lib/schematic/licenses/client.rb +26 -3
- data/lib/schematic/planbundle/client.rb +27 -3
- data/lib/schematic/plangroups/client.rb +26 -3
- data/lib/schematic/planmigrations/client.rb +98 -11
- data/lib/schematic/plans/client.rb +274 -28
- data/lib/schematic/plans/types/get_plan_version_diff_params.rb +12 -0
- data/lib/schematic/plans/types/get_plan_version_diff_request.rb +13 -0
- data/lib/schematic/plans/types/get_plan_version_diff_response.rb +13 -0
- data/lib/schematic/plans/types/list_custom_plan_billings_params.rb +4 -0
- data/lib/schematic/plans/types/list_custom_plan_billings_request.rb +4 -0
- data/lib/schematic/plans/types/preview_publish_plan_version_response.rb +13 -0
- data/lib/schematic/rules_engine.rb +14 -2
- data/lib/schematic/scheduledcheckout/client.rb +35 -4
- data/lib/schematic/schematic_client.rb +22 -11
- data/lib/schematic/types/amendment_proration_lands_on.rb +13 -0
- data/lib/schematic/types/billing_coupon_response_data.rb +2 -2
- data/lib/schematic/types/billing_credit_grant_response_data.rb +8 -8
- data/lib/schematic/types/billing_customer_subscription.rb +1 -1
- data/lib/schematic/types/billing_invoice_detail_response_data.rb +49 -0
- data/lib/schematic/types/billing_invoice_line_response_data.rb +27 -0
- data/lib/schematic/types/billing_invoice_response_data.rb +43 -0
- data/lib/schematic/types/billing_invoice_settlement_response_data.rb +17 -0
- data/lib/schematic/types/billing_invoice_terms_response_data.rb +19 -0
- data/lib/schematic/types/billing_native_subscription_change_response_data.rb +15 -0
- data/lib/schematic/types/billing_native_subscription_line_response_data.rb +47 -0
- data/lib/schematic/types/billing_native_subscription_response_data.rb +31 -0
- data/lib/schematic/types/billing_plan_credit_grant_response_data.rb +1 -1
- data/lib/schematic/types/billing_price_response_data.rb +1 -1
- data/lib/schematic/types/billing_price_view.rb +1 -1
- data/lib/schematic/types/billing_product_detail_response_data.rb +2 -2
- data/lib/schematic/types/billing_product_for_subscription_response_data.rb +2 -2
- data/lib/schematic/types/billing_product_price_response_data.rb +1 -1
- data/lib/schematic/types/billing_product_pricing.rb +1 -1
- data/lib/schematic/types/billing_product_response_data.rb +2 -2
- data/lib/schematic/types/billing_settings_response_data.rb +9 -0
- data/lib/schematic/types/billing_statement_line_response_data.rb +21 -0
- data/lib/schematic/types/billing_statement_response_data.rb +19 -0
- data/lib/schematic/types/billing_subscription_discount_view.rb +2 -2
- data/lib/schematic/types/billing_subscription_response_data.rb +1 -1
- data/lib/schematic/types/billing_subscription_view.rb +1 -1
- data/lib/schematic/types/catalog_config_ordered_plan.rb +2 -0
- data/lib/schematic/types/catalog_config_ordered_plan_response_data.rb +2 -0
- data/lib/schematic/types/catalog_config_plan_credit.rb +11 -0
- data/lib/schematic/types/catalog_config_plan_credit_response_data.rb +11 -0
- data/lib/schematic/types/change_subscription_internal_request_body.rb +1 -1
- data/lib/schematic/types/change_subscription_request_body.rb +1 -1
- data/lib/schematic/types/charge_timing.rb +12 -0
- data/lib/schematic/types/checkout_problem_code.rb +54 -0
- data/lib/schematic/types/checkout_problem_response_data.rb +31 -0
- data/lib/schematic/types/checkout_problem_source.rb +13 -0
- data/lib/schematic/types/checkout_subscription.rb +1 -1
- data/lib/schematic/types/collector.rb +13 -0
- data/lib/schematic/types/company_billing_entity_subscription_response_data.rb +1 -1
- data/lib/schematic/types/company_billing_profile_response_data.rb +12 -0
- data/lib/schematic/types/company_credit_balance.rb +7 -3
- data/lib/schematic/types/company_credit_balance_response_data.rb +4 -4
- data/lib/schematic/types/company_detail_response_data.rb +1 -1
- data/lib/schematic/types/company_override_response_data.rb +3 -1
- data/lib/schematic/types/company_plan_credit_grant_view.rb +1 -1
- data/lib/schematic/types/company_plan_detail_response_data.rb +2 -0
- data/lib/schematic/types/company_subscription_response_data.rb +1 -1
- data/lib/schematic/types/company_user_usage_response_data.rb +2 -2
- data/lib/schematic/types/company_user_usage_row_response_data.rb +2 -2
- data/lib/schematic/types/component_response_data.rb +1 -1
- data/lib/schematic/types/condition.rb +3 -1
- data/lib/schematic/types/condition_response_data.rb +3 -1
- data/lib/schematic/types/condition_view.rb +3 -1
- data/lib/schematic/types/coupon_request_body.rb +2 -2
- data/lib/schematic/types/create_billing_plan_credit_grant_request_body.rb +1 -1
- data/lib/schematic/types/create_entitlement_in_bundle_request_body.rb +4 -2
- data/lib/schematic/types/create_entitlement_req_common.rb +3 -1
- data/lib/schematic/types/create_flag_request_body.rb +1 -1
- data/lib/schematic/types/create_or_update_condition_request_body.rb +1 -1
- data/lib/schematic/types/create_or_update_flag_request_body.rb +1 -1
- data/lib/schematic/types/credit_balance_event_response_data.rb +21 -0
- data/lib/schematic/types/credit_balance_feature_consumption_response_data.rb +13 -0
- data/lib/schematic/types/credit_balance_point_response_data.rb +15 -0
- data/lib/schematic/types/credit_balance_time_series_response_data.rb +15 -0
- data/lib/schematic/types/credit_bundle_currency_price.rb +1 -1
- data/lib/schematic/types/credit_bundle_currency_price_request_body.rb +1 -1
- data/lib/schematic/types/credit_bundle_currency_price_response_data.rb +1 -1
- data/lib/schematic/types/credit_burn_breakdown_line.rb +15 -0
- data/lib/schematic/types/credit_company_grant_view.rb +8 -8
- data/lib/schematic/types/credit_currency_price.rb +1 -1
- data/lib/schematic/types/credit_currency_price_request_body.rb +1 -1
- data/lib/schematic/types/credit_currency_price_response_data.rb +1 -1
- data/lib/schematic/types/credit_event_ledger_response_data.rb +10 -6
- data/lib/schematic/types/credit_grant_detail.rb +1 -1
- data/lib/schematic/types/credit_lease_response_data.rb +2 -2
- data/lib/schematic/types/credit_reservation_response_data.rb +2 -2
- data/lib/schematic/types/credit_spend_policy.rb +4 -2
- data/lib/schematic/types/credit_spend_policy_response_data.rb +4 -4
- data/lib/schematic/types/credit_transfer_response_data.rb +1 -1
- data/lib/schematic/types/credit_transfer_view.rb +1 -1
- data/lib/schematic/types/credit_usage.rb +5 -5
- data/lib/schematic/types/credit_usage_aggregation.rb +4 -4
- data/lib/schematic/types/credit_usage_reason.rb +1 -0
- data/lib/schematic/types/credits_in_plan.rb +11 -0
- data/lib/schematic/types/currency.rb +144 -0
- data/lib/schematic/types/currency_price_request_body.rb +1 -1
- data/lib/schematic/types/custom_plan_billing_response_data.rb +6 -0
- data/lib/schematic/types/entitlement_currency_prices_response_data.rb +1 -1
- data/lib/schematic/types/estimated_plan_total.rb +1 -1
- data/lib/schematic/types/event_body_inference.rb +4 -0
- data/lib/schematic/types/feature_company_response_data.rb +7 -7
- data/lib/schematic/types/feature_detail_response_data.rb +2 -0
- data/lib/schematic/types/feature_entitlement.rb +8 -6
- data/lib/schematic/types/feature_event_source.rb +12 -0
- data/lib/schematic/types/feature_in_plan_response_data.rb +2 -0
- data/lib/schematic/types/feature_response_data.rb +2 -0
- data/lib/schematic/types/feature_usage_response_data.rb +7 -7
- data/lib/schematic/types/feature_view.rb +2 -0
- data/lib/schematic/types/flag_check_reservation_response_data.rb +3 -3
- data/lib/schematic/types/flag_detail_response_data.rb +1 -1
- data/lib/schematic/types/flag_in_plan_response_data.rb +1 -1
- data/lib/schematic/types/flag_response_data.rb +1 -1
- data/lib/schematic/types/insights_summary_response_data.rb +1 -1
- data/lib/schematic/types/invoice_collection_state.rb +17 -0
- data/lib/schematic/types/invoice_document_state.rb +14 -0
- data/lib/schematic/types/invoice_line_kind.rb +15 -0
- data/lib/schematic/types/invoice_request_body.rb +1 -1
- data/lib/schematic/types/invoice_response_data.rb +1 -1
- data/lib/schematic/types/line_kind.rb +13 -0
- data/lib/schematic/types/manage_plan_preview_response_response_data.rb +2 -0
- data/lib/schematic/types/manage_plan_request.rb +3 -1
- data/lib/schematic/types/manage_plan_response_response_data.rb +4 -0
- data/lib/schematic/types/mrr_response_data.rb +1 -1
- data/lib/schematic/types/onboarding_milestone_view.rb +1 -1
- data/lib/schematic/types/ordered_plans_in_group.rb +2 -0
- data/lib/schematic/types/payment_gating.rb +12 -0
- data/lib/schematic/types/plan_billing_source.rb +1 -0
- data/lib/schematic/types/plan_change_action.rb +1 -0
- data/lib/schematic/types/plan_change_amendment_status.rb +15 -0
- data/lib/schematic/types/plan_change_response_data.rb +4 -0
- data/lib/schematic/types/plan_credit_grant_view.rb +1 -1
- data/lib/schematic/types/plan_credit_order.rb +11 -0
- data/lib/schematic/types/plan_credit_visibility.rb +11 -0
- data/lib/schematic/types/plan_currency_price_request_body.rb +1 -1
- data/lib/schematic/types/plan_currency_prices_response_data.rb +1 -1
- data/lib/schematic/types/plan_entitlement_response_data.rb +3 -1
- data/lib/schematic/types/plan_group_plan_entitlements_order.rb +2 -0
- data/lib/schematic/types/plan_version_billing_product_change_response_data.rb +11 -0
- data/lib/schematic/types/plan_version_credit_grant_change_response_data.rb +17 -0
- data/lib/schematic/types/plan_version_diff_change_type.rb +13 -0
- data/lib/schematic/types/plan_version_diff_price_cadence.rb +14 -0
- data/lib/schematic/types/plan_version_diff_response_data.rb +23 -0
- data/lib/schematic/types/plan_version_entitlement_change_response_data.rb +17 -0
- data/lib/schematic/types/plan_version_field_change_response_data.rb +13 -0
- data/lib/schematic/types/plan_version_price_change_response_data.rb +15 -0
- data/lib/schematic/types/plan_view_public_response_data.rb +2 -0
- data/lib/schematic/types/preflight_event_quantities_request_body.rb +13 -0
- data/lib/schematic/types/preflight_request_body.rb +3 -1
- data/lib/schematic/types/preview_subscription_change_response_data.rb +3 -1
- data/lib/schematic/types/preview_subscription_discount_response_data.rb +2 -2
- data/lib/schematic/types/preview_subscription_finance_response_data.rb +2 -2
- data/lib/schematic/types/publish_plan_version_request_body.rb +43 -0
- data/lib/schematic/types/publish_preview_pay_in_advance_response_data.rb +15 -0
- data/lib/schematic/types/publish_preview_payment_method_response_data.rb +15 -0
- data/lib/schematic/types/publish_preview_proration_line_response_data.rb +19 -0
- data/lib/schematic/types/publish_preview_response_data.rb +53 -0
- data/lib/schematic/types/rulesengine_company.rb +1 -1
- data/lib/schematic/types/rulesengine_condition.rb +3 -1
- data/lib/schematic/types/rulesengine_credit_postpaid_config.rb +1 -1
- data/lib/schematic/types/rulesengine_credit_spend_policy.rb +4 -2
- data/lib/schematic/types/rulesengine_feature_entitlement.rb +8 -6
- data/lib/schematic/types/scheduled_downgrade_response_data.rb +1 -1
- data/lib/schematic/types/subscription_change_action.rb +14 -0
- data/lib/schematic/types/top_feature_by_usage_response_data.rb +1 -1
- data/lib/schematic/types/upcoming_invoice_response_data.rb +1 -1
- data/lib/schematic/types/update_billing_plan_credit_grant_request_body.rb +1 -1
- data/lib/schematic/types/update_entitlement_req_common.rb +3 -1
- data/lib/schematic/types/upsert_billing_product_request_body.rb +1 -1
- data/lib/schematic/types/usage_based_entitlement_request_body.rb +1 -1
- data/lib/schematic/types/usage_based_entitlement_response_data.rb +1 -1
- data/lib/schematic/types/user_credit_usage_response_data.rb +2 -2
- data/lib/schematic/types/user_daily_credit_point_response_data.rb +1 -1
- data/lib/schematic/types/user_feature_usage_response_data.rb +1 -1
- data/lib/schematic/version.rb +1 -1
- data/lib/schematic/wasm/rulesengine.wasm +0 -0
- data/lib/schematic/webhooks/client.rb +88 -10
- data/lib/schematic.rb +80 -8
- data/reference.md +892 -113
- metadata +75 -3
- data/lib/schematic/plans/types/publish_plan_version_request_body.rb +0 -45
|
@@ -12,46 +12,84 @@ module Schematic
|
|
|
12
12
|
# Instantiates an OffsetPageIterator, an Enumerable class which wraps calls to an offset-based paginated API and yields pages of items from it.
|
|
13
13
|
#
|
|
14
14
|
# @param initial_page [Integer] The initial page to use when iterating, if any.
|
|
15
|
-
# @param item_field [Symbol] The field to pull the list of items to iterate over.
|
|
16
|
-
# @param has_next_field [Symbol] The field to pull the boolean of whether a next page exists from, if any.
|
|
15
|
+
# @param item_field [Symbol, Array<Symbol>] The field (or nested path) to pull the list of items to iterate over.
|
|
16
|
+
# @param has_next_field [Symbol, Array<Symbol>] The field (or nested path) to pull the boolean of whether a next page exists from, if any.
|
|
17
17
|
# @param step [Boolean] If true, treats the page number as a true offset (i.e. increments the page number by the number of items returned from each call rather than just 1)
|
|
18
18
|
# @param block [Proc] A block which is responsible for receiving a page number to use and returning the given page from the API.
|
|
19
19
|
# The block should return a two-element array: [parsed_page, raw_http_response].
|
|
20
20
|
# @return [Schematic::Internal::OffsetPageIterator]
|
|
21
21
|
def initialize(initial_page:, item_field:, has_next_field:, step:, &block)
|
|
22
|
-
@
|
|
22
|
+
@initial_page = initial_page || (step ? 0 : 1)
|
|
23
23
|
@item_field = item_field
|
|
24
24
|
@has_next_field = has_next_field
|
|
25
25
|
@step = step
|
|
26
26
|
@get_next_page = block
|
|
27
|
+
@http_response = nil
|
|
28
|
+
@first_page_requested = false
|
|
29
|
+
@first_page = nil
|
|
30
|
+
rewind
|
|
31
|
+
end
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
# Sends the request for the first page now instead of on the first iteration, so an API error for that page
|
|
34
|
+
# is raised here. The page is kept, and every loop that starts from the first page reuses it instead of
|
|
35
|
+
# requesting it again (an empty first page ends those loops without a new request). Does nothing if the first
|
|
36
|
+
# page was already requested.
|
|
37
|
+
#
|
|
38
|
+
# @return [self]
|
|
39
|
+
def load_first_page
|
|
40
|
+
return self if @first_page_requested
|
|
32
41
|
|
|
33
|
-
@
|
|
42
|
+
@first_page = fetch_page(@initial_page)
|
|
43
|
+
rewind
|
|
44
|
+
self
|
|
34
45
|
end
|
|
35
46
|
|
|
36
|
-
#
|
|
47
|
+
# Uses the first page that `other` loaded with `load_first_page`, unless this iterator already sent a request.
|
|
37
48
|
#
|
|
38
|
-
# @param
|
|
49
|
+
# @param other [Schematic::Internal::OffsetPageIterator]
|
|
39
50
|
# @return [NilClass]
|
|
51
|
+
def reuse_first_page(other)
|
|
52
|
+
return if @first_page_requested || other.first_page.nil?
|
|
53
|
+
|
|
54
|
+
@first_page = other.first_page
|
|
55
|
+
rewind
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Iterates over each page returned by the API, starting again from the first page on every call.
|
|
59
|
+
#
|
|
60
|
+
# @param block [Proc] The block which each retrieved page is yielded to.
|
|
61
|
+
# @return [NilClass, Enumerator] An Enumerator when no block is given.
|
|
40
62
|
def each(&block)
|
|
63
|
+
return enum_for(:each) unless block_given?
|
|
64
|
+
|
|
65
|
+
rewind
|
|
41
66
|
while (page = next_page)
|
|
42
67
|
block.call(page)
|
|
43
68
|
end
|
|
44
69
|
end
|
|
45
70
|
|
|
71
|
+
# Resets page-by-page iteration (`next_page` / `next?`) to the first page.
|
|
72
|
+
#
|
|
73
|
+
# @return [NilClass]
|
|
74
|
+
def rewind
|
|
75
|
+
@page_number = @initial_page
|
|
76
|
+
# A cache of whether the API has another page, if it gives us that information...
|
|
77
|
+
@has_next_page = nil
|
|
78
|
+
# ...or the actual next page, preloaded, if it doesn't. A first page kept by `load_first_page` is reused.
|
|
79
|
+
@next_page = @first_page
|
|
80
|
+
nil
|
|
81
|
+
end
|
|
82
|
+
|
|
46
83
|
# Whether another page will be available from the API.
|
|
47
84
|
#
|
|
48
85
|
# @return [Boolean]
|
|
49
86
|
def next?
|
|
50
87
|
return @has_next_page unless @has_next_page.nil?
|
|
51
|
-
return true if @next_page
|
|
88
|
+
return true if @next_page && page_has_items?(@next_page)
|
|
89
|
+
return @has_next_page = false if @next_page
|
|
52
90
|
|
|
53
91
|
fetched_page = fetch_page(@page_number)
|
|
54
|
-
fetched_page_items = fetched_page
|
|
92
|
+
fetched_page_items = read_field(fetched_page, @item_field)
|
|
55
93
|
if fetched_page_items.nil? || fetched_page_items.empty?
|
|
56
94
|
@has_next_page = false
|
|
57
95
|
else
|
|
@@ -71,9 +109,9 @@ module Schematic
|
|
|
71
109
|
this_page = fetch_page(@page_number)
|
|
72
110
|
end
|
|
73
111
|
|
|
74
|
-
@has_next_page = this_page
|
|
112
|
+
@has_next_page = read_field(this_page, @has_next_field) if @has_next_field
|
|
75
113
|
|
|
76
|
-
items = this_page
|
|
114
|
+
items = read_field(this_page, @item_field)
|
|
77
115
|
if items.nil? || items.empty?
|
|
78
116
|
@page_number = nil
|
|
79
117
|
return nil
|
|
@@ -86,10 +124,20 @@ module Schematic
|
|
|
86
124
|
this_page
|
|
87
125
|
end
|
|
88
126
|
|
|
127
|
+
protected
|
|
128
|
+
|
|
129
|
+
attr_reader :first_page
|
|
130
|
+
|
|
89
131
|
private
|
|
90
132
|
|
|
133
|
+
def page_has_items?(page)
|
|
134
|
+
items = read_field(page, @item_field)
|
|
135
|
+
!items.nil? && !items.empty?
|
|
136
|
+
end
|
|
137
|
+
|
|
91
138
|
def fetch_page(page_number)
|
|
92
139
|
result = @get_next_page.call(page_number)
|
|
140
|
+
@first_page_requested = true
|
|
93
141
|
if result.is_a?(Array)
|
|
94
142
|
fetched_page, raw_response = result
|
|
95
143
|
@http_response = raw_response
|
|
@@ -98,6 +146,15 @@ module Schematic
|
|
|
98
146
|
result
|
|
99
147
|
end
|
|
100
148
|
end
|
|
149
|
+
|
|
150
|
+
# Reads a field from an API response, walking through enclosing objects when the field is nested.
|
|
151
|
+
#
|
|
152
|
+
# @param value [Object, nil] The API response.
|
|
153
|
+
# @param field [Symbol, Array<Symbol>] The field name, or the path of field names for a nested field.
|
|
154
|
+
# @return [Object, nil]
|
|
155
|
+
def read_field(value, field)
|
|
156
|
+
Array(field).reduce(value) { |object, name| object&.send(name) }
|
|
157
|
+
end
|
|
101
158
|
end
|
|
102
159
|
end
|
|
103
160
|
end
|
|
@@ -31,9 +31,18 @@ module Schematic
|
|
|
31
31
|
merge_additional_headers(sdk_headers, protected_keys:)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
# @return [String, nil] The encoded HTTP request body
|
|
34
|
+
# @return [String, nil] The encoded HTTP request body, including any additional_body_parameters
|
|
35
|
+
# from request_options.
|
|
35
36
|
def encode_body
|
|
36
|
-
|
|
37
|
+
body = request_body
|
|
38
|
+
body.nil? ? nil : ::JSON.generate(body)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
# @return [Object, nil] The request body merged with additional_body_parameters.
|
|
44
|
+
def request_body
|
|
45
|
+
merge_additional_body_parameters(@body)
|
|
37
46
|
end
|
|
38
47
|
end
|
|
39
48
|
end
|
|
@@ -94,6 +94,18 @@ module Schematic
|
|
|
94
94
|
define_setter(name)
|
|
95
95
|
end
|
|
96
96
|
|
|
97
|
+
# Whether an unknown input key is dropped instead of kept as an extra field: it matches a declared
|
|
98
|
+
# field's name or API name, ignoring case
|
|
99
|
+
#
|
|
100
|
+
# @api private
|
|
101
|
+
#
|
|
102
|
+
# @param key [Symbol, String]
|
|
103
|
+
# @return [Boolean]
|
|
104
|
+
def drop_extra_key?(key)
|
|
105
|
+
key = key.to_s
|
|
106
|
+
fields.any? { |name, field| name.to_s.casecmp?(key) || field.api_name.to_s.casecmp?(key) }
|
|
107
|
+
end
|
|
108
|
+
|
|
97
109
|
# @api private
|
|
98
110
|
private def define_accessor(name)
|
|
99
111
|
method_name = name.to_sym
|
|
@@ -108,6 +120,7 @@ module Schematic
|
|
|
108
120
|
method_name = :"#{name}="
|
|
109
121
|
|
|
110
122
|
define_method(method_name) do |val|
|
|
123
|
+
@explicit_fields[name] = true
|
|
111
124
|
@data[name] = val
|
|
112
125
|
end
|
|
113
126
|
end
|
|
@@ -137,6 +150,7 @@ module Schematic
|
|
|
137
150
|
# @return [self]
|
|
138
151
|
def initialize(values = {})
|
|
139
152
|
@data = {}
|
|
153
|
+
@explicit_fields = {}
|
|
140
154
|
|
|
141
155
|
values = Utils.symbolize_keys(values.dup)
|
|
142
156
|
|
|
@@ -145,6 +159,7 @@ module Schematic
|
|
|
145
159
|
[field.api_name.to_sym, field_name].uniq.each do |key|
|
|
146
160
|
next unless values.key?(key)
|
|
147
161
|
|
|
162
|
+
@explicit_fields[field_name] = true
|
|
148
163
|
candidate = values.delete(key)
|
|
149
164
|
value = candidate if value.nil?
|
|
150
165
|
end
|
|
@@ -160,8 +175,12 @@ module Schematic
|
|
|
160
175
|
@data[field_name] = Utils.coerce(field.type, field_value)
|
|
161
176
|
end
|
|
162
177
|
|
|
163
|
-
# Any remaining values in the input become extra fields
|
|
178
|
+
# Any remaining values in the input become extra fields, except keys that match a declared field
|
|
179
|
+
# case-insensitively (e.g. `VALUE` next to `value`): re-emitting those would let a case-insensitive
|
|
180
|
+
# JSON decoder downstream read the extra key instead of the declared field.
|
|
164
181
|
values.each do |name, value|
|
|
182
|
+
next if self.class.drop_extra_key?(name)
|
|
183
|
+
|
|
165
184
|
self.class.add_extra_field_definition(name: name, type: value.class)
|
|
166
185
|
|
|
167
186
|
@data[name.to_sym] = value
|
|
@@ -173,14 +192,15 @@ module Schematic
|
|
|
173
192
|
# If there is a value present in the data, use that value
|
|
174
193
|
# If there is a `nil` value present in the data, and it is optional but NOT nullable, exclude key altogether
|
|
175
194
|
# If there is a `nil` value present in the data, and it is optional and nullable, use the nil value
|
|
195
|
+
# only when it was explicitly provided; an omitted optional field is excluded
|
|
176
196
|
|
|
177
197
|
value = @data[name]
|
|
178
198
|
|
|
179
|
-
next if value.nil? && field.optional && !field.nullable
|
|
199
|
+
next if value.nil? && field.optional && (!field.nullable || !@explicit_fields&.key?(name))
|
|
180
200
|
|
|
181
201
|
if value.is_a?(::Array)
|
|
182
|
-
value = value.map { |item| item.respond_to?(:to_h) ? item.to_h : item }
|
|
183
|
-
elsif value.respond_to?(:to_h)
|
|
202
|
+
value = value.map { |item| !item.nil? && item.respond_to?(:to_h) ? item.to_h : item }
|
|
203
|
+
elsif !value.nil? && value.respond_to?(:to_h)
|
|
184
204
|
value = value.to_h
|
|
185
205
|
end
|
|
186
206
|
|
|
@@ -60,11 +60,18 @@ module Schematic
|
|
|
60
60
|
case value
|
|
61
61
|
when Numeric, String, Time
|
|
62
62
|
return value.to_i
|
|
63
|
+
when Symbol
|
|
64
|
+
# JSON object keys are parsed as symbols, so numeric map keys arrive as e.g. :"1"
|
|
65
|
+
parsed = Integer(value.to_s, 10, exception: false)
|
|
66
|
+
return parsed unless parsed.nil?
|
|
63
67
|
end
|
|
64
68
|
in ->(t) { t <= Float }
|
|
65
69
|
case value
|
|
66
70
|
when Numeric, Time, String
|
|
67
71
|
return value.to_f
|
|
72
|
+
when Symbol
|
|
73
|
+
parsed = Float(value.to_s, exception: false)
|
|
74
|
+
return parsed unless parsed.nil?
|
|
68
75
|
end
|
|
69
76
|
in ->(t) { t <= Model }
|
|
70
77
|
case value
|
|
@@ -59,7 +59,15 @@ module Schematic
|
|
|
59
59
|
(response.body.to_s.empty? ? nil : Schematic::Licenses::Types::ListLicensesResponse.load(response.body))
|
|
60
60
|
else
|
|
61
61
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
62
|
-
|
|
62
|
+
error_types = {
|
|
63
|
+
400 => Schematic::Types::ApiError,
|
|
64
|
+
401 => Schematic::Types::ApiError,
|
|
65
|
+
403 => Schematic::Types::ApiError,
|
|
66
|
+
404 => Schematic::Types::ApiError,
|
|
67
|
+
500 => Schematic::Types::ApiError
|
|
68
|
+
}
|
|
69
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
70
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
63
71
|
end
|
|
64
72
|
end
|
|
65
73
|
|
|
@@ -94,7 +102,14 @@ module Schematic
|
|
|
94
102
|
(response.body.to_s.empty? ? nil : Schematic::Licenses::Types::GetSingleLicenseResponse.load(response.body))
|
|
95
103
|
else
|
|
96
104
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
97
|
-
|
|
105
|
+
error_types = {
|
|
106
|
+
401 => Schematic::Types::ApiError,
|
|
107
|
+
403 => Schematic::Types::ApiError,
|
|
108
|
+
404 => Schematic::Types::ApiError,
|
|
109
|
+
500 => Schematic::Types::ApiError
|
|
110
|
+
}
|
|
111
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
112
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
98
113
|
end
|
|
99
114
|
end
|
|
100
115
|
|
|
@@ -147,7 +162,15 @@ module Schematic
|
|
|
147
162
|
(response.body.to_s.empty? ? nil : Schematic::Licenses::Types::CountLicensesResponse.load(response.body))
|
|
148
163
|
else
|
|
149
164
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
150
|
-
|
|
165
|
+
error_types = {
|
|
166
|
+
400 => Schematic::Types::ApiError,
|
|
167
|
+
401 => Schematic::Types::ApiError,
|
|
168
|
+
403 => Schematic::Types::ApiError,
|
|
169
|
+
404 => Schematic::Types::ApiError,
|
|
170
|
+
500 => Schematic::Types::ApiError
|
|
171
|
+
}
|
|
172
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
173
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
151
174
|
end
|
|
152
175
|
end
|
|
153
176
|
end
|
|
@@ -53,7 +53,15 @@ module Schematic
|
|
|
53
53
|
(response.body.to_s.empty? ? nil : Schematic::Planbundle::Types::CreateCustomPlanBundleResponse.load(response.body))
|
|
54
54
|
else
|
|
55
55
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
56
|
-
|
|
56
|
+
error_types = {
|
|
57
|
+
400 => Schematic::Types::ApiError,
|
|
58
|
+
401 => Schematic::Types::ApiError,
|
|
59
|
+
403 => Schematic::Types::ApiError,
|
|
60
|
+
404 => Schematic::Types::ApiError,
|
|
61
|
+
500 => Schematic::Types::ApiError
|
|
62
|
+
}
|
|
63
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
64
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
57
65
|
end
|
|
58
66
|
end
|
|
59
67
|
|
|
@@ -96,7 +104,15 @@ module Schematic
|
|
|
96
104
|
(response.body.to_s.empty? ? nil : Schematic::Planbundle::Types::CreatePlanBundleResponse.load(response.body))
|
|
97
105
|
else
|
|
98
106
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
99
|
-
|
|
107
|
+
error_types = {
|
|
108
|
+
400 => Schematic::Types::ApiError,
|
|
109
|
+
401 => Schematic::Types::ApiError,
|
|
110
|
+
403 => Schematic::Types::ApiError,
|
|
111
|
+
404 => Schematic::Types::ApiError,
|
|
112
|
+
500 => Schematic::Types::ApiError
|
|
113
|
+
}
|
|
114
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
115
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
100
116
|
end
|
|
101
117
|
end
|
|
102
118
|
|
|
@@ -144,7 +160,15 @@ module Schematic
|
|
|
144
160
|
(response.body.to_s.empty? ? nil : Schematic::Planbundle::Types::UpdatePlanBundleResponse.load(response.body))
|
|
145
161
|
else
|
|
146
162
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
147
|
-
|
|
163
|
+
error_types = {
|
|
164
|
+
400 => Schematic::Types::ApiError,
|
|
165
|
+
401 => Schematic::Types::ApiError,
|
|
166
|
+
403 => Schematic::Types::ApiError,
|
|
167
|
+
404 => Schematic::Types::ApiError,
|
|
168
|
+
500 => Schematic::Types::ApiError
|
|
169
|
+
}
|
|
170
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
171
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
148
172
|
end
|
|
149
173
|
end
|
|
150
174
|
end
|
|
@@ -45,7 +45,14 @@ module Schematic
|
|
|
45
45
|
(response.body.to_s.empty? ? nil : Schematic::Plangroups::Types::GetPlanGroupResponse.load(response.body))
|
|
46
46
|
else
|
|
47
47
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
48
|
-
|
|
48
|
+
error_types = {
|
|
49
|
+
401 => Schematic::Types::ApiError,
|
|
50
|
+
403 => Schematic::Types::ApiError,
|
|
51
|
+
404 => Schematic::Types::ApiError,
|
|
52
|
+
500 => Schematic::Types::ApiError
|
|
53
|
+
}
|
|
54
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
55
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
49
56
|
end
|
|
50
57
|
end
|
|
51
58
|
|
|
@@ -108,7 +115,15 @@ module Schematic
|
|
|
108
115
|
(response.body.to_s.empty? ? nil : Schematic::Plangroups::Types::CreatePlanGroupResponse.load(response.body))
|
|
109
116
|
else
|
|
110
117
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
111
|
-
|
|
118
|
+
error_types = {
|
|
119
|
+
400 => Schematic::Types::ApiError,
|
|
120
|
+
401 => Schematic::Types::ApiError,
|
|
121
|
+
403 => Schematic::Types::ApiError,
|
|
122
|
+
404 => Schematic::Types::ApiError,
|
|
123
|
+
500 => Schematic::Types::ApiError
|
|
124
|
+
}
|
|
125
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
126
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
112
127
|
end
|
|
113
128
|
end
|
|
114
129
|
|
|
@@ -177,7 +192,15 @@ module Schematic
|
|
|
177
192
|
(response.body.to_s.empty? ? nil : Schematic::Plangroups::Types::UpdatePlanGroupResponse.load(response.body))
|
|
178
193
|
else
|
|
179
194
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
180
|
-
|
|
195
|
+
error_types = {
|
|
196
|
+
400 => Schematic::Types::ApiError,
|
|
197
|
+
401 => Schematic::Types::ApiError,
|
|
198
|
+
403 => Schematic::Types::ApiError,
|
|
199
|
+
404 => Schematic::Types::ApiError,
|
|
200
|
+
500 => Schematic::Types::ApiError
|
|
201
|
+
}
|
|
202
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
203
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
181
204
|
end
|
|
182
205
|
end
|
|
183
206
|
end
|
|
@@ -59,7 +59,15 @@ module Schematic
|
|
|
59
59
|
(response.body.to_s.empty? ? nil : Schematic::Planmigrations::Types::ListCompanyMigrationsResponse.load(response.body))
|
|
60
60
|
else
|
|
61
61
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
62
|
-
|
|
62
|
+
error_types = {
|
|
63
|
+
400 => Schematic::Types::ApiError,
|
|
64
|
+
401 => Schematic::Types::ApiError,
|
|
65
|
+
403 => Schematic::Types::ApiError,
|
|
66
|
+
404 => Schematic::Types::ApiError,
|
|
67
|
+
500 => Schematic::Types::ApiError
|
|
68
|
+
}
|
|
69
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
70
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
63
71
|
end
|
|
64
72
|
end
|
|
65
73
|
|
|
@@ -94,7 +102,15 @@ module Schematic
|
|
|
94
102
|
(response.body.to_s.empty? ? nil : Schematic::Planmigrations::Types::RetryCompanyMigrationResponse.load(response.body))
|
|
95
103
|
else
|
|
96
104
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
97
|
-
|
|
105
|
+
error_types = {
|
|
106
|
+
400 => Schematic::Types::ApiError,
|
|
107
|
+
401 => Schematic::Types::ApiError,
|
|
108
|
+
403 => Schematic::Types::ApiError,
|
|
109
|
+
404 => Schematic::Types::ApiError,
|
|
110
|
+
500 => Schematic::Types::ApiError
|
|
111
|
+
}
|
|
112
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
113
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
98
114
|
end
|
|
99
115
|
end
|
|
100
116
|
|
|
@@ -147,7 +163,15 @@ module Schematic
|
|
|
147
163
|
(response.body.to_s.empty? ? nil : Schematic::Planmigrations::Types::CountCompanyMigrationsResponse.load(response.body))
|
|
148
164
|
else
|
|
149
165
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
150
|
-
|
|
166
|
+
error_types = {
|
|
167
|
+
400 => Schematic::Types::ApiError,
|
|
168
|
+
401 => Schematic::Types::ApiError,
|
|
169
|
+
403 => Schematic::Types::ApiError,
|
|
170
|
+
404 => Schematic::Types::ApiError,
|
|
171
|
+
500 => Schematic::Types::ApiError
|
|
172
|
+
}
|
|
173
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
174
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
151
175
|
end
|
|
152
176
|
end
|
|
153
177
|
|
|
@@ -203,7 +227,15 @@ module Schematic
|
|
|
203
227
|
(response.body.to_s.empty? ? nil : Schematic::Planmigrations::Types::ListMigrationsResponse.load(response.body))
|
|
204
228
|
else
|
|
205
229
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
206
|
-
|
|
230
|
+
error_types = {
|
|
231
|
+
400 => Schematic::Types::ApiError,
|
|
232
|
+
401 => Schematic::Types::ApiError,
|
|
233
|
+
403 => Schematic::Types::ApiError,
|
|
234
|
+
404 => Schematic::Types::ApiError,
|
|
235
|
+
500 => Schematic::Types::ApiError
|
|
236
|
+
}
|
|
237
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
238
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
207
239
|
end
|
|
208
240
|
end
|
|
209
241
|
|
|
@@ -243,7 +275,15 @@ module Schematic
|
|
|
243
275
|
(response.body.to_s.empty? ? nil : Schematic::Planmigrations::Types::CreateMigrationResponse.load(response.body))
|
|
244
276
|
else
|
|
245
277
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
246
|
-
|
|
278
|
+
error_types = {
|
|
279
|
+
400 => Schematic::Types::ApiError,
|
|
280
|
+
401 => Schematic::Types::ApiError,
|
|
281
|
+
403 => Schematic::Types::ApiError,
|
|
282
|
+
404 => Schematic::Types::ApiError,
|
|
283
|
+
500 => Schematic::Types::ApiError
|
|
284
|
+
}
|
|
285
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
286
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
247
287
|
end
|
|
248
288
|
end
|
|
249
289
|
|
|
@@ -278,7 +318,14 @@ module Schematic
|
|
|
278
318
|
(response.body.to_s.empty? ? nil : Schematic::Planmigrations::Types::GetMigrationResponse.load(response.body))
|
|
279
319
|
else
|
|
280
320
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
281
|
-
|
|
321
|
+
error_types = {
|
|
322
|
+
401 => Schematic::Types::ApiError,
|
|
323
|
+
403 => Schematic::Types::ApiError,
|
|
324
|
+
404 => Schematic::Types::ApiError,
|
|
325
|
+
500 => Schematic::Types::ApiError
|
|
326
|
+
}
|
|
327
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
328
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
282
329
|
end
|
|
283
330
|
end
|
|
284
331
|
|
|
@@ -313,7 +360,15 @@ module Schematic
|
|
|
313
360
|
(response.body.to_s.empty? ? nil : Schematic::Planmigrations::Types::CancelMigrationResponse.load(response.body))
|
|
314
361
|
else
|
|
315
362
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
316
|
-
|
|
363
|
+
error_types = {
|
|
364
|
+
400 => Schematic::Types::ApiError,
|
|
365
|
+
401 => Schematic::Types::ApiError,
|
|
366
|
+
403 => Schematic::Types::ApiError,
|
|
367
|
+
404 => Schematic::Types::ApiError,
|
|
368
|
+
500 => Schematic::Types::ApiError
|
|
369
|
+
}
|
|
370
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
371
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
317
372
|
end
|
|
318
373
|
end
|
|
319
374
|
|
|
@@ -353,7 +408,15 @@ module Schematic
|
|
|
353
408
|
(response.body.to_s.empty? ? nil : Schematic::Planmigrations::Types::CompleteMigrationNowResponse.load(response.body))
|
|
354
409
|
else
|
|
355
410
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
356
|
-
|
|
411
|
+
error_types = {
|
|
412
|
+
400 => Schematic::Types::ApiError,
|
|
413
|
+
401 => Schematic::Types::ApiError,
|
|
414
|
+
403 => Schematic::Types::ApiError,
|
|
415
|
+
404 => Schematic::Types::ApiError,
|
|
416
|
+
500 => Schematic::Types::ApiError
|
|
417
|
+
}
|
|
418
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
419
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
357
420
|
end
|
|
358
421
|
end
|
|
359
422
|
|
|
@@ -396,7 +459,15 @@ module Schematic
|
|
|
396
459
|
(response.body.to_s.empty? ? nil : Schematic::Planmigrations::Types::RetryMigrationResponse.load(response.body))
|
|
397
460
|
else
|
|
398
461
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
399
|
-
|
|
462
|
+
error_types = {
|
|
463
|
+
400 => Schematic::Types::ApiError,
|
|
464
|
+
401 => Schematic::Types::ApiError,
|
|
465
|
+
403 => Schematic::Types::ApiError,
|
|
466
|
+
404 => Schematic::Types::ApiError,
|
|
467
|
+
500 => Schematic::Types::ApiError
|
|
468
|
+
}
|
|
469
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
470
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
400
471
|
end
|
|
401
472
|
end
|
|
402
473
|
|
|
@@ -452,7 +523,15 @@ module Schematic
|
|
|
452
523
|
(response.body.to_s.empty? ? nil : Schematic::Planmigrations::Types::CountMigrationsResponse.load(response.body))
|
|
453
524
|
else
|
|
454
525
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
455
|
-
|
|
526
|
+
error_types = {
|
|
527
|
+
400 => Schematic::Types::ApiError,
|
|
528
|
+
401 => Schematic::Types::ApiError,
|
|
529
|
+
403 => Schematic::Types::ApiError,
|
|
530
|
+
404 => Schematic::Types::ApiError,
|
|
531
|
+
500 => Schematic::Types::ApiError
|
|
532
|
+
}
|
|
533
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
534
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
456
535
|
end
|
|
457
536
|
end
|
|
458
537
|
|
|
@@ -491,7 +570,15 @@ module Schematic
|
|
|
491
570
|
(response.body.to_s.empty? ? nil : Schematic::Planmigrations::Types::PreviewMigrationResponse.load(response.body))
|
|
492
571
|
else
|
|
493
572
|
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
494
|
-
|
|
573
|
+
error_types = {
|
|
574
|
+
400 => Schematic::Types::ApiError,
|
|
575
|
+
401 => Schematic::Types::ApiError,
|
|
576
|
+
403 => Schematic::Types::ApiError,
|
|
577
|
+
404 => Schematic::Types::ApiError,
|
|
578
|
+
500 => Schematic::Types::ApiError
|
|
579
|
+
}
|
|
580
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
581
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
495
582
|
end
|
|
496
583
|
end
|
|
497
584
|
end
|