schematichq 1.5.7 → 1.5.9

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 (153) hide show
  1. checksums.yaml +4 -4
  2. data/.fern/metadata.json +5 -5
  3. data/.fern/replay.lock +13 -1
  4. data/README.md +7 -1
  5. data/lib/schematic/accesstokens/client.rb +1 -1
  6. data/lib/schematic/accounts/client.rb +15 -15
  7. data/lib/schematic/billing/client.rb +706 -83
  8. data/lib/schematic/billing/types/charge_native_invoice_response.rb +15 -0
  9. data/lib/schematic/billing/types/convert_company_trial_response.rb +15 -0
  10. data/lib/schematic/billing/types/create_billing_subscription_request_body.rb +6 -0
  11. data/lib/schematic/billing/types/delete_contract_document_response.rb +15 -0
  12. data/lib/schematic/billing/types/end_company_trial_response.rb +15 -0
  13. data/lib/schematic/billing/types/get_company_contract_response.rb +15 -0
  14. data/lib/schematic/billing/types/get_company_trial_response.rb +15 -0
  15. data/lib/schematic/billing/types/get_company_upcoming_invoices_response.rb +15 -0
  16. data/lib/schematic/billing/types/move_to_default_plan_response.rb +15 -0
  17. data/lib/schematic/billing/types/reissue_native_invoice_link_response.rb +15 -0
  18. data/lib/schematic/billing/types/revoke_native_invoice_link_response.rb +15 -0
  19. data/lib/schematic/billing/types/start_company_trial_request_body.rb +21 -0
  20. data/lib/schematic/billing/types/start_company_trial_response.rb +15 -0
  21. data/lib/schematic/billing/types/update_billing_settings_request_body.rb +4 -0
  22. data/lib/schematic/billing/types/update_company_billing_profile_request_body.rb +6 -0
  23. data/lib/schematic/billing/types/update_company_trial_request_body.rb +15 -0
  24. data/lib/schematic/billing/types/update_company_trial_response.rb +15 -0
  25. data/lib/schematic/billing/types/upload_contract_document_request.rb +11 -0
  26. data/lib/schematic/billing/types/upload_contract_document_response.rb +15 -0
  27. data/lib/schematic/cache.rb +19 -2
  28. data/lib/schematic/catalogs/client.rb +16 -16
  29. data/lib/schematic/catalogs/types/update_catalog_configuration_request_body.rb +2 -0
  30. data/lib/schematic/checkout/client.rb +98 -9
  31. data/lib/schematic/checkout/types/checkout_data_request_body.rb +2 -0
  32. data/lib/schematic/checkout/types/pause_subscription_request.rb +15 -0
  33. data/lib/schematic/checkout/types/pause_subscription_response.rb +15 -0
  34. data/lib/schematic/checkout/types/resume_subscription_request.rb +13 -0
  35. data/lib/schematic/checkout/types/resume_subscription_response.rb +15 -0
  36. data/lib/schematic/client.rb +7 -196
  37. data/lib/schematic/companies/client.rb +140 -44
  38. data/lib/schematic/companies/types/get_billing_entity_settings_response.rb +15 -0
  39. data/lib/schematic/companies/types/list_users_params.rb +4 -0
  40. data/lib/schematic/companies/types/list_users_request.rb +4 -0
  41. data/lib/schematic/companies/types/update_billing_entity_settings_request_body.rb +13 -0
  42. data/lib/schematic/companies/types/update_billing_entity_settings_response.rb +15 -0
  43. data/lib/schematic/components/client.rb +8 -8
  44. data/lib/schematic/componentspublic/client.rb +1 -1
  45. data/lib/schematic/credits/client.rb +41 -41
  46. data/lib/schematic/customplangrouprollouts/client.rb +258 -0
  47. data/lib/schematic/customplangrouprollouts/types/copy_custom_plan_request_body.rb +15 -0
  48. data/lib/schematic/customplangrouprollouts/types/copy_custom_plan_response.rb +15 -0
  49. data/lib/schematic/customplangrouprollouts/types/get_group_rollout_response.rb +15 -0
  50. data/lib/schematic/customplangrouprollouts/types/list_group_rollouts_params.rb +14 -0
  51. data/lib/schematic/customplangrouprollouts/types/list_group_rollouts_request.rb +11 -0
  52. data/lib/schematic/customplangrouprollouts/types/list_group_rollouts_response.rb +15 -0
  53. data/lib/schematic/customplangrouprollouts/types/preview_group_rollout_params.rb +16 -0
  54. data/lib/schematic/customplangrouprollouts/types/preview_group_rollout_request.rb +15 -0
  55. data/lib/schematic/customplangrouprollouts/types/preview_group_rollout_response.rb +15 -0
  56. data/lib/schematic/customplangrouprollouts/types/start_group_rollout_request_body.rb +17 -0
  57. data/lib/schematic/customplangrouprollouts/types/start_group_rollout_response.rb +15 -0
  58. data/lib/schematic/dataexports/client.rb +4 -4
  59. data/lib/schematic/datastream/client.rb +52 -22
  60. data/lib/schematic/datastream/resource_cache.rb +13 -3
  61. data/lib/schematic/entitlements/client.rb +28 -28
  62. data/lib/schematic/entitlements/types/create_billing_linked_plan_entitlement_request_body.rb +2 -0
  63. data/lib/schematic/entitlements/types/create_company_override_request_body.rb +2 -0
  64. data/lib/schematic/entitlements/types/create_plan_entitlement_request_body.rb +2 -0
  65. data/lib/schematic/entitlements/types/update_company_override_request_body.rb +2 -0
  66. data/lib/schematic/entitlements/types/update_plan_entitlement_request_body.rb +2 -0
  67. data/lib/schematic/errors/response_error.rb +4 -2
  68. data/lib/schematic/events/client.rb +213 -9
  69. data/lib/schematic/events/types/create_account_inference_cost_rate_request_body.rb +19 -0
  70. data/lib/schematic/events/types/create_account_inference_cost_rate_response.rb +15 -0
  71. data/lib/schematic/events/types/delete_account_inference_cost_rate_response.rb +15 -0
  72. data/lib/schematic/events/types/list_account_inference_cost_rates_params.rb +20 -0
  73. data/lib/schematic/events/types/list_account_inference_cost_rates_request.rb +17 -0
  74. data/lib/schematic/events/types/list_account_inference_cost_rates_response.rb +15 -0
  75. data/lib/schematic/events/types/update_account_inference_cost_rate_request_body.rb +13 -0
  76. data/lib/schematic/events/types/update_account_inference_cost_rate_response.rb +15 -0
  77. data/lib/schematic/features/client.rb +18 -18
  78. data/lib/schematic/insights/client.rb +6 -6
  79. data/lib/schematic/integrationsapi/client.rb +14 -14
  80. data/lib/schematic/internal/http/raw_client.rb +2 -2
  81. data/lib/schematic/internal/iterators/offset_page_iterator.rb +2 -0
  82. data/lib/schematic/licenses/client.rb +3 -3
  83. data/lib/schematic/planbundle/client.rb +3 -3
  84. data/lib/schematic/plangroups/client.rb +3 -3
  85. data/lib/schematic/planmigrations/client.rb +11 -11
  86. data/lib/schematic/plans/client.rb +20 -20
  87. data/lib/schematic/redis_cache.rb +10 -1
  88. data/lib/schematic/scheduledcheckout/client.rb +4 -4
  89. data/lib/schematic/schematic_client.rb +21 -3
  90. data/lib/schematic/types/account_inference_cost_rate_response_data.rb +29 -0
  91. data/lib/schematic/types/billing_customer_subscription.rb +2 -0
  92. data/lib/schematic/types/billing_invoice_billing_details_response_data.rb +2 -0
  93. data/lib/schematic/types/billing_invoice_detail_response_data.rb +2 -0
  94. data/lib/schematic/types/billing_moved_to_default_plan_response_data.rb +15 -0
  95. data/lib/schematic/types/billing_native_subscription_response_data.rb +4 -0
  96. data/lib/schematic/types/billing_product_for_subscription_response_data.rb +2 -0
  97. data/lib/schematic/types/billing_product_plan_response_data.rb +2 -0
  98. data/lib/schematic/types/billing_settings_response_data.rb +4 -0
  99. data/lib/schematic/types/billing_subscription_pause_behavior.rb +15 -0
  100. data/lib/schematic/types/billing_subscription_response_data.rb +6 -0
  101. data/lib/schematic/types/billing_subscription_view.rb +6 -0
  102. data/lib/schematic/types/billing_upcoming_invoice_response_data.rb +43 -0
  103. data/lib/schematic/types/billing_upcoming_invoices_response_data.rb +13 -0
  104. data/lib/schematic/types/catalog_configuration_response_data.rb +2 -0
  105. data/lib/schematic/types/catalog_plan_response_data.rb +4 -0
  106. data/lib/schematic/types/catalog_response_data.rb +2 -0
  107. data/lib/schematic/types/checkout_subscription.rb +6 -0
  108. data/lib/schematic/types/company_billing_entity_settings_response_data.rb +15 -0
  109. data/lib/schematic/types/company_billing_entity_subscription_response_data.rb +10 -0
  110. data/lib/schematic/types/company_billing_profile_contract_response_data.rb +55 -0
  111. data/lib/schematic/types/company_billing_profile_document_response_data.rb +15 -0
  112. data/lib/schematic/types/company_override_response_data.rb +2 -0
  113. data/lib/schematic/types/company_subscription_response_data.rb +10 -0
  114. data/lib/schematic/types/company_trial_response_data.rb +35 -0
  115. data/lib/schematic/types/company_trial_status.rb +16 -0
  116. data/lib/schematic/types/contract_billing_details_request_body.rb +19 -0
  117. data/lib/schematic/types/contract_postpaid_credit_response_data.rb +23 -0
  118. data/lib/schematic/types/contract_postpaid_response_data.rb +15 -0
  119. data/lib/schematic/types/create_entitlement_in_bundle_request_body.rb +2 -0
  120. data/lib/schematic/types/create_entitlement_req_common.rb +2 -0
  121. data/lib/schematic/types/credit_burn_breakdown_line.rb +4 -0
  122. data/lib/schematic/types/credit_ledger_export_metadata.rb +25 -0
  123. data/lib/schematic/types/credit_ledger_export_metadata_event_type.rb +19 -0
  124. data/lib/schematic/types/credit_model_rate.rb +17 -0
  125. data/lib/schematic/types/custom_plan_billing_response_data.rb +2 -0
  126. data/lib/schematic/types/data_export_metadata.rb +2 -0
  127. data/lib/schematic/types/data_export_type.rb +1 -0
  128. data/lib/schematic/types/group_rollout_change_response_data.rb +13 -0
  129. data/lib/schematic/types/group_rollout_changes_response_data.rb +23 -0
  130. data/lib/schematic/types/group_rollout_company_response_data.rb +15 -0
  131. data/lib/schematic/types/group_rollout_company_result_response_data.rb +19 -0
  132. data/lib/schematic/types/group_rollout_preview_response_data.rb +19 -0
  133. data/lib/schematic/types/group_rollout_response_data.rb +25 -0
  134. data/lib/schematic/types/group_rollout_versions_request_body.rb +13 -0
  135. data/lib/schematic/types/manage_plan_request.rb +4 -0
  136. data/lib/schematic/types/manage_plan_response_response_data.rb +2 -0
  137. data/lib/schematic/types/migration_error_code.rb +1 -0
  138. data/lib/schematic/types/plan_change_action.rb +2 -0
  139. data/lib/schematic/types/plan_change_response_data.rb +4 -0
  140. data/lib/schematic/types/plan_entitlement_response_data.rb +2 -0
  141. data/lib/schematic/types/publish_plan_version_request_body.rb +8 -0
  142. data/lib/schematic/types/publish_preview_interval_change_response_data.rb +13 -0
  143. data/lib/schematic/types/publish_preview_response_data.rb +6 -0
  144. data/lib/schematic/types/scheduled_downgrade_response_data.rb +4 -0
  145. data/lib/schematic/types/stripe_integration_config.rb +2 -0
  146. data/lib/schematic/types/trial_source.rb +15 -0
  147. data/lib/schematic/types/update_entitlement_req_common.rb +2 -0
  148. data/lib/schematic/types/web_scheduled_downgrade_webhook_output.rb +2 -0
  149. data/lib/schematic/version.rb +1 -1
  150. data/lib/schematic/webhooks/client.rb +10 -10
  151. data/lib/schematic.rb +79 -5
  152. data/reference.md +5208 -3800
  153. metadata +70 -2
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Schematic
4
+ module Customplangrouprollouts
5
+ module Types
6
+ class ListGroupRolloutsRequest < Internal::Types::Model
7
+ field :plan_id, -> { String }, optional: false, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../../schematic"
4
+
5
+ module Schematic
6
+ module Customplangrouprollouts
7
+ module Types
8
+ class ListGroupRolloutsResponse < Internal::Types::Model
9
+ field :data, -> { Internal::Types::Array[Schematic::Types::GroupRolloutResponseData] }, optional: false, nullable: false
10
+
11
+ field :params, -> { Schematic::Customplangrouprollouts::Types::ListGroupRolloutsParams }, optional: false, nullable: false
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../../schematic"
4
+
5
+ module Schematic
6
+ module Customplangrouprollouts
7
+ module Types
8
+ # Input parameters
9
+ class PreviewGroupRolloutParams < Internal::Types::Model
10
+ field :from_plan_version_id, -> { String }, optional: true, nullable: false
11
+
12
+ field :to_plan_version_id, -> { String }, optional: true, nullable: false
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Schematic
4
+ module Customplangrouprollouts
5
+ module Types
6
+ class PreviewGroupRolloutRequest < Internal::Types::Model
7
+ field :plan_id, -> { String }, optional: false, nullable: false
8
+
9
+ field :from_plan_version_id, -> { String }, optional: true, nullable: false
10
+
11
+ field :to_plan_version_id, -> { String }, optional: true, nullable: false
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../../schematic"
4
+
5
+ module Schematic
6
+ module Customplangrouprollouts
7
+ module Types
8
+ class PreviewGroupRolloutResponse < Internal::Types::Model
9
+ field :data, -> { Schematic::Types::GroupRolloutPreviewResponseData }, optional: false, nullable: false
10
+
11
+ field :params, -> { Schematic::Customplangrouprollouts::Types::PreviewGroupRolloutParams }, optional: false, nullable: false
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Schematic
4
+ module Customplangrouprollouts
5
+ module Types
6
+ class StartGroupRolloutRequestBody < Internal::Types::Model
7
+ field :plan_id, -> { String }, optional: false, nullable: false
8
+
9
+ field :excluded_company_ids, -> { Internal::Types::Array[String] }, optional: false, nullable: false
10
+
11
+ field :from_plan_version_id, -> { String }, optional: true, nullable: false
12
+
13
+ field :to_plan_version_id, -> { String }, optional: true, nullable: false
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../../schematic"
4
+
5
+ module Schematic
6
+ module Customplangrouprollouts
7
+ module Types
8
+ class StartGroupRolloutResponse < Internal::Types::Model
9
+ field :data, -> { Schematic::Types::GroupRolloutResponseData }, optional: false, nullable: false
10
+
11
+ field :params, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false
12
+ end
13
+ end
14
+ end
15
+ end
@@ -64,7 +64,7 @@ module Schematic
64
64
  500 => Schematic::Types::ApiError
65
65
  }
66
66
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
67
- raise error_class.new(response.body, code: code, body: error_body)
67
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
68
68
  end
69
69
  end
70
70
 
@@ -110,7 +110,7 @@ module Schematic
110
110
  500 => Schematic::Types::ApiError
111
111
  }
112
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)
113
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
114
114
  end
115
115
  end
116
116
 
@@ -152,7 +152,7 @@ module Schematic
152
152
  500 => Schematic::Types::ApiError
153
153
  }
154
154
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
155
- raise error_class.new(response.body, code: code, body: error_body)
155
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
156
156
  end
157
157
  end
158
158
 
@@ -193,7 +193,7 @@ module Schematic
193
193
  500 => Schematic::Types::ApiError
194
194
  }
195
195
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
196
- raise error_class.new(response.body, code: code, body: error_body)
196
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
197
197
  end
198
198
  end
199
199
  end
@@ -129,10 +129,26 @@ module Schematic
129
129
  end
130
130
  end
131
131
 
132
+ # Whether the DataStream is connected. In websocket mode this is the
133
+ # WebSocket connection state. In replicator mode it reports replicator
134
+ # readiness (the same value as cache_ready?), kept for backward
135
+ # compatibility; use cache_ready? to decide whether the replicator cache
136
+ # can be served.
132
137
  def connected?
133
138
  @replicator_mode ? @replicator_ready : (@ws_client&.connected || false)
134
139
  end
135
140
 
141
+ # Whether the cache is ready to serve flag checks. In replicator mode this
142
+ # is the `ready` field from the replicator's health endpoint, which is true
143
+ # only once the replicator has fully loaded the cache for its current
144
+ # cache_version. It is false until the first answer from the health
145
+ # endpoint, and a failed poll leaves it as the last answer set it.
146
+ # Outside replicator mode it is always true: the SDK
147
+ # fills its own cache over the WebSocket, so there is nothing to wait for.
148
+ def cache_ready?
149
+ @replicator_mode ? @replicator_ready : true
150
+ end
151
+
136
152
  def close
137
153
  @logger.info("Closing DataStream client")
138
154
  @mutex.synchronize { @stopped = true }
@@ -208,7 +224,10 @@ module Schematic
208
224
  end
209
225
 
210
226
  company[:metrics] = metrics
211
- @company_cache.cache_entity(company, ttl: @cache_ttl)
227
+ # The replicator owns these keys and usually writes them with no
228
+ # expiry; applying our TTL here would make them vanish if the
229
+ # replicator doesn't rewrite the company in time.
230
+ @company_cache.cache_entity(company, ttl: @cache_ttl, keep_ttl: @replicator_mode)
212
231
  end
213
232
 
214
233
  private
@@ -499,6 +518,15 @@ module Schematic
499
518
  @health_thread.abort_on_exception = false
500
519
  end
501
520
 
521
+ # Polls the replicator health endpoint. The body is read whatever the
522
+ # HTTP status: a replicator that is still loading its cache answers 503
523
+ # with {"ready": false, "cache_version": "..."}. Only an explicit answer
524
+ # changes state: a body with a boolean `ready` sets readiness from it and
525
+ # records any non-empty cache_version. A failed poll (connection error,
526
+ # timeout, or a body with no boolean `ready`) changes nothing, because
527
+ # it says nothing about whether the cache is complete, and flipping every
528
+ # check to the API on one blip would send the whole fleet to the API at
529
+ # once. Before the first answer the replicator counts as not ready.
502
530
  def check_replicator_health
503
531
  uri = URI.parse(@replicator_health_url)
504
532
  http = Net::HTTP.new(uri.host, uri.port)
@@ -507,29 +535,17 @@ module Schematic
507
535
  http.read_timeout = 5
508
536
  response = http.get(uri.request_uri)
509
537
 
510
- if response.is_a?(Net::HTTPSuccess)
511
- body = begin
512
- JSON.parse(response.body, symbolize_names: true)
513
- rescue StandardError
514
- {}
515
- end
516
- was_ready = @replicator_ready
517
- @replicator_ready = body[:ready] == true
518
-
519
- update_cache_version(body[:cache_version].to_s)
520
-
521
- @logger.info("Replicator is ready") if @replicator_ready && !was_ready
522
- @logger.info("Replicator is no longer ready") if !@replicator_ready && was_ready
523
- else
524
- was_ready = @replicator_ready
525
- @replicator_ready = false
526
- @logger.info("Replicator is no longer ready") if was_ready
527
- @logger.warn("Replicator health check failed: #{response.code}")
538
+ body = parse_health_body(response.body)
539
+ unless body
540
+ @logger.warn("Replicator health check returned no readiness answer (HTTP #{response.code})")
541
+ return
528
542
  end
543
+
544
+ cache_version = body[:cache_version].to_s
545
+ update_cache_version(cache_version) unless cache_version.empty?
546
+ update_replicator_ready(body[:ready])
547
+ @logger.debug("Replicator not ready (HTTP #{response.code})") unless @replicator_ready
529
548
  rescue StandardError => e
530
- was_ready = @replicator_ready
531
- @replicator_ready = false
532
- @logger.info("Replicator is no longer ready") if was_ready
533
549
  @logger.warn("Replicator health check error: #{e.message}")
534
550
  end
535
551
 
@@ -543,6 +559,20 @@ module Schematic
543
559
  # definitions. The credit-lease check path resolves the flag, the company,
544
560
  # and the user itself before evaluating, so it needs all three.
545
561
  public :get_flag, :get_company, :get_user, :get_cached_company
562
+
563
+ def parse_health_body(raw)
564
+ body = JSON.parse(raw.to_s, symbolize_names: true)
565
+ body.is_a?(Hash) && [true, false].include?(body[:ready]) ? body : nil
566
+ rescue JSON::ParserError
567
+ nil
568
+ end
569
+
570
+ def update_replicator_ready(ready)
571
+ was_ready = @replicator_ready
572
+ @replicator_ready = ready
573
+ @logger.info("Replicator is ready (cache_version: #{@cache_version})") if ready && !was_ready
574
+ @logger.info("Replicator is no longer ready") if !ready && was_ready
575
+ end
546
576
  end
547
577
  end
548
578
  end
@@ -14,17 +14,19 @@ module Schematic
14
14
 
15
15
  attr_writer :cache_version
16
16
 
17
- def cache_entity(entity, ttl: nil)
17
+ # With keep_ttl, each key keeps its current expiry instead of taking
18
+ # `ttl`, on providers that support it.
19
+ def cache_entity(entity, ttl: nil, keep_ttl: false)
18
20
  id = @get_id.call(entity)
19
21
  return unless id
20
22
 
21
23
  id_key = build_id_key(id)
22
- @primary_cache.set(id_key, entity, ttl: ttl)
24
+ write(@primary_cache, id_key, entity, ttl, keep_ttl)
23
25
 
24
26
  keys = @get_keys.call(entity)
25
27
  keys&.each do |k, v|
26
28
  lookup_key = build_lookup_key(k, v)
27
- @lookup_cache.set(lookup_key, id, ttl: ttl)
29
+ write(@lookup_cache, lookup_key, id, ttl, keep_ttl)
28
30
  end
29
31
  end
30
32
 
@@ -62,6 +64,14 @@ module Schematic
62
64
 
63
65
  private
64
66
 
67
+ def write(cache, key, value, ttl, keep_ttl)
68
+ if keep_ttl && cache.respond_to?(:set_keep_ttl)
69
+ cache.set_keep_ttl(key, value)
70
+ else
71
+ cache.set(key, value, ttl: ttl)
72
+ end
73
+ end
74
+
65
75
  def build_id_key(id)
66
76
  "#{@key_prefix}:#{@cache_version}:#{id}"
67
77
  end
@@ -79,7 +79,7 @@ module Schematic
79
79
  500 => Schematic::Types::ApiError
80
80
  }
81
81
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
82
- raise error_class.new(response.body, code: code, body: error_body)
82
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
83
83
  end
84
84
  end
85
85
 
@@ -126,7 +126,7 @@ module Schematic
126
126
  500 => Schematic::Types::ApiError
127
127
  }
128
128
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
129
- raise error_class.new(response.body, code: code, body: error_body)
129
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
130
130
  end
131
131
  end
132
132
 
@@ -168,7 +168,7 @@ module Schematic
168
168
  500 => Schematic::Types::ApiError
169
169
  }
170
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)
171
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
172
172
  end
173
173
  end
174
174
 
@@ -219,7 +219,7 @@ module Schematic
219
219
  500 => Schematic::Types::ApiError
220
220
  }
221
221
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
222
- raise error_class.new(response.body, code: code, body: error_body)
222
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
223
223
  end
224
224
  end
225
225
 
@@ -262,7 +262,7 @@ module Schematic
262
262
  500 => Schematic::Types::ApiError
263
263
  }
264
264
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
265
- raise error_class.new(response.body, code: code, body: error_body)
265
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
266
266
  end
267
267
  end
268
268
 
@@ -335,7 +335,7 @@ module Schematic
335
335
  500 => Schematic::Types::ApiError
336
336
  }
337
337
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
338
- raise error_class.new(response.body, code: code, body: error_body)
338
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
339
339
  end
340
340
  end
341
341
 
@@ -393,7 +393,7 @@ module Schematic
393
393
  500 => Schematic::Types::ApiError
394
394
  }
395
395
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
396
- raise error_class.new(response.body, code: code, body: error_body)
396
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
397
397
  end
398
398
  end
399
399
 
@@ -451,7 +451,7 @@ module Schematic
451
451
  500 => Schematic::Types::ApiError
452
452
  }
453
453
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
454
- raise error_class.new(response.body, code: code, body: error_body)
454
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
455
455
  end
456
456
  end
457
457
 
@@ -523,7 +523,7 @@ module Schematic
523
523
  500 => Schematic::Types::ApiError
524
524
  }
525
525
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
526
- raise error_class.new(response.body, code: code, body: error_body)
526
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
527
527
  end
528
528
  end
529
529
 
@@ -590,7 +590,7 @@ module Schematic
590
590
  500 => Schematic::Types::ApiError
591
591
  }
592
592
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
593
- raise error_class.new(response.body, code: code, body: error_body)
593
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
594
594
  end
595
595
  end
596
596
 
@@ -650,7 +650,7 @@ module Schematic
650
650
  500 => Schematic::Types::ApiError
651
651
  }
652
652
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
653
- raise error_class.new(response.body, code: code, body: error_body)
653
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
654
654
  end
655
655
  end
656
656
 
@@ -722,7 +722,7 @@ module Schematic
722
722
  500 => Schematic::Types::ApiError
723
723
  }
724
724
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
725
- raise error_class.new(response.body, code: code, body: error_body)
725
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
726
726
  end
727
727
  end
728
728
 
@@ -780,7 +780,7 @@ module Schematic
780
780
  500 => Schematic::Types::ApiError
781
781
  }
782
782
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
783
- raise error_class.new(response.body, code: code, body: error_body)
783
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
784
784
  end
785
785
  end
786
786
 
@@ -838,7 +838,7 @@ module Schematic
838
838
  500 => Schematic::Types::ApiError
839
839
  }
840
840
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
841
- raise error_class.new(response.body, code: code, body: error_body)
841
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
842
842
  end
843
843
  end
844
844
 
@@ -917,7 +917,7 @@ module Schematic
917
917
  500 => Schematic::Types::ApiError
918
918
  }
919
919
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
920
- raise error_class.new(response.body, code: code, body: error_body)
920
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
921
921
  end
922
922
  end
923
923
 
@@ -964,7 +964,7 @@ module Schematic
964
964
  500 => Schematic::Types::ApiError
965
965
  }
966
966
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
967
- raise error_class.new(response.body, code: code, body: error_body)
967
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
968
968
  end
969
969
  end
970
970
 
@@ -1006,7 +1006,7 @@ module Schematic
1006
1006
  500 => Schematic::Types::ApiError
1007
1007
  }
1008
1008
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
1009
- raise error_class.new(response.body, code: code, body: error_body)
1009
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
1010
1010
  end
1011
1011
  end
1012
1012
 
@@ -1057,7 +1057,7 @@ module Schematic
1057
1057
  500 => Schematic::Types::ApiError
1058
1058
  }
1059
1059
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
1060
- raise error_class.new(response.body, code: code, body: error_body)
1060
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
1061
1061
  end
1062
1062
  end
1063
1063
 
@@ -1100,7 +1100,7 @@ module Schematic
1100
1100
  500 => Schematic::Types::ApiError
1101
1101
  }
1102
1102
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
1103
- raise error_class.new(response.body, code: code, body: error_body)
1103
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
1104
1104
  end
1105
1105
  end
1106
1106
 
@@ -1149,7 +1149,7 @@ module Schematic
1149
1149
  500 => Schematic::Types::ApiError
1150
1150
  }
1151
1151
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
1152
- raise error_class.new(response.body, code: code, body: error_body)
1152
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
1153
1153
  end
1154
1154
  end
1155
1155
 
@@ -1228,7 +1228,7 @@ module Schematic
1228
1228
  500 => Schematic::Types::ApiError
1229
1229
  }
1230
1230
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
1231
- raise error_class.new(response.body, code: code, body: error_body)
1231
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
1232
1232
  end
1233
1233
  end
1234
1234
 
@@ -1274,7 +1274,7 @@ module Schematic
1274
1274
  500 => Schematic::Types::ApiError
1275
1275
  }
1276
1276
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
1277
- raise error_class.new(response.body, code: code, body: error_body)
1277
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
1278
1278
  end
1279
1279
  end
1280
1280
 
@@ -1322,7 +1322,7 @@ module Schematic
1322
1322
  500 => Schematic::Types::ApiError
1323
1323
  }
1324
1324
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
1325
- raise error_class.new(response.body, code: code, body: error_body)
1325
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
1326
1326
  end
1327
1327
  end
1328
1328
 
@@ -1379,7 +1379,7 @@ module Schematic
1379
1379
  500 => Schematic::Types::ApiError
1380
1380
  }
1381
1381
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
1382
- raise error_class.new(response.body, code: code, body: error_body)
1382
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
1383
1383
  end
1384
1384
  end
1385
1385
 
@@ -1433,7 +1433,7 @@ module Schematic
1433
1433
  500 => Schematic::Types::ApiError
1434
1434
  }
1435
1435
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
1436
- raise error_class.new(response.body, code: code, body: error_body)
1436
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
1437
1437
  end
1438
1438
  end
1439
1439
 
@@ -1499,7 +1499,7 @@ module Schematic
1499
1499
  500 => Schematic::Types::ApiError
1500
1500
  }
1501
1501
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
1502
- raise error_class.new(response.body, code: code, body: error_body)
1502
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
1503
1503
  end
1504
1504
  end
1505
1505
 
@@ -1566,7 +1566,7 @@ module Schematic
1566
1566
  500 => Schematic::Types::ApiError
1567
1567
  }
1568
1568
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
1569
- raise error_class.new(response.body, code: code, body: error_body)
1569
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
1570
1570
  end
1571
1571
  end
1572
1572
 
@@ -1623,7 +1623,7 @@ module Schematic
1623
1623
  500 => Schematic::Types::ApiError
1624
1624
  }
1625
1625
  error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
1626
- raise error_class.new(response.body, code: code, body: error_body)
1626
+ raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
1627
1627
  end
1628
1628
  end
1629
1629
  end
@@ -24,6 +24,8 @@ module Schematic
24
24
 
25
25
  field :metric_period_month_reset, -> { Schematic::Types::MetricPeriodMonthReset }, optional: true, nullable: false
26
26
 
27
+ field :model_rates, -> { Internal::Types::Array[Schematic::Types::CreditModelRate] }, optional: true, nullable: false
28
+
27
29
  field :monthly_metered_price_id, -> { String }, optional: true, nullable: false
28
30
 
29
31
  field :monthly_price_tiers, -> { Internal::Types::Array[Schematic::Types::CreatePriceTierRequestBody] }, optional: true, nullable: false
@@ -16,6 +16,8 @@ module Schematic
16
16
 
17
17
  field :metric_period_month_reset, -> { Schematic::Types::MetricPeriodMonthReset }, optional: true, nullable: false
18
18
 
19
+ field :model_rates, -> { Internal::Types::Array[Schematic::Types::CreditModelRate] }, optional: true, nullable: false
20
+
19
21
  field :note, -> { String }, optional: true, nullable: false
20
22
 
21
23
  field :quantity_rates, -> { Internal::Types::Hash[String, Float] }, optional: true, nullable: false
@@ -20,6 +20,8 @@ module Schematic
20
20
 
21
21
  field :metric_period_month_reset, -> { Schematic::Types::MetricPeriodMonthReset }, optional: true, nullable: false
22
22
 
23
+ field :model_rates, -> { Internal::Types::Array[Schematic::Types::CreditModelRate] }, optional: true, nullable: false
24
+
23
25
  field :monthly_metered_price_id, -> { String }, optional: true, nullable: false
24
26
 
25
27
  field :monthly_price_tiers, -> { Internal::Types::Array[Schematic::Types::CreatePriceTierRequestBody] }, optional: true, nullable: false
@@ -14,6 +14,8 @@ module Schematic
14
14
 
15
15
  field :metric_period_month_reset, -> { Schematic::Types::MetricPeriodMonthReset }, optional: true, nullable: false
16
16
 
17
+ field :model_rates, -> { Internal::Types::Array[Schematic::Types::CreditModelRate] }, optional: true, nullable: false
18
+
17
19
  field :note, -> { String }, optional: true, nullable: false
18
20
 
19
21
  field :quantity_rates, -> { Internal::Types::Hash[String, Float] }, optional: true, nullable: false
@@ -20,6 +20,8 @@ module Schematic
20
20
 
21
21
  field :metric_period_month_reset, -> { Schematic::Types::MetricPeriodMonthReset }, optional: true, nullable: false
22
22
 
23
+ field :model_rates, -> { Internal::Types::Array[Schematic::Types::CreditModelRate] }, optional: true, nullable: false
24
+
23
25
  field :monthly_metered_price_id, -> { String }, optional: true, nullable: false
24
26
 
25
27
  field :monthly_price_tiers, -> { Internal::Types::Array[Schematic::Types::CreatePriceTierRequestBody] }, optional: true, nullable: false
@@ -3,14 +3,16 @@
3
3
  module Schematic
4
4
  module Errors
5
5
  class ResponseError < ApiError
6
- attr_reader :code, :body
6
+ attr_reader :code, :body, :headers
7
7
 
8
8
  # @param msg [String] The raw response body.
9
9
  # @param code [Integer] The HTTP status code.
10
10
  # @param body [Object, nil] The response body parsed into the endpoint's declared error type, if any.
11
- def initialize(msg, code:, body: nil)
11
+ # @param headers [Hash{String => Array<String>}] The response headers, with lowercase names.
12
+ def initialize(msg, code:, body: nil, headers: {})
12
13
  @code = code
13
14
  @body = body
15
+ @headers = headers
14
16
  super(msg)
15
17
  end
16
18