schematichq 1.4.16 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/.fern/metadata.json +4 -4
  3. data/.fern/replay.lock +21 -3
  4. data/.fernignore +1 -0
  5. data/CONTRIBUTING.md +2 -2
  6. data/README.md +23 -0
  7. data/WASM_VERSION +1 -1
  8. data/lib/schematic/accesstokens/client.rb +1 -1
  9. data/lib/schematic/accounts/client.rb +21 -21
  10. data/lib/schematic/accounts/types/update_onboarding_state_request_body.rb +2 -0
  11. data/lib/schematic/billing/client.rb +120 -24
  12. data/lib/schematic/billing/types/create_billing_subscription_request_body.rb +2 -0
  13. data/lib/schematic/billing/types/list_company_billing_profiles_params.rb +20 -0
  14. data/lib/schematic/billing/types/list_company_billing_profiles_request.rb +19 -0
  15. data/lib/schematic/billing/types/list_company_billing_profiles_response.rb +13 -0
  16. data/lib/schematic/billing/types/update_company_billing_profile_request_body.rb +23 -0
  17. data/lib/schematic/billing/types/update_company_billing_profile_response.rb +13 -0
  18. data/lib/schematic/catalogs/client.rb +10 -10
  19. data/lib/schematic/checkout/client.rb +9 -9
  20. data/lib/schematic/client.rb +1 -1
  21. data/lib/schematic/companies/client.rb +43 -43
  22. data/lib/schematic/components/client.rb +8 -8
  23. data/lib/schematic/componentspublic/client.rb +1 -1
  24. data/lib/schematic/credits/client.rb +372 -41
  25. data/lib/schematic/credits/types/count_credit_spend_policies_params.rb +24 -0
  26. data/lib/schematic/credits/types/count_credit_spend_policies_request.rb +23 -0
  27. data/lib/schematic/credits/types/count_credit_spend_policies_response.rb +13 -0
  28. data/lib/schematic/credits/types/create_company_credit_grant.rb +2 -0
  29. data/lib/schematic/credits/types/create_credit_spend_policy_request_body.rb +19 -0
  30. data/lib/schematic/credits/types/create_credit_spend_policy_response.rb +13 -0
  31. data/lib/schematic/credits/types/delete_credit_spend_policy_response.rb +13 -0
  32. data/lib/schematic/credits/types/get_credit_spend_policy_response.rb +13 -0
  33. data/lib/schematic/credits/types/list_credit_spend_policies_params.rb +24 -0
  34. data/lib/schematic/credits/types/list_credit_spend_policies_request.rb +23 -0
  35. data/lib/schematic/credits/types/list_credit_spend_policies_response.rb +13 -0
  36. data/lib/schematic/credits/types/release_credit_reservation_response.rb +13 -0
  37. data/lib/schematic/credits/types/reserve_credits_request_body.rb +19 -0
  38. data/lib/schematic/credits/types/reserve_credits_response.rb +13 -0
  39. data/lib/schematic/credits/types/update_credit_spend_policy_request_body.rb +15 -0
  40. data/lib/schematic/credits/types/update_credit_spend_policy_response.rb +13 -0
  41. data/lib/schematic/dataexports/client.rb +3 -3
  42. data/lib/schematic/datastream/client.rb +5 -2
  43. data/lib/schematic/datastream/resource_cache.rb +2 -4
  44. data/lib/schematic/datastream/websocket_client.rb +59 -1
  45. data/lib/schematic/entitlements/client.rb +25 -25
  46. data/lib/schematic/events/client.rb +107 -6
  47. data/lib/schematic/events/types/delete_otlp_environment_settings_response.rb +13 -0
  48. data/lib/schematic/events/types/get_otlp_environment_settings_response.rb +13 -0
  49. data/lib/schematic/events/types/upsert_otlp_environment_settings_request_body.rb +19 -0
  50. data/lib/schematic/events/types/upsert_otlp_environment_settings_response.rb +13 -0
  51. data/lib/schematic/features/client.rb +57 -17
  52. data/lib/schematic/features/types/check_and_reserve_flag_request_body.rb +21 -0
  53. data/lib/schematic/features/types/check_and_reserve_flag_response.rb +13 -0
  54. data/lib/schematic/insights/client.rb +6 -6
  55. data/lib/schematic/integrationsapi/client.rb +178 -9
  56. data/lib/schematic/integrationsapi/types/claim_stripe_sandbox_keys_request_body.rb +11 -0
  57. data/lib/schematic/integrationsapi/types/claim_stripe_sandbox_keys_response.rb +13 -0
  58. data/lib/schematic/integrationsapi/types/get_stripe_sandbox_claim_link_response.rb +13 -0
  59. data/lib/schematic/integrationsapi/types/get_stripe_sandbox_keys_response.rb +13 -0
  60. data/lib/schematic/integrationsapi/types/install_stripe_claimable_sandbox_response.rb +13 -0
  61. data/lib/schematic/integrationsapi/types/install_stripe_sandbox_request_body.rb +17 -0
  62. data/lib/schematic/integrationsapi/types/list_stripe_sandbox_countries_response.rb +13 -0
  63. data/lib/schematic/internal/multipart/multipart_form_data.rb +8 -3
  64. data/lib/schematic/internal/types/model.rb +14 -6
  65. data/lib/schematic/licenses/client.rb +3 -3
  66. data/lib/schematic/planbundle/client.rb +3 -3
  67. data/lib/schematic/plangroups/client.rb +3 -3
  68. data/lib/schematic/plangroups/types/create_plan_group_request_body.rb +2 -0
  69. data/lib/schematic/plangroups/types/update_plan_group_request_body.rb +2 -0
  70. data/lib/schematic/planmigrations/client.rb +11 -11
  71. data/lib/schematic/plans/client.rb +24 -18
  72. data/lib/schematic/plans/types/count_plans_params.rb +2 -0
  73. data/lib/schematic/plans/types/count_plans_request.rb +2 -0
  74. data/lib/schematic/plans/types/list_plans_params.rb +2 -0
  75. data/lib/schematic/plans/types/list_plans_request.rb +2 -0
  76. data/lib/schematic/scheduledcheckout/client.rb +4 -4
  77. data/lib/schematic/schematic_client.rb +15 -2
  78. data/lib/schematic/types/billing_arrears_anchor.rb +12 -0
  79. data/lib/schematic/types/billing_arrears_cadence.rb +12 -0
  80. data/lib/schematic/types/billing_credit_grant_response_data.rb +8 -0
  81. data/lib/schematic/types/billing_plan_credit_grant_response_data.rb +12 -0
  82. data/lib/schematic/types/check_and_reserve_flag_response_data.rb +39 -0
  83. data/lib/schematic/types/checkout_data_response_data.rb +4 -0
  84. data/lib/schematic/types/claimed_stripe_sandbox_keys_response_data.rb +13 -0
  85. data/lib/schematic/types/company_billing_profile_response_data.rb +35 -0
  86. data/lib/schematic/types/company_detail_response_data.rb +4 -0
  87. data/lib/schematic/types/company_override_response_data.rb +4 -0
  88. data/lib/schematic/types/company_plan_credit_grant_view.rb +12 -0
  89. data/lib/schematic/types/create_billing_plan_credit_grant_request_body.rb +12 -0
  90. data/lib/schematic/types/credit_company_grant_view.rb +14 -0
  91. data/lib/schematic/types/credit_reservation_response_data.rb +25 -0
  92. data/lib/schematic/types/credit_spend_policy_response_data.rb +25 -0
  93. data/lib/schematic/types/credit_spend_policy_scope.rb +13 -0
  94. data/lib/schematic/types/credit_usage_reason.rb +2 -0
  95. data/lib/schematic/types/event_body_inference.rb +2 -0
  96. data/lib/schematic/types/event_body_track.rb +2 -0
  97. data/lib/schematic/types/event_detail_response_data.rb +2 -0
  98. data/lib/schematic/types/event_response_data.rb +2 -0
  99. data/lib/schematic/types/flag_check_reservation_response_data.rb +23 -0
  100. data/lib/schematic/types/get_onboarding_state_resp.rb +6 -0
  101. data/lib/schematic/types/issue_temporary_access_token_response_data.rb +3 -1
  102. data/lib/schematic/types/onboarding_requirement.rb +1 -0
  103. data/lib/schematic/types/onboarding_roadmap_view.rb +11 -0
  104. data/lib/schematic/types/otlp_environment_settings_response_data.rb +23 -0
  105. data/lib/schematic/types/plan_credit_grant_view.rb +12 -0
  106. data/lib/schematic/types/plan_group_detail_response_data.rb +2 -0
  107. data/lib/schematic/types/plan_group_response_data.rb +2 -0
  108. data/lib/schematic/types/rule_condition_detail_response_data.rb +2 -0
  109. data/lib/schematic/types/rule_condition_plan_version_response_data.rb +15 -0
  110. data/lib/schematic/types/rules_engine_schema_version.rb +1 -1
  111. data/lib/schematic/types/rulesengine_company.rb +2 -0
  112. data/lib/schematic/types/rulesengine_credit_postpaid_config.rb +9 -0
  113. data/lib/schematic/types/slack_connect_invite_status.rb +15 -0
  114. data/lib/schematic/types/slack_connect_invite_view.rb +15 -0
  115. data/lib/schematic/types/stripe_integration_config.rb +6 -0
  116. data/lib/schematic/types/stripe_sandbox_claim_link.rb +15 -0
  117. data/lib/schematic/types/stripe_sandbox_countries_response_data.rb +9 -0
  118. data/lib/schematic/types/stripe_sandbox_install_response_data.rb +21 -0
  119. data/lib/schematic/types/stripe_sandbox_keys_response_data.rb +13 -0
  120. data/lib/schematic/types/temporary_access_token_issuer_type.rb +12 -0
  121. data/lib/schematic/types/temporary_access_token_response_data.rb +3 -1
  122. data/lib/schematic/types/update_billing_plan_credit_grant_request_body.rb +12 -0
  123. data/lib/schematic/types/webhook_event_detail_response_data.rb +2 -0
  124. data/lib/schematic/types/webhook_event_response_data.rb +2 -0
  125. data/lib/schematic/version.rb +1 -1
  126. data/lib/schematic/wasm/rulesengine.wasm +0 -0
  127. data/lib/schematic/webhooks/client.rb +10 -10
  128. data/lib/schematic.rb +56 -4
  129. data/reference.md +1345 -44
  130. data/testapp/app.rb +13 -2
  131. metadata +55 -3
  132. data/lib/schematic/types/release_credit_lease_request_body.rb +0 -23
@@ -53,7 +53,7 @@ module Schematic
53
53
  end
54
54
  code = response.code.to_i
55
55
  if code.between?(200, 299)
56
- Schematic::Credits::Types::ListBillingCreditsResponse.load(response.body)
56
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::ListBillingCreditsResponse.load(response.body))
57
57
  else
58
58
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
59
59
  raise error_class.new(response.body, code: code)
@@ -92,7 +92,7 @@ module Schematic
92
92
  end
93
93
  code = response.code.to_i
94
94
  if code.between?(200, 299)
95
- Schematic::Credits::Types::CreateBillingCreditResponse.load(response.body)
95
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::CreateBillingCreditResponse.load(response.body))
96
96
  else
97
97
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
98
98
  raise error_class.new(response.body, code: code)
@@ -127,7 +127,7 @@ module Schematic
127
127
  end
128
128
  code = response.code.to_i
129
129
  if code.between?(200, 299)
130
- Schematic::Credits::Types::GetSingleBillingCreditResponse.load(response.body)
130
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::GetSingleBillingCreditResponse.load(response.body))
131
131
  else
132
132
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
133
133
  raise error_class.new(response.body, code: code)
@@ -171,7 +171,7 @@ module Schematic
171
171
  end
172
172
  code = response.code.to_i
173
173
  if code.between?(200, 299)
174
- Schematic::Credits::Types::UpdateBillingCreditResponse.load(response.body)
174
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::UpdateBillingCreditResponse.load(response.body))
175
175
  else
176
176
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
177
177
  raise error_class.new(response.body, code: code)
@@ -206,7 +206,7 @@ module Schematic
206
206
  end
207
207
  code = response.code.to_i
208
208
  if code.between?(200, 299)
209
- Schematic::Credits::Types::SoftDeleteBillingCreditResponse.load(response.body)
209
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::SoftDeleteBillingCreditResponse.load(response.body))
210
210
  else
211
211
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
212
212
  raise error_class.new(response.body, code: code)
@@ -245,7 +245,7 @@ module Schematic
245
245
  end
246
246
  code = response.code.to_i
247
247
  if code.between?(200, 299)
248
- Schematic::Credits::Types::ListCompanyCreditBalancesResponse.load(response.body)
248
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::ListCompanyCreditBalancesResponse.load(response.body))
249
249
  else
250
250
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
251
251
  raise error_class.new(response.body, code: code)
@@ -301,7 +301,7 @@ module Schematic
301
301
  end
302
302
  code = response.code.to_i
303
303
  if code.between?(200, 299)
304
- Schematic::Credits::Types::ListCreditBundlesResponse.load(response.body)
304
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::ListCreditBundlesResponse.load(response.body))
305
305
  else
306
306
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
307
307
  raise error_class.new(response.body, code: code)
@@ -341,7 +341,7 @@ module Schematic
341
341
  end
342
342
  code = response.code.to_i
343
343
  if code.between?(200, 299)
344
- Schematic::Credits::Types::CreateCreditBundleResponse.load(response.body)
344
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::CreateCreditBundleResponse.load(response.body))
345
345
  else
346
346
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
347
347
  raise error_class.new(response.body, code: code)
@@ -376,7 +376,7 @@ module Schematic
376
376
  end
377
377
  code = response.code.to_i
378
378
  if code.between?(200, 299)
379
- Schematic::Credits::Types::GetCreditBundleResponse.load(response.body)
379
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::GetCreditBundleResponse.load(response.body))
380
380
  else
381
381
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
382
382
  raise error_class.new(response.body, code: code)
@@ -420,7 +420,7 @@ module Schematic
420
420
  end
421
421
  code = response.code.to_i
422
422
  if code.between?(200, 299)
423
- Schematic::Credits::Types::UpdateCreditBundleDetailsResponse.load(response.body)
423
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::UpdateCreditBundleDetailsResponse.load(response.body))
424
424
  else
425
425
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
426
426
  raise error_class.new(response.body, code: code)
@@ -455,7 +455,7 @@ module Schematic
455
455
  end
456
456
  code = response.code.to_i
457
457
  if code.between?(200, 299)
458
- Schematic::Credits::Types::DeleteCreditBundleResponse.load(response.body)
458
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::DeleteCreditBundleResponse.load(response.body))
459
459
  else
460
460
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
461
461
  raise error_class.new(response.body, code: code)
@@ -511,7 +511,7 @@ module Schematic
511
511
  end
512
512
  code = response.code.to_i
513
513
  if code.between?(200, 299)
514
- Schematic::Credits::Types::CountCreditBundlesResponse.load(response.body)
514
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::CountCreditBundlesResponse.load(response.body))
515
515
  else
516
516
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
517
517
  raise error_class.new(response.body, code: code)
@@ -561,7 +561,7 @@ module Schematic
561
561
  end
562
562
  code = response.code.to_i
563
563
  if code.between?(200, 299)
564
- Schematic::Credits::Types::CountBillingCreditsResponse.load(response.body)
564
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::CountBillingCreditsResponse.load(response.body))
565
565
  else
566
566
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
567
567
  raise error_class.new(response.body, code: code)
@@ -601,7 +601,7 @@ module Schematic
601
601
  end
602
602
  code = response.code.to_i
603
603
  if code.between?(200, 299)
604
- Schematic::Credits::Types::ZeroOutGrantResponse.load(response.body)
604
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::ZeroOutGrantResponse.load(response.body))
605
605
  else
606
606
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
607
607
  raise error_class.new(response.body, code: code)
@@ -641,7 +641,7 @@ module Schematic
641
641
  end
642
642
  code = response.code.to_i
643
643
  if code.between?(200, 299)
644
- Schematic::Credits::Types::GrantBillingCreditsToCompanyResponse.load(response.body)
644
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::GrantBillingCreditsToCompanyResponse.load(response.body))
645
645
  else
646
646
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
647
647
  raise error_class.new(response.body, code: code)
@@ -694,7 +694,7 @@ module Schematic
694
694
  end
695
695
  code = response.code.to_i
696
696
  if code.between?(200, 299)
697
- Schematic::Credits::Types::CountCompanyGrantsResponse.load(response.body)
697
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::CountCompanyGrantsResponse.load(response.body))
698
698
  else
699
699
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
700
700
  raise error_class.new(response.body, code: code)
@@ -747,7 +747,7 @@ module Schematic
747
747
  end
748
748
  code = response.code.to_i
749
749
  if code.between?(200, 299)
750
- Schematic::Credits::Types::ListCompanyGrantsResponse.load(response.body)
750
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::ListCompanyGrantsResponse.load(response.body))
751
751
  else
752
752
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
753
753
  raise error_class.new(response.body, code: code)
@@ -797,7 +797,7 @@ module Schematic
797
797
  end
798
798
  code = response.code.to_i
799
799
  if code.between?(200, 299)
800
- Schematic::Credits::Types::CountBillingCreditsGrantsResponse.load(response.body)
800
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::CountBillingCreditsGrantsResponse.load(response.body))
801
801
  else
802
802
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
803
803
  raise error_class.new(response.body, code: code)
@@ -847,7 +847,7 @@ module Schematic
847
847
  end
848
848
  code = response.code.to_i
849
849
  if code.between?(200, 299)
850
- Schematic::Credits::Types::ListGrantsForCreditResponse.load(response.body)
850
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::ListGrantsForCreditResponse.load(response.body))
851
851
  else
852
852
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
853
853
  raise error_class.new(response.body, code: code)
@@ -886,7 +886,7 @@ module Schematic
886
886
  end
887
887
  code = response.code.to_i
888
888
  if code.between?(200, 299)
889
- Schematic::Credits::Types::AcquireCreditLeaseResponse.load(response.body)
889
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::AcquireCreditLeaseResponse.load(response.body))
890
890
  else
891
891
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
892
892
  raise error_class.new(response.body, code: code)
@@ -929,7 +929,7 @@ module Schematic
929
929
  end
930
930
  code = response.code.to_i
931
931
  if code.between?(200, 299)
932
- Schematic::Credits::Types::ExtendCreditLeaseResponse.load(response.body)
932
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::ExtendCreditLeaseResponse.load(response.body))
933
933
  else
934
934
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
935
935
  raise error_class.new(response.body, code: code)
@@ -937,7 +937,7 @@ module Schematic
937
937
  end
938
938
 
939
939
  # @param request_options [Hash]
940
- # @param params [Schematic::Types::ReleaseCreditLeaseRequestBody]
940
+ # @param params [Hash]
941
941
  # @option request_options [String] :base_url
942
942
  # @option request_options [Hash{String => Object}] :additional_headers
943
943
  # @option request_options [Hash{String => Object}] :additional_query_parameters
@@ -946,24 +946,15 @@ module Schematic
946
946
  # @option params [String] :lease_id
947
947
  #
948
948
  # @example
949
- # client.credits.release_credit_lease(
950
- # lease_id: "lease_id",
951
- # request: {
952
- # key: "value"
953
- # }
954
- # )
949
+ # client.credits.release_credit_lease(lease_id: "lease_id")
955
950
  #
956
951
  # @return [Schematic::Credits::Types::ReleaseCreditLeaseResponse]
957
952
  def release_credit_lease(request_options: {}, **params)
958
953
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
959
- path_param_names = %i[lease_id]
960
- body_params = params.except(*path_param_names)
961
-
962
954
  request = Schematic::Internal::JSON::Request.new(
963
955
  base_url: request_options[:base_url],
964
956
  method: "PUT",
965
957
  path: "billing/credits/lease/#{URI.encode_uri_component(params[:lease_id].to_s)}/release",
966
- body: body_params,
967
958
  request_options: request_options
968
959
  )
969
960
  begin
@@ -973,7 +964,7 @@ module Schematic
973
964
  end
974
965
  code = response.code.to_i
975
966
  if code.between?(200, 299)
976
- Schematic::Credits::Types::ReleaseCreditLeaseResponse.load(response.body)
967
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::ReleaseCreditLeaseResponse.load(response.body))
977
968
  else
978
969
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
979
970
  raise error_class.new(response.body, code: code)
@@ -1035,7 +1026,7 @@ module Schematic
1035
1026
  end
1036
1027
  code = response.code.to_i
1037
1028
  if code.between?(200, 299)
1038
- Schematic::Credits::Types::ListBillingPlanCreditGrantsResponse.load(response.body)
1029
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::ListBillingPlanCreditGrantsResponse.load(response.body))
1039
1030
  else
1040
1031
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1041
1032
  raise error_class.new(response.body, code: code)
@@ -1076,7 +1067,7 @@ module Schematic
1076
1067
  end
1077
1068
  code = response.code.to_i
1078
1069
  if code.between?(200, 299)
1079
- Schematic::Credits::Types::CreateBillingPlanCreditGrantResponse.load(response.body)
1070
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::CreateBillingPlanCreditGrantResponse.load(response.body))
1080
1071
  else
1081
1072
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1082
1073
  raise error_class.new(response.body, code: code)
@@ -1111,7 +1102,7 @@ module Schematic
1111
1102
  end
1112
1103
  code = response.code.to_i
1113
1104
  if code.between?(200, 299)
1114
- Schematic::Credits::Types::GetSingleBillingPlanCreditGrantResponse.load(response.body)
1105
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::GetSingleBillingPlanCreditGrantResponse.load(response.body))
1115
1106
  else
1116
1107
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1117
1108
  raise error_class.new(response.body, code: code)
@@ -1154,7 +1145,7 @@ module Schematic
1154
1145
  end
1155
1146
  code = response.code.to_i
1156
1147
  if code.between?(200, 299)
1157
- Schematic::Credits::Types::UpdateBillingPlanCreditGrantResponse.load(response.body)
1148
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::UpdateBillingPlanCreditGrantResponse.load(response.body))
1158
1149
  else
1159
1150
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1160
1151
  raise error_class.new(response.body, code: code)
@@ -1197,7 +1188,7 @@ module Schematic
1197
1188
  end
1198
1189
  code = response.code.to_i
1199
1190
  if code.between?(200, 299)
1200
- Schematic::Credits::Types::DeleteBillingPlanCreditGrantResponse.load(response.body)
1191
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::DeleteBillingPlanCreditGrantResponse.load(response.body))
1201
1192
  else
1202
1193
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1203
1194
  raise error_class.new(response.body, code: code)
@@ -1259,7 +1250,347 @@ module Schematic
1259
1250
  end
1260
1251
  code = response.code.to_i
1261
1252
  if code.between?(200, 299)
1262
- Schematic::Credits::Types::CountBillingPlanCreditGrantsResponse.load(response.body)
1253
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::CountBillingPlanCreditGrantsResponse.load(response.body))
1254
+ else
1255
+ error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1256
+ raise error_class.new(response.body, code: code)
1257
+ end
1258
+ end
1259
+
1260
+ # @param request_options [Hash]
1261
+ # @param params [Schematic::Credits::Types::ReserveCreditsRequestBody]
1262
+ # @option request_options [String] :base_url
1263
+ # @option request_options [Hash{String => Object}] :additional_headers
1264
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
1265
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
1266
+ # @option request_options [Integer] :timeout_in_seconds
1267
+ #
1268
+ # @example
1269
+ # client.credits.reserve_credits(
1270
+ # amount: 1.1,
1271
+ # company_id: "company_id",
1272
+ # credit_type_id: "credit_type_id"
1273
+ # )
1274
+ #
1275
+ # @return [Schematic::Credits::Types::ReserveCreditsResponse]
1276
+ def reserve_credits(request_options: {}, **params)
1277
+ params = Schematic::Internal::Types::Utils.normalize_keys(params)
1278
+ request = Schematic::Internal::JSON::Request.new(
1279
+ base_url: request_options[:base_url],
1280
+ method: "POST",
1281
+ path: "billing/credits/reservations",
1282
+ body: Schematic::Credits::Types::ReserveCreditsRequestBody.new(params).to_h,
1283
+ request_options: request_options
1284
+ )
1285
+ begin
1286
+ response = @client.send(request)
1287
+ rescue Net::HTTPRequestTimeout
1288
+ raise Schematic::Errors::TimeoutError
1289
+ end
1290
+ code = response.code.to_i
1291
+ if code.between?(200, 299)
1292
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::ReserveCreditsResponse.load(response.body))
1293
+ else
1294
+ error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1295
+ raise error_class.new(response.body, code: code)
1296
+ end
1297
+ end
1298
+
1299
+ # @param request_options [Hash]
1300
+ # @param params [Hash]
1301
+ # @option request_options [String] :base_url
1302
+ # @option request_options [Hash{String => Object}] :additional_headers
1303
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
1304
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
1305
+ # @option request_options [Integer] :timeout_in_seconds
1306
+ # @option params [String] :reservation_id
1307
+ #
1308
+ # @example
1309
+ # client.credits.release_credit_reservation(reservation_id: "reservation_id")
1310
+ #
1311
+ # @return [Schematic::Credits::Types::ReleaseCreditReservationResponse]
1312
+ def release_credit_reservation(request_options: {}, **params)
1313
+ params = Schematic::Internal::Types::Utils.normalize_keys(params)
1314
+ request = Schematic::Internal::JSON::Request.new(
1315
+ base_url: request_options[:base_url],
1316
+ method: "PUT",
1317
+ path: "billing/credits/reservations/#{URI.encode_uri_component(params[:reservation_id].to_s)}/release",
1318
+ request_options: request_options
1319
+ )
1320
+ begin
1321
+ response = @client.send(request)
1322
+ rescue Net::HTTPRequestTimeout
1323
+ raise Schematic::Errors::TimeoutError
1324
+ end
1325
+ code = response.code.to_i
1326
+ if code.between?(200, 299)
1327
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::ReleaseCreditReservationResponse.load(response.body))
1328
+ else
1329
+ error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1330
+ raise error_class.new(response.body, code: code)
1331
+ end
1332
+ end
1333
+
1334
+ # @param request_options [Hash]
1335
+ # @param params [Hash]
1336
+ # @option request_options [String] :base_url
1337
+ # @option request_options [Hash{String => Object}] :additional_headers
1338
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
1339
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
1340
+ # @option request_options [Integer] :timeout_in_seconds
1341
+ # @option params [String, nil] :billing_credit_id
1342
+ # @option params [String, nil] :company_id
1343
+ # @option params [Schematic::Types::CreditSpendPolicyScope, nil] :scope_type
1344
+ # @option params [String, nil] :user_id
1345
+ # @option params [String, nil] :user_ids
1346
+ # @option params [Integer, nil] :limit
1347
+ # @option params [Integer, nil] :offset
1348
+ #
1349
+ # @example
1350
+ # client.credits.list_credit_spend_policies(
1351
+ # billing_credit_id: "billing_credit_id",
1352
+ # company_id: "company_id",
1353
+ # scope_type: "company",
1354
+ # user_id: "user_id",
1355
+ # user_ids: ["user_ids"],
1356
+ # limit: 1000000,
1357
+ # offset: 1000000
1358
+ # )
1359
+ #
1360
+ # @return [Schematic::Credits::Types::ListCreditSpendPoliciesResponse]
1361
+ def list_credit_spend_policies(request_options: {}, **params)
1362
+ params = Schematic::Internal::Types::Utils.normalize_keys(params)
1363
+ query_params = {}
1364
+ query_params["billing_credit_id"] = params[:billing_credit_id] if params.key?(:billing_credit_id)
1365
+ query_params["company_id"] = params[:company_id] if params.key?(:company_id)
1366
+ query_params["scope_type"] = params[:scope_type] if params.key?(:scope_type)
1367
+ query_params["user_id"] = params[:user_id] if params.key?(:user_id)
1368
+ query_params["user_ids"] = params[:user_ids] if params.key?(:user_ids)
1369
+ query_params["limit"] = params[:limit] if params.key?(:limit)
1370
+ query_params["offset"] = params[:offset] if params.key?(:offset)
1371
+
1372
+ request = Schematic::Internal::JSON::Request.new(
1373
+ base_url: request_options[:base_url],
1374
+ method: "GET",
1375
+ path: "billing/credits/spend-policies",
1376
+ query: query_params,
1377
+ request_options: request_options
1378
+ )
1379
+ begin
1380
+ response = @client.send(request)
1381
+ rescue Net::HTTPRequestTimeout
1382
+ raise Schematic::Errors::TimeoutError
1383
+ end
1384
+ code = response.code.to_i
1385
+ if code.between?(200, 299)
1386
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::ListCreditSpendPoliciesResponse.load(response.body))
1387
+ else
1388
+ error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1389
+ raise error_class.new(response.body, code: code)
1390
+ end
1391
+ end
1392
+
1393
+ # @param request_options [Hash]
1394
+ # @param params [Schematic::Credits::Types::CreateCreditSpendPolicyRequestBody]
1395
+ # @option request_options [String] :base_url
1396
+ # @option request_options [Hash{String => Object}] :additional_headers
1397
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
1398
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
1399
+ # @option request_options [Integer] :timeout_in_seconds
1400
+ #
1401
+ # @example
1402
+ # client.credits.create_credit_spend_policy(
1403
+ # billing_credit_id: "billing_credit_id",
1404
+ # max_per_draw: 1.1
1405
+ # )
1406
+ #
1407
+ # @return [Schematic::Credits::Types::CreateCreditSpendPolicyResponse]
1408
+ def create_credit_spend_policy(request_options: {}, **params)
1409
+ params = Schematic::Internal::Types::Utils.normalize_keys(params)
1410
+ request = Schematic::Internal::JSON::Request.new(
1411
+ base_url: request_options[:base_url],
1412
+ method: "POST",
1413
+ path: "billing/credits/spend-policies",
1414
+ body: Schematic::Credits::Types::CreateCreditSpendPolicyRequestBody.new(params).to_h,
1415
+ request_options: request_options
1416
+ )
1417
+ begin
1418
+ response = @client.send(request)
1419
+ rescue Net::HTTPRequestTimeout
1420
+ raise Schematic::Errors::TimeoutError
1421
+ end
1422
+ code = response.code.to_i
1423
+ if code.between?(200, 299)
1424
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::CreateCreditSpendPolicyResponse.load(response.body))
1425
+ else
1426
+ error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1427
+ raise error_class.new(response.body, code: code)
1428
+ end
1429
+ end
1430
+
1431
+ # @param request_options [Hash]
1432
+ # @param params [Hash]
1433
+ # @option request_options [String] :base_url
1434
+ # @option request_options [Hash{String => Object}] :additional_headers
1435
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
1436
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
1437
+ # @option request_options [Integer] :timeout_in_seconds
1438
+ # @option params [String] :spend_policy_id
1439
+ #
1440
+ # @example
1441
+ # client.credits.get_credit_spend_policy(spend_policy_id: "spend_policy_id")
1442
+ #
1443
+ # @return [Schematic::Credits::Types::GetCreditSpendPolicyResponse]
1444
+ def get_credit_spend_policy(request_options: {}, **params)
1445
+ params = Schematic::Internal::Types::Utils.normalize_keys(params)
1446
+ request = Schematic::Internal::JSON::Request.new(
1447
+ base_url: request_options[:base_url],
1448
+ method: "GET",
1449
+ path: "billing/credits/spend-policies/#{URI.encode_uri_component(params[:spend_policy_id].to_s)}",
1450
+ request_options: request_options
1451
+ )
1452
+ begin
1453
+ response = @client.send(request)
1454
+ rescue Net::HTTPRequestTimeout
1455
+ raise Schematic::Errors::TimeoutError
1456
+ end
1457
+ code = response.code.to_i
1458
+ if code.between?(200, 299)
1459
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::GetCreditSpendPolicyResponse.load(response.body))
1460
+ else
1461
+ error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1462
+ raise error_class.new(response.body, code: code)
1463
+ end
1464
+ end
1465
+
1466
+ # @param request_options [Hash]
1467
+ # @param params [Schematic::Credits::Types::UpdateCreditSpendPolicyRequestBody]
1468
+ # @option request_options [String] :base_url
1469
+ # @option request_options [Hash{String => Object}] :additional_headers
1470
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
1471
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
1472
+ # @option request_options [Integer] :timeout_in_seconds
1473
+ # @option params [String] :spend_policy_id
1474
+ #
1475
+ # @example
1476
+ # client.credits.update_credit_spend_policy(spend_policy_id: "spend_policy_id")
1477
+ #
1478
+ # @return [Schematic::Credits::Types::UpdateCreditSpendPolicyResponse]
1479
+ def update_credit_spend_policy(request_options: {}, **params)
1480
+ params = Schematic::Internal::Types::Utils.normalize_keys(params)
1481
+ request_data = Schematic::Credits::Types::UpdateCreditSpendPolicyRequestBody.new(params).to_h
1482
+ non_body_param_names = %w[spend_policy_id]
1483
+ body = request_data.except(*non_body_param_names)
1484
+
1485
+ request = Schematic::Internal::JSON::Request.new(
1486
+ base_url: request_options[:base_url],
1487
+ method: "PUT",
1488
+ path: "billing/credits/spend-policies/#{URI.encode_uri_component(params[:spend_policy_id].to_s)}",
1489
+ body: body,
1490
+ request_options: request_options
1491
+ )
1492
+ begin
1493
+ response = @client.send(request)
1494
+ rescue Net::HTTPRequestTimeout
1495
+ raise Schematic::Errors::TimeoutError
1496
+ end
1497
+ code = response.code.to_i
1498
+ if code.between?(200, 299)
1499
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::UpdateCreditSpendPolicyResponse.load(response.body))
1500
+ else
1501
+ error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1502
+ raise error_class.new(response.body, code: code)
1503
+ end
1504
+ end
1505
+
1506
+ # @param request_options [Hash]
1507
+ # @param params [Hash]
1508
+ # @option request_options [String] :base_url
1509
+ # @option request_options [Hash{String => Object}] :additional_headers
1510
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
1511
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
1512
+ # @option request_options [Integer] :timeout_in_seconds
1513
+ # @option params [String] :spend_policy_id
1514
+ #
1515
+ # @example
1516
+ # client.credits.delete_credit_spend_policy(spend_policy_id: "spend_policy_id")
1517
+ #
1518
+ # @return [Schematic::Credits::Types::DeleteCreditSpendPolicyResponse]
1519
+ def delete_credit_spend_policy(request_options: {}, **params)
1520
+ params = Schematic::Internal::Types::Utils.normalize_keys(params)
1521
+ request = Schematic::Internal::JSON::Request.new(
1522
+ base_url: request_options[:base_url],
1523
+ method: "DELETE",
1524
+ path: "billing/credits/spend-policies/#{URI.encode_uri_component(params[:spend_policy_id].to_s)}",
1525
+ request_options: request_options
1526
+ )
1527
+ begin
1528
+ response = @client.send(request)
1529
+ rescue Net::HTTPRequestTimeout
1530
+ raise Schematic::Errors::TimeoutError
1531
+ end
1532
+ code = response.code.to_i
1533
+ if code.between?(200, 299)
1534
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::DeleteCreditSpendPolicyResponse.load(response.body))
1535
+ else
1536
+ error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1537
+ raise error_class.new(response.body, code: code)
1538
+ end
1539
+ end
1540
+
1541
+ # @param request_options [Hash]
1542
+ # @param params [Hash]
1543
+ # @option request_options [String] :base_url
1544
+ # @option request_options [Hash{String => Object}] :additional_headers
1545
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
1546
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
1547
+ # @option request_options [Integer] :timeout_in_seconds
1548
+ # @option params [String, nil] :billing_credit_id
1549
+ # @option params [String, nil] :company_id
1550
+ # @option params [Schematic::Types::CreditSpendPolicyScope, nil] :scope_type
1551
+ # @option params [String, nil] :user_id
1552
+ # @option params [String, nil] :user_ids
1553
+ # @option params [Integer, nil] :limit
1554
+ # @option params [Integer, nil] :offset
1555
+ #
1556
+ # @example
1557
+ # client.credits.count_credit_spend_policies(
1558
+ # billing_credit_id: "billing_credit_id",
1559
+ # company_id: "company_id",
1560
+ # scope_type: "company",
1561
+ # user_id: "user_id",
1562
+ # user_ids: ["user_ids"],
1563
+ # limit: 1000000,
1564
+ # offset: 1000000
1565
+ # )
1566
+ #
1567
+ # @return [Schematic::Credits::Types::CountCreditSpendPoliciesResponse]
1568
+ def count_credit_spend_policies(request_options: {}, **params)
1569
+ params = Schematic::Internal::Types::Utils.normalize_keys(params)
1570
+ query_params = {}
1571
+ query_params["billing_credit_id"] = params[:billing_credit_id] if params.key?(:billing_credit_id)
1572
+ query_params["company_id"] = params[:company_id] if params.key?(:company_id)
1573
+ query_params["scope_type"] = params[:scope_type] if params.key?(:scope_type)
1574
+ query_params["user_id"] = params[:user_id] if params.key?(:user_id)
1575
+ query_params["user_ids"] = params[:user_ids] if params.key?(:user_ids)
1576
+ query_params["limit"] = params[:limit] if params.key?(:limit)
1577
+ query_params["offset"] = params[:offset] if params.key?(:offset)
1578
+
1579
+ request = Schematic::Internal::JSON::Request.new(
1580
+ base_url: request_options[:base_url],
1581
+ method: "GET",
1582
+ path: "billing/credits/spend-policies/count",
1583
+ query: query_params,
1584
+ request_options: request_options
1585
+ )
1586
+ begin
1587
+ response = @client.send(request)
1588
+ rescue Net::HTTPRequestTimeout
1589
+ raise Schematic::Errors::TimeoutError
1590
+ end
1591
+ code = response.code.to_i
1592
+ if code.between?(200, 299)
1593
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::CountCreditSpendPoliciesResponse.load(response.body))
1263
1594
  else
1264
1595
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1265
1596
  raise error_class.new(response.body, code: code)
@@ -1321,7 +1652,7 @@ module Schematic
1321
1652
  end
1322
1653
  code = response.code.to_i
1323
1654
  if code.between?(200, 299)
1324
- Schematic::Credits::Types::ListCreditEventLedgerResponse.load(response.body)
1655
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::ListCreditEventLedgerResponse.load(response.body))
1325
1656
  else
1326
1657
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1327
1658
  raise error_class.new(response.body, code: code)
@@ -1383,7 +1714,7 @@ module Schematic
1383
1714
  end
1384
1715
  code = response.code.to_i
1385
1716
  if code.between?(200, 299)
1386
- Schematic::Credits::Types::CountCreditEventLedgerResponse.load(response.body)
1717
+ (response.body.to_s.empty? ? nil : Schematic::Credits::Types::CountCreditEventLedgerResponse.load(response.body))
1387
1718
  else
1388
1719
  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
1389
1720
  raise error_class.new(response.body, code: code)
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Schematic
4
+ module Credits
5
+ module Types
6
+ # Input parameters
7
+ class CountCreditSpendPoliciesParams < Internal::Types::Model
8
+ field :billing_credit_id, -> { String }, optional: true, nullable: false
9
+
10
+ field :company_id, -> { String }, optional: true, nullable: false
11
+
12
+ field :limit, -> { Integer }, optional: true, nullable: false
13
+
14
+ field :offset, -> { Integer }, optional: true, nullable: false
15
+
16
+ field :scope_type, -> { Schematic::Types::CreditSpendPolicyScope }, optional: true, nullable: false
17
+
18
+ field :user_id, -> { String }, optional: true, nullable: false
19
+
20
+ field :user_ids, -> { Internal::Types::Array[String] }, optional: true, nullable: false
21
+ end
22
+ end
23
+ end
24
+ end