schematichq 1.5.3 → 1.5.4

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.
Files changed (220) hide show
  1. checksums.yaml +4 -4
  2. data/.fern/metadata.json +4 -4
  3. data/.fern/replay.lock +7 -1
  4. data/.fernignore +2 -0
  5. data/.rubocop.yml +4 -0
  6. data/README.md +1 -1
  7. data/WASM_VERSION +1 -1
  8. data/lib/schematic/accesstokens/client.rb +9 -1
  9. data/lib/schematic/accounts/client.rb +183 -21
  10. data/lib/schematic/billing/client.rb +325 -34
  11. data/lib/schematic/billing/types/create_billing_price_request_body.rb +1 -1
  12. data/lib/schematic/billing/types/create_billing_product_request_body.rb +1 -1
  13. data/lib/schematic/billing/types/create_billing_subscription_request_body.rb +1 -1
  14. data/lib/schematic/billing/types/create_coupon_request_body.rb +2 -2
  15. data/lib/schematic/billing/types/create_invoice_request_body.rb +1 -1
  16. data/lib/schematic/billing/types/get_billing_settings_response.rb +13 -0
  17. data/lib/schematic/billing/types/list_billing_prices_params.rb +1 -1
  18. data/lib/schematic/billing/types/list_billing_prices_request.rb +1 -1
  19. data/lib/schematic/billing/types/list_billing_product_prices_params.rb +1 -1
  20. data/lib/schematic/billing/types/list_billing_product_prices_request.rb +1 -1
  21. data/lib/schematic/billing/types/update_billing_settings_request_body.rb +11 -0
  22. data/lib/schematic/billing/types/update_billing_settings_response.rb +13 -0
  23. data/lib/schematic/catalogs/client.rb +121 -14
  24. data/lib/schematic/checkout/client.rb +80 -9
  25. data/lib/schematic/checkout/types/checkout_data_request_body.rb +1 -1
  26. data/lib/schematic/client.rb +5 -3
  27. data/lib/schematic/companies/client.rb +380 -44
  28. data/lib/schematic/components/client.rb +70 -8
  29. data/lib/schematic/components/types/create_component_request_body.rb +1 -1
  30. data/lib/schematic/components/types/update_component_request_body.rb +1 -1
  31. data/lib/schematic/componentspublic/client.rb +8 -1
  32. data/lib/schematic/credits/client.rb +409 -41
  33. data/lib/schematic/credits/types/acquire_credit_lease_request_body.rb +1 -1
  34. data/lib/schematic/credits/types/create_billing_credit_request_body.rb +1 -1
  35. data/lib/schematic/credits/types/create_company_credit_grant.rb +1 -1
  36. data/lib/schematic/credits/types/create_credit_bundle_request_body.rb +1 -1
  37. data/lib/schematic/credits/types/create_credit_spend_policy_request_body.rb +2 -2
  38. data/lib/schematic/credits/types/extend_credit_lease_request_body.rb +1 -1
  39. data/lib/schematic/credits/types/get_credit_balance_time_series_params.rb +18 -0
  40. data/lib/schematic/credits/types/get_credit_balance_time_series_request.rb +17 -0
  41. data/lib/schematic/credits/types/get_credit_balance_time_series_response.rb +13 -0
  42. data/lib/schematic/credits/types/reserve_credits_request_body.rb +1 -1
  43. data/lib/schematic/credits/types/update_credit_spend_policy_request_body.rb +2 -2
  44. data/lib/schematic/dataexports/client.rb +36 -6
  45. data/lib/schematic/entitlements/client.rb +244 -28
  46. data/lib/schematic/entitlements/types/create_billing_linked_plan_entitlement_request_body.rb +4 -2
  47. data/lib/schematic/entitlements/types/create_company_override_request_body.rb +3 -1
  48. data/lib/schematic/entitlements/types/create_plan_entitlement_request_body.rb +4 -2
  49. data/lib/schematic/entitlements/types/update_company_override_request_body.rb +3 -1
  50. data/lib/schematic/entitlements/types/update_plan_entitlement_request_body.rb +4 -2
  51. data/lib/schematic/errors/connection_error.rb +11 -0
  52. data/lib/schematic/errors/response_error.rb +23 -2
  53. data/lib/schematic/events/client.rb +78 -9
  54. data/lib/schematic/features/client.rb +160 -18
  55. data/lib/schematic/features/types/check_and_reserve_flag_request_body.rb +1 -1
  56. data/lib/schematic/features/types/create_billing_linked_feature_request_body.rb +2 -0
  57. data/lib/schematic/features/types/create_feature_request_body.rb +2 -0
  58. data/lib/schematic/features/types/update_feature_request_body.rb +2 -0
  59. data/lib/schematic/insights/client.rb +48 -6
  60. data/lib/schematic/integrationsapi/client.rb +120 -14
  61. data/lib/schematic/internal/http/base_request.rb +30 -0
  62. data/lib/schematic/internal/http/raw_client.rb +35 -5
  63. data/lib/schematic/internal/iterators/cursor_item_iterator.rb +7 -2
  64. data/lib/schematic/internal/iterators/cursor_page_iterator.rb +68 -14
  65. data/lib/schematic/internal/iterators/item_iterator.rb +61 -15
  66. data/lib/schematic/internal/iterators/offset_item_iterator.rb +7 -2
  67. data/lib/schematic/internal/iterators/offset_page_iterator.rb +57 -9
  68. data/lib/schematic/internal/json/request.rb +11 -2
  69. data/lib/schematic/internal/multipart/multipart_request.rb +1 -0
  70. data/lib/schematic/internal/types/model.rb +7 -3
  71. data/lib/schematic/internal/types/utils.rb +7 -0
  72. data/lib/schematic/licenses/client.rb +26 -3
  73. data/lib/schematic/planbundle/client.rb +27 -3
  74. data/lib/schematic/plangroups/client.rb +26 -3
  75. data/lib/schematic/planmigrations/client.rb +98 -11
  76. data/lib/schematic/plans/client.rb +213 -23
  77. data/lib/schematic/plans/types/get_plan_version_diff_params.rb +12 -0
  78. data/lib/schematic/plans/types/get_plan_version_diff_request.rb +13 -0
  79. data/lib/schematic/plans/types/get_plan_version_diff_response.rb +13 -0
  80. data/lib/schematic/plans/types/publish_plan_version_request_body.rb +2 -0
  81. data/lib/schematic/rules_engine.rb +14 -2
  82. data/lib/schematic/scheduledcheckout/client.rb +35 -4
  83. data/lib/schematic/schematic_client.rb +22 -11
  84. data/lib/schematic/types/billing_coupon_response_data.rb +2 -2
  85. data/lib/schematic/types/billing_credit_grant_response_data.rb +8 -8
  86. data/lib/schematic/types/billing_customer_subscription.rb +1 -1
  87. data/lib/schematic/types/billing_plan_credit_grant_response_data.rb +1 -1
  88. data/lib/schematic/types/billing_price_response_data.rb +1 -1
  89. data/lib/schematic/types/billing_price_view.rb +1 -1
  90. data/lib/schematic/types/billing_product_detail_response_data.rb +2 -2
  91. data/lib/schematic/types/billing_product_for_subscription_response_data.rb +2 -2
  92. data/lib/schematic/types/billing_product_price_response_data.rb +1 -1
  93. data/lib/schematic/types/billing_product_pricing.rb +1 -1
  94. data/lib/schematic/types/billing_product_response_data.rb +2 -2
  95. data/lib/schematic/types/billing_settings_response_data.rb +9 -0
  96. data/lib/schematic/types/billing_subscription_discount_view.rb +2 -2
  97. data/lib/schematic/types/billing_subscription_response_data.rb +1 -1
  98. data/lib/schematic/types/billing_subscription_view.rb +1 -1
  99. data/lib/schematic/types/catalog_config_ordered_plan.rb +2 -0
  100. data/lib/schematic/types/catalog_config_ordered_plan_response_data.rb +2 -0
  101. data/lib/schematic/types/catalog_config_plan_credit.rb +11 -0
  102. data/lib/schematic/types/catalog_config_plan_credit_response_data.rb +11 -0
  103. data/lib/schematic/types/change_subscription_internal_request_body.rb +1 -1
  104. data/lib/schematic/types/change_subscription_request_body.rb +1 -1
  105. data/lib/schematic/types/checkout_problem_code.rb +54 -0
  106. data/lib/schematic/types/checkout_problem_response_data.rb +31 -0
  107. data/lib/schematic/types/checkout_problem_source.rb +13 -0
  108. data/lib/schematic/types/checkout_subscription.rb +1 -1
  109. data/lib/schematic/types/company_billing_entity_subscription_response_data.rb +1 -1
  110. data/lib/schematic/types/company_credit_balance.rb +3 -3
  111. data/lib/schematic/types/company_credit_balance_response_data.rb +4 -4
  112. data/lib/schematic/types/company_detail_response_data.rb +1 -1
  113. data/lib/schematic/types/company_override_response_data.rb +3 -1
  114. data/lib/schematic/types/company_plan_credit_grant_view.rb +1 -1
  115. data/lib/schematic/types/company_plan_detail_response_data.rb +2 -0
  116. data/lib/schematic/types/company_subscription_response_data.rb +1 -1
  117. data/lib/schematic/types/company_user_usage_response_data.rb +2 -2
  118. data/lib/schematic/types/company_user_usage_row_response_data.rb +2 -2
  119. data/lib/schematic/types/component_response_data.rb +1 -1
  120. data/lib/schematic/types/condition.rb +3 -1
  121. data/lib/schematic/types/condition_response_data.rb +3 -1
  122. data/lib/schematic/types/condition_view.rb +3 -1
  123. data/lib/schematic/types/coupon_request_body.rb +2 -2
  124. data/lib/schematic/types/create_billing_plan_credit_grant_request_body.rb +1 -1
  125. data/lib/schematic/types/create_entitlement_in_bundle_request_body.rb +4 -2
  126. data/lib/schematic/types/create_entitlement_req_common.rb +3 -1
  127. data/lib/schematic/types/create_or_update_condition_request_body.rb +1 -1
  128. data/lib/schematic/types/credit_balance_event_response_data.rb +21 -0
  129. data/lib/schematic/types/credit_balance_feature_consumption_response_data.rb +13 -0
  130. data/lib/schematic/types/credit_balance_point_response_data.rb +15 -0
  131. data/lib/schematic/types/credit_balance_time_series_response_data.rb +15 -0
  132. data/lib/schematic/types/credit_bundle_currency_price.rb +1 -1
  133. data/lib/schematic/types/credit_bundle_currency_price_request_body.rb +1 -1
  134. data/lib/schematic/types/credit_bundle_currency_price_response_data.rb +1 -1
  135. data/lib/schematic/types/credit_burn_breakdown_line.rb +15 -0
  136. data/lib/schematic/types/credit_company_grant_view.rb +8 -8
  137. data/lib/schematic/types/credit_currency_price.rb +1 -1
  138. data/lib/schematic/types/credit_currency_price_request_body.rb +1 -1
  139. data/lib/schematic/types/credit_currency_price_response_data.rb +1 -1
  140. data/lib/schematic/types/credit_event_ledger_response_data.rb +10 -6
  141. data/lib/schematic/types/credit_grant_detail.rb +1 -1
  142. data/lib/schematic/types/credit_lease_response_data.rb +2 -2
  143. data/lib/schematic/types/credit_reservation_response_data.rb +2 -2
  144. data/lib/schematic/types/credit_spend_policy.rb +2 -2
  145. data/lib/schematic/types/credit_spend_policy_response_data.rb +4 -4
  146. data/lib/schematic/types/credit_transfer_response_data.rb +1 -1
  147. data/lib/schematic/types/credit_transfer_view.rb +1 -1
  148. data/lib/schematic/types/credit_usage.rb +5 -5
  149. data/lib/schematic/types/credit_usage_aggregation.rb +4 -4
  150. data/lib/schematic/types/credit_usage_reason.rb +1 -0
  151. data/lib/schematic/types/credits_in_plan.rb +11 -0
  152. data/lib/schematic/types/currency.rb +144 -0
  153. data/lib/schematic/types/currency_price_request_body.rb +1 -1
  154. data/lib/schematic/types/custom_plan_billing_response_data.rb +6 -0
  155. data/lib/schematic/types/entitlement_currency_prices_response_data.rb +1 -1
  156. data/lib/schematic/types/estimated_plan_total.rb +1 -1
  157. data/lib/schematic/types/feature_company_response_data.rb +7 -7
  158. data/lib/schematic/types/feature_detail_response_data.rb +2 -0
  159. data/lib/schematic/types/feature_entitlement.rb +8 -6
  160. data/lib/schematic/types/feature_event_source.rb +12 -0
  161. data/lib/schematic/types/feature_in_plan_response_data.rb +2 -0
  162. data/lib/schematic/types/feature_response_data.rb +2 -0
  163. data/lib/schematic/types/feature_usage_response_data.rb +7 -7
  164. data/lib/schematic/types/feature_view.rb +2 -0
  165. data/lib/schematic/types/flag_check_reservation_response_data.rb +3 -3
  166. data/lib/schematic/types/insights_summary_response_data.rb +1 -1
  167. data/lib/schematic/types/invoice_request_body.rb +1 -1
  168. data/lib/schematic/types/invoice_response_data.rb +1 -1
  169. data/lib/schematic/types/manage_plan_preview_response_response_data.rb +2 -0
  170. data/lib/schematic/types/manage_plan_request.rb +3 -1
  171. data/lib/schematic/types/manage_plan_response_response_data.rb +4 -0
  172. data/lib/schematic/types/mrr_response_data.rb +1 -1
  173. data/lib/schematic/types/onboarding_milestone_view.rb +1 -1
  174. data/lib/schematic/types/ordered_plans_in_group.rb +2 -0
  175. data/lib/schematic/types/plan_billing_source.rb +1 -0
  176. data/lib/schematic/types/plan_change_action.rb +1 -0
  177. data/lib/schematic/types/plan_change_amendment_status.rb +15 -0
  178. data/lib/schematic/types/plan_change_response_data.rb +4 -0
  179. data/lib/schematic/types/plan_credit_grant_view.rb +1 -1
  180. data/lib/schematic/types/plan_credit_order.rb +11 -0
  181. data/lib/schematic/types/plan_credit_visibility.rb +11 -0
  182. data/lib/schematic/types/plan_currency_price_request_body.rb +1 -1
  183. data/lib/schematic/types/plan_currency_prices_response_data.rb +1 -1
  184. data/lib/schematic/types/plan_entitlement_response_data.rb +3 -1
  185. data/lib/schematic/types/plan_group_plan_entitlements_order.rb +2 -0
  186. data/lib/schematic/types/plan_version_billing_product_change_response_data.rb +11 -0
  187. data/lib/schematic/types/plan_version_credit_grant_change_response_data.rb +17 -0
  188. data/lib/schematic/types/plan_version_diff_change_type.rb +13 -0
  189. data/lib/schematic/types/plan_version_diff_price_cadence.rb +14 -0
  190. data/lib/schematic/types/plan_version_diff_response_data.rb +23 -0
  191. data/lib/schematic/types/plan_version_entitlement_change_response_data.rb +17 -0
  192. data/lib/schematic/types/plan_version_field_change_response_data.rb +13 -0
  193. data/lib/schematic/types/plan_version_price_change_response_data.rb +15 -0
  194. data/lib/schematic/types/plan_view_public_response_data.rb +2 -0
  195. data/lib/schematic/types/preflight_request_body.rb +1 -1
  196. data/lib/schematic/types/preview_subscription_change_response_data.rb +3 -1
  197. data/lib/schematic/types/preview_subscription_discount_response_data.rb +2 -2
  198. data/lib/schematic/types/preview_subscription_finance_response_data.rb +2 -2
  199. data/lib/schematic/types/rulesengine_company.rb +1 -1
  200. data/lib/schematic/types/rulesengine_condition.rb +3 -1
  201. data/lib/schematic/types/rulesengine_credit_postpaid_config.rb +1 -1
  202. data/lib/schematic/types/rulesengine_credit_spend_policy.rb +2 -2
  203. data/lib/schematic/types/rulesengine_feature_entitlement.rb +8 -6
  204. data/lib/schematic/types/scheduled_downgrade_response_data.rb +1 -1
  205. data/lib/schematic/types/top_feature_by_usage_response_data.rb +1 -1
  206. data/lib/schematic/types/upcoming_invoice_response_data.rb +1 -1
  207. data/lib/schematic/types/update_billing_plan_credit_grant_request_body.rb +1 -1
  208. data/lib/schematic/types/update_entitlement_req_common.rb +3 -1
  209. data/lib/schematic/types/upsert_billing_product_request_body.rb +1 -1
  210. data/lib/schematic/types/usage_based_entitlement_request_body.rb +1 -1
  211. data/lib/schematic/types/usage_based_entitlement_response_data.rb +1 -1
  212. data/lib/schematic/types/user_credit_usage_response_data.rb +2 -2
  213. data/lib/schematic/types/user_daily_credit_point_response_data.rb +1 -1
  214. data/lib/schematic/types/user_feature_usage_response_data.rb +1 -1
  215. data/lib/schematic/version.rb +1 -1
  216. data/lib/schematic/wasm/rulesengine.wasm +0 -0
  217. data/lib/schematic/webhooks/client.rb +88 -10
  218. data/lib/schematic.rb +38 -3
  219. data/reference.md +340 -44
  220. metadata +37 -2
@@ -19,36 +19,74 @@ module Schematic
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
- @page_number = initial_page || (step ? 0 : 1)
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
- # A cache of whether the API has another page, if it gives us that information...
29
- @next_page = nil
30
- # ...or the actual next page, preloaded, if it doesn't.
31
- @has_next_page = nil
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
- @http_response = nil
42
+ @first_page = fetch_page(@initial_page)
43
+ rewind
44
+ self
34
45
  end
35
46
 
36
- # Iterates over each page returned by the API.
47
+ # Uses the first page that `other` loaded with `load_first_page`, unless this iterator already sent a request.
37
48
  #
38
- # @param block [Proc] The block which each retrieved page is yielded to.
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
92
  fetched_page_items = fetched_page&.send(@item_field)
@@ -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 = page.send(@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
@@ -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
- @body.nil? ? nil : ::JSON.generate(@body)
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
@@ -31,6 +31,7 @@ module Schematic
31
31
  end
32
32
 
33
33
  # @return [String, nil] The encoded HTTP request body.
34
+ # Note: additional_body_parameters from request_options are not applied to multipart requests.
34
35
  def encode_body
35
36
  @body&.encode
36
37
  end
@@ -108,6 +108,7 @@ module Schematic
108
108
  method_name = :"#{name}="
109
109
 
110
110
  define_method(method_name) do |val|
111
+ @explicit_fields[name] = true
111
112
  @data[name] = val
112
113
  end
113
114
  end
@@ -137,6 +138,7 @@ module Schematic
137
138
  # @return [self]
138
139
  def initialize(values = {})
139
140
  @data = {}
141
+ @explicit_fields = {}
140
142
 
141
143
  values = Utils.symbolize_keys(values.dup)
142
144
 
@@ -145,6 +147,7 @@ module Schematic
145
147
  [field.api_name.to_sym, field_name].uniq.each do |key|
146
148
  next unless values.key?(key)
147
149
 
150
+ @explicit_fields[field_name] = true
148
151
  candidate = values.delete(key)
149
152
  value = candidate if value.nil?
150
153
  end
@@ -173,14 +176,15 @@ module Schematic
173
176
  # If there is a value present in the data, use that value
174
177
  # If there is a `nil` value present in the data, and it is optional but NOT nullable, exclude key altogether
175
178
  # If there is a `nil` value present in the data, and it is optional and nullable, use the nil value
179
+ # only when it was explicitly provided; an omitted optional field is excluded
176
180
 
177
181
  value = @data[name]
178
182
 
179
- next if value.nil? && field.optional && !field.nullable
183
+ next if value.nil? && field.optional && (!field.nullable || !@explicit_fields&.key?(name))
180
184
 
181
185
  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)
186
+ value = value.map { |item| !item.nil? && item.respond_to?(:to_h) ? item.to_h : item }
187
+ elsif !value.nil? && value.respond_to?(:to_h)
184
188
  value = value.to_h
185
189
  end
186
190
 
@@ -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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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
- raise error_class.new(response.body, code: code)
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