clerk-sdk-ruby 5.0.0.pre.beta → 5.0.0.pre.beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/clerk/billing.rb +170 -0
- data/lib/clerk/instancesettings.rb +261 -1
- data/lib/clerk/models/components/commercepriceresponse.rb +76 -0
- data/lib/clerk/models/components/commercepriceresponse.rbi +35 -0
- data/lib/clerk/models/components/commercepriceresponse_object.rb +22 -0
- data/lib/clerk/models/components/commercepriceresponse_object.rbi +11 -0
- data/lib/clerk/models/components/commercepricetransitiondetails.rb +64 -0
- data/lib/clerk/models/components/commercepricetransitiondetails.rbi +29 -0
- data/lib/clerk/models/components/commercepricetransitionresponse.rb +40 -0
- data/lib/clerk/models/components/commercepricetransitionresponse.rbi +17 -0
- data/lib/clerk/models/components/commercepricetransitionresponse_object.rb +22 -0
- data/lib/clerk/models/components/commercepricetransitionresponse_object.rbi +11 -0
- data/lib/clerk/models/components/effective_mode.rb +23 -0
- data/lib/clerk/models/components/effective_mode.rbi +11 -0
- data/lib/clerk/models/components/immediate_charge.rb +44 -0
- data/lib/clerk/models/components/immediate_charge.rbi +19 -0
- data/lib/clerk/models/components/instanceprotect.rb +40 -0
- data/lib/clerk/models/components/instanceprotect.rbi +17 -0
- data/lib/clerk/models/components/instanceprotect_object.rb +22 -0
- data/lib/clerk/models/components/instanceprotect_object.rbi +11 -0
- data/lib/clerk/models/components/previous_subscription_item_status.rb +24 -0
- data/lib/clerk/models/components/previous_subscription_item_status.rbi +11 -0
- data/lib/clerk/models/components/pricetransitionrequest.rb +36 -0
- data/lib/clerk/models/components/pricetransitionrequest.rbi +15 -0
- data/lib/clerk/models/components/schemas_commerceplan.rb +144 -0
- data/lib/clerk/models/components/schemas_commerceplan.rbi +69 -0
- data/lib/clerk/models/components/schemas_commerceplan_object.rb +22 -0
- data/lib/clerk/models/components/schemas_commerceplan_object.rbi +11 -0
- data/lib/clerk/models/components.rb +13 -0
- data/lib/clerk/models/operations/createbillingpricetransition_request.rb +36 -0
- data/lib/clerk/models/operations/createbillingpricetransition_request.rbi +15 -0
- data/lib/clerk/models/operations/createbillingpricetransition_response.rb +44 -0
- data/lib/clerk/models/operations/createbillingpricetransition_response.rbi +19 -0
- data/lib/clerk/models/operations/createuser_request.rb +1 -1
- data/lib/clerk/models/operations/getinstanceprotect_response.rb +44 -0
- data/lib/clerk/models/operations/getinstanceprotect_response.rbi +19 -0
- data/lib/clerk/models/operations/updateinstanceprotect_request.rb +36 -0
- data/lib/clerk/models/operations/updateinstanceprotect_request.rbi +15 -0
- data/lib/clerk/models/operations/updateinstanceprotect_response.rb +44 -0
- data/lib/clerk/models/operations/updateinstanceprotect_response.rbi +19 -0
- data/lib/clerk/models/operations/updateuser_requestbody.rb +1 -1
- data/lib/clerk/models/operations.rb +5 -0
- data/lib/clerk/sdkconfiguration.rb +3 -3
- data/lib/clerk/users.rb +3 -3
- metadata +38 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc7b0d0982301864ad97026cc179a43e7e9f6c68a392396ebbbac98016bb19bf
|
|
4
|
+
data.tar.gz: b5c91c3096c37dc48ca43b8ac9af13ab25bff49821151872d48ee3c03947955e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3cba47d353ed5abef6c7639fe7dbbeb7d59e18d9c07fd7e6038eda6c278f690f60a4a3a2ea0f319f00646f048ce47c650271dd27494de28c4d1cd86661315af4
|
|
7
|
+
data.tar.gz: 10d2eeb326457c39d445b010ccce48da8d2c3b22a6e7663556a0fbfae96ed2a8cc6474ed181bc8670b263a04a369f7d1f3dae05ea4b1af28ca2bb547da50fafb
|
data/lib/clerk/billing.rb
CHANGED
|
@@ -678,6 +678,176 @@ module Clerk
|
|
|
678
678
|
|
|
679
679
|
|
|
680
680
|
|
|
681
|
+
def create_price_transition(body:, subscription_item_id:, retries: nil, timeout_ms: nil)
|
|
682
|
+
# create_price_transition - Create a price transition for a subscription item
|
|
683
|
+
# Creates a price transition for the specified subscription item.
|
|
684
|
+
# This may create an upcoming subscription item or activate immediately depending on plan and payer rules.
|
|
685
|
+
request = Models::Operations::CreateBillingPriceTransitionRequest.new(
|
|
686
|
+
subscription_item_id: subscription_item_id,
|
|
687
|
+
body: body
|
|
688
|
+
)
|
|
689
|
+
url, params = @sdk_configuration.get_server_details
|
|
690
|
+
base_url = Utils.template_url(url, params)
|
|
691
|
+
url = Utils.generate_url(
|
|
692
|
+
Models::Operations::CreateBillingPriceTransitionRequest,
|
|
693
|
+
base_url,
|
|
694
|
+
'/billing/subscription_items/{subscription_item_id}/price_transition',
|
|
695
|
+
request
|
|
696
|
+
)
|
|
697
|
+
headers = {}
|
|
698
|
+
|
|
699
|
+
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
|
|
700
|
+
headers['content-type'] = req_content_type
|
|
701
|
+
raise StandardError, 'request body is required' if data.nil? && form.nil?
|
|
702
|
+
|
|
703
|
+
if form
|
|
704
|
+
body = Utils.encode_form(form)
|
|
705
|
+
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
706
|
+
body = URI.encode_www_form(data)
|
|
707
|
+
else
|
|
708
|
+
body = data
|
|
709
|
+
end
|
|
710
|
+
headers['Accept'] = 'application/json'
|
|
711
|
+
headers['user-agent'] = @sdk_configuration.user_agent
|
|
712
|
+
retries ||= @sdk_configuration.retry_config
|
|
713
|
+
retries ||= Utils::RetryConfig.new(
|
|
714
|
+
backoff: Utils::BackoffStrategy.new(
|
|
715
|
+
exponent: 1.5,
|
|
716
|
+
initial_interval: 500,
|
|
717
|
+
max_elapsed_time: 3_600_000,
|
|
718
|
+
max_interval: 60_000
|
|
719
|
+
),
|
|
720
|
+
retry_connection_errors: true,
|
|
721
|
+
strategy: 'backoff'
|
|
722
|
+
)
|
|
723
|
+
retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
|
|
724
|
+
retry_options[:retry_statuses] = [500, 501, 502, 503, 504, 505]
|
|
725
|
+
|
|
726
|
+
security = @sdk_configuration.security_source&.call
|
|
727
|
+
|
|
728
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
|
729
|
+
timeout ||= @sdk_configuration.timeout
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
connection = @sdk_configuration.client.dup
|
|
733
|
+
connection.request :retry, retry_options
|
|
734
|
+
|
|
735
|
+
hook_ctx = SDKHooks::HookContext.new(
|
|
736
|
+
config: @sdk_configuration,
|
|
737
|
+
base_url: base_url,
|
|
738
|
+
oauth2_scopes: nil,
|
|
739
|
+
operation_id: 'CreateBillingPriceTransition',
|
|
740
|
+
security_source: @sdk_configuration.security_source
|
|
741
|
+
)
|
|
742
|
+
|
|
743
|
+
error = nil
|
|
744
|
+
http_response = nil
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
begin
|
|
748
|
+
http_response = connection.post(url) do |req|
|
|
749
|
+
req.body = body
|
|
750
|
+
req.headers.merge!(headers)
|
|
751
|
+
req.options.timeout = timeout unless timeout.nil?
|
|
752
|
+
Utils.configure_request_security(req, security)
|
|
753
|
+
|
|
754
|
+
@sdk_configuration.hooks.before_request(
|
|
755
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
|
756
|
+
hook_ctx: hook_ctx
|
|
757
|
+
),
|
|
758
|
+
request: req
|
|
759
|
+
)
|
|
760
|
+
end
|
|
761
|
+
rescue StandardError => e
|
|
762
|
+
error = e
|
|
763
|
+
ensure
|
|
764
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
|
765
|
+
http_response = @sdk_configuration.hooks.after_error(
|
|
766
|
+
error: error,
|
|
767
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
768
|
+
hook_ctx: hook_ctx
|
|
769
|
+
),
|
|
770
|
+
response: http_response
|
|
771
|
+
)
|
|
772
|
+
else
|
|
773
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
774
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
775
|
+
hook_ctx: hook_ctx
|
|
776
|
+
),
|
|
777
|
+
response: http_response
|
|
778
|
+
)
|
|
779
|
+
end
|
|
780
|
+
|
|
781
|
+
if http_response.nil?
|
|
782
|
+
raise error if !error.nil?
|
|
783
|
+
raise 'no response'
|
|
784
|
+
end
|
|
785
|
+
end
|
|
786
|
+
|
|
787
|
+
content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
|
|
788
|
+
if Utils.match_status_code(http_response.status, ['200'])
|
|
789
|
+
if Utils.match_content_type(content_type, 'application/json')
|
|
790
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
791
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
792
|
+
hook_ctx: hook_ctx
|
|
793
|
+
),
|
|
794
|
+
response: http_response
|
|
795
|
+
)
|
|
796
|
+
response_data = http_response.env.response_body
|
|
797
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Components::CommercePriceTransitionResponse)
|
|
798
|
+
response = Models::Operations::CreateBillingPriceTransitionResponse.new(
|
|
799
|
+
status_code: http_response.status,
|
|
800
|
+
content_type: content_type,
|
|
801
|
+
raw_response: http_response,
|
|
802
|
+
commerce_price_transition_response: obj
|
|
803
|
+
)
|
|
804
|
+
|
|
805
|
+
return response
|
|
806
|
+
else
|
|
807
|
+
raise ::Clerk::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
|
|
808
|
+
end
|
|
809
|
+
elsif Utils.match_status_code(http_response.status, ['400', '401', '403', '404', '409', '422'])
|
|
810
|
+
if Utils.match_content_type(content_type, 'application/json')
|
|
811
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
812
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
813
|
+
hook_ctx: hook_ctx
|
|
814
|
+
),
|
|
815
|
+
response: http_response
|
|
816
|
+
)
|
|
817
|
+
response_data = http_response.env.response_body
|
|
818
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ClerkErrors)
|
|
819
|
+
obj.raw_response = http_response
|
|
820
|
+
raise obj
|
|
821
|
+
else
|
|
822
|
+
raise ::Clerk::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
|
|
823
|
+
end
|
|
824
|
+
elsif Utils.match_status_code(http_response.status, ['500'])
|
|
825
|
+
if Utils.match_content_type(content_type, 'application/json')
|
|
826
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
827
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
828
|
+
hook_ctx: hook_ctx
|
|
829
|
+
),
|
|
830
|
+
response: http_response
|
|
831
|
+
)
|
|
832
|
+
response_data = http_response.env.response_body
|
|
833
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ClerkErrors)
|
|
834
|
+
obj.raw_response = http_response
|
|
835
|
+
raise obj
|
|
836
|
+
else
|
|
837
|
+
raise ::Clerk::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
|
|
838
|
+
end
|
|
839
|
+
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
840
|
+
raise ::Clerk::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
|
841
|
+
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
842
|
+
raise ::Clerk::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
|
843
|
+
else
|
|
844
|
+
raise ::Clerk::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown status code received'
|
|
845
|
+
|
|
846
|
+
end
|
|
847
|
+
end
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
|
|
681
851
|
def list_statements(paginated: nil, limit: nil, offset: nil, retries: nil, timeout_ms: nil)
|
|
682
852
|
# list_statements - List all billing statements
|
|
683
853
|
# Returns a list of all billing statements for the instance. The statements are returned sorted by creation date,
|
|
@@ -14,7 +14,7 @@ module Clerk
|
|
|
14
14
|
class InstanceSettings
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
# Modify the settings of your instance.
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def initialize(sdk_config)
|
|
@@ -716,5 +716,265 @@ module Clerk
|
|
|
716
716
|
|
|
717
717
|
end
|
|
718
718
|
end
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
def get_instance_protect(retries: nil, timeout_ms: nil)
|
|
723
|
+
# get_instance_protect - Get instance protect settings
|
|
724
|
+
url, params = @sdk_configuration.get_server_details
|
|
725
|
+
base_url = Utils.template_url(url, params)
|
|
726
|
+
url = "#{base_url}/instance/protect"
|
|
727
|
+
headers = {}
|
|
728
|
+
|
|
729
|
+
headers['Accept'] = 'application/json'
|
|
730
|
+
headers['user-agent'] = @sdk_configuration.user_agent
|
|
731
|
+
retries ||= @sdk_configuration.retry_config
|
|
732
|
+
retries ||= Utils::RetryConfig.new(
|
|
733
|
+
backoff: Utils::BackoffStrategy.new(
|
|
734
|
+
exponent: 1.5,
|
|
735
|
+
initial_interval: 500,
|
|
736
|
+
max_elapsed_time: 3_600_000,
|
|
737
|
+
max_interval: 60_000
|
|
738
|
+
),
|
|
739
|
+
retry_connection_errors: true,
|
|
740
|
+
strategy: 'backoff'
|
|
741
|
+
)
|
|
742
|
+
retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
|
|
743
|
+
retry_options[:retry_statuses] = [500, 501, 502, 503, 504, 505]
|
|
744
|
+
|
|
745
|
+
security = @sdk_configuration.security_source&.call
|
|
746
|
+
|
|
747
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
|
748
|
+
timeout ||= @sdk_configuration.timeout
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
connection = @sdk_configuration.client.dup
|
|
752
|
+
connection.request :retry, retry_options
|
|
753
|
+
|
|
754
|
+
hook_ctx = SDKHooks::HookContext.new(
|
|
755
|
+
config: @sdk_configuration,
|
|
756
|
+
base_url: base_url,
|
|
757
|
+
oauth2_scopes: nil,
|
|
758
|
+
operation_id: 'GetInstanceProtect',
|
|
759
|
+
security_source: @sdk_configuration.security_source
|
|
760
|
+
)
|
|
761
|
+
|
|
762
|
+
error = nil
|
|
763
|
+
http_response = nil
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
begin
|
|
767
|
+
http_response = connection.get(url) do |req|
|
|
768
|
+
req.headers.merge!(headers)
|
|
769
|
+
req.options.timeout = timeout unless timeout.nil?
|
|
770
|
+
Utils.configure_request_security(req, security)
|
|
771
|
+
|
|
772
|
+
@sdk_configuration.hooks.before_request(
|
|
773
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
|
774
|
+
hook_ctx: hook_ctx
|
|
775
|
+
),
|
|
776
|
+
request: req
|
|
777
|
+
)
|
|
778
|
+
end
|
|
779
|
+
rescue StandardError => e
|
|
780
|
+
error = e
|
|
781
|
+
ensure
|
|
782
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
|
783
|
+
http_response = @sdk_configuration.hooks.after_error(
|
|
784
|
+
error: error,
|
|
785
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
786
|
+
hook_ctx: hook_ctx
|
|
787
|
+
),
|
|
788
|
+
response: http_response
|
|
789
|
+
)
|
|
790
|
+
else
|
|
791
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
792
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
793
|
+
hook_ctx: hook_ctx
|
|
794
|
+
),
|
|
795
|
+
response: http_response
|
|
796
|
+
)
|
|
797
|
+
end
|
|
798
|
+
|
|
799
|
+
if http_response.nil?
|
|
800
|
+
raise error if !error.nil?
|
|
801
|
+
raise 'no response'
|
|
802
|
+
end
|
|
803
|
+
end
|
|
804
|
+
|
|
805
|
+
content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
|
|
806
|
+
if Utils.match_status_code(http_response.status, ['200'])
|
|
807
|
+
if Utils.match_content_type(content_type, 'application/json')
|
|
808
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
809
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
810
|
+
hook_ctx: hook_ctx
|
|
811
|
+
),
|
|
812
|
+
response: http_response
|
|
813
|
+
)
|
|
814
|
+
response_data = http_response.env.response_body
|
|
815
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Components::InstanceProtect)
|
|
816
|
+
response = Models::Operations::GetInstanceProtectResponse.new(
|
|
817
|
+
status_code: http_response.status,
|
|
818
|
+
content_type: content_type,
|
|
819
|
+
raw_response: http_response,
|
|
820
|
+
instance_protect: obj
|
|
821
|
+
)
|
|
822
|
+
|
|
823
|
+
return response
|
|
824
|
+
else
|
|
825
|
+
raise ::Clerk::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
|
|
826
|
+
end
|
|
827
|
+
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
828
|
+
raise ::Clerk::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
|
829
|
+
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
830
|
+
raise ::Clerk::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
|
831
|
+
else
|
|
832
|
+
raise ::Clerk::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown status code received'
|
|
833
|
+
|
|
834
|
+
end
|
|
835
|
+
end
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
def update_instance_protect(request: nil, retries: nil, timeout_ms: nil)
|
|
840
|
+
# update_instance_protect - Update instance protect settings
|
|
841
|
+
url, params = @sdk_configuration.get_server_details
|
|
842
|
+
base_url = Utils.template_url(url, params)
|
|
843
|
+
url = "#{base_url}/instance/protect"
|
|
844
|
+
headers = {}
|
|
845
|
+
|
|
846
|
+
req_content_type, data, form = Utils.serialize_request_body(request, false, true, :request, :json)
|
|
847
|
+
headers['content-type'] = req_content_type
|
|
848
|
+
|
|
849
|
+
if form
|
|
850
|
+
body = Utils.encode_form(form)
|
|
851
|
+
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
852
|
+
body = URI.encode_www_form(data)
|
|
853
|
+
else
|
|
854
|
+
body = data
|
|
855
|
+
end
|
|
856
|
+
headers['Accept'] = 'application/json'
|
|
857
|
+
headers['user-agent'] = @sdk_configuration.user_agent
|
|
858
|
+
retries ||= @sdk_configuration.retry_config
|
|
859
|
+
retries ||= Utils::RetryConfig.new(
|
|
860
|
+
backoff: Utils::BackoffStrategy.new(
|
|
861
|
+
exponent: 1.5,
|
|
862
|
+
initial_interval: 500,
|
|
863
|
+
max_elapsed_time: 3_600_000,
|
|
864
|
+
max_interval: 60_000
|
|
865
|
+
),
|
|
866
|
+
retry_connection_errors: true,
|
|
867
|
+
strategy: 'backoff'
|
|
868
|
+
)
|
|
869
|
+
retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
|
|
870
|
+
retry_options[:retry_statuses] = [500, 501, 502, 503, 504, 505]
|
|
871
|
+
|
|
872
|
+
security = @sdk_configuration.security_source&.call
|
|
873
|
+
|
|
874
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
|
875
|
+
timeout ||= @sdk_configuration.timeout
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
connection = @sdk_configuration.client.dup
|
|
879
|
+
connection.request :retry, retry_options
|
|
880
|
+
|
|
881
|
+
hook_ctx = SDKHooks::HookContext.new(
|
|
882
|
+
config: @sdk_configuration,
|
|
883
|
+
base_url: base_url,
|
|
884
|
+
oauth2_scopes: nil,
|
|
885
|
+
operation_id: 'UpdateInstanceProtect',
|
|
886
|
+
security_source: @sdk_configuration.security_source
|
|
887
|
+
)
|
|
888
|
+
|
|
889
|
+
error = nil
|
|
890
|
+
http_response = nil
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
begin
|
|
894
|
+
http_response = connection.patch(url) do |req|
|
|
895
|
+
req.body = body
|
|
896
|
+
req.headers.merge!(headers)
|
|
897
|
+
req.options.timeout = timeout unless timeout.nil?
|
|
898
|
+
Utils.configure_request_security(req, security)
|
|
899
|
+
|
|
900
|
+
@sdk_configuration.hooks.before_request(
|
|
901
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
|
902
|
+
hook_ctx: hook_ctx
|
|
903
|
+
),
|
|
904
|
+
request: req
|
|
905
|
+
)
|
|
906
|
+
end
|
|
907
|
+
rescue StandardError => e
|
|
908
|
+
error = e
|
|
909
|
+
ensure
|
|
910
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
|
911
|
+
http_response = @sdk_configuration.hooks.after_error(
|
|
912
|
+
error: error,
|
|
913
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
914
|
+
hook_ctx: hook_ctx
|
|
915
|
+
),
|
|
916
|
+
response: http_response
|
|
917
|
+
)
|
|
918
|
+
else
|
|
919
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
920
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
921
|
+
hook_ctx: hook_ctx
|
|
922
|
+
),
|
|
923
|
+
response: http_response
|
|
924
|
+
)
|
|
925
|
+
end
|
|
926
|
+
|
|
927
|
+
if http_response.nil?
|
|
928
|
+
raise error if !error.nil?
|
|
929
|
+
raise 'no response'
|
|
930
|
+
end
|
|
931
|
+
end
|
|
932
|
+
|
|
933
|
+
content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
|
|
934
|
+
if Utils.match_status_code(http_response.status, ['200'])
|
|
935
|
+
if Utils.match_content_type(content_type, 'application/json')
|
|
936
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
937
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
938
|
+
hook_ctx: hook_ctx
|
|
939
|
+
),
|
|
940
|
+
response: http_response
|
|
941
|
+
)
|
|
942
|
+
response_data = http_response.env.response_body
|
|
943
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Components::InstanceProtect)
|
|
944
|
+
response = Models::Operations::UpdateInstanceProtectResponse.new(
|
|
945
|
+
status_code: http_response.status,
|
|
946
|
+
content_type: content_type,
|
|
947
|
+
raw_response: http_response,
|
|
948
|
+
instance_protect: obj
|
|
949
|
+
)
|
|
950
|
+
|
|
951
|
+
return response
|
|
952
|
+
else
|
|
953
|
+
raise ::Clerk::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
|
|
954
|
+
end
|
|
955
|
+
elsif Utils.match_status_code(http_response.status, ['422'])
|
|
956
|
+
if Utils.match_content_type(content_type, 'application/json')
|
|
957
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
958
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
959
|
+
hook_ctx: hook_ctx
|
|
960
|
+
),
|
|
961
|
+
response: http_response
|
|
962
|
+
)
|
|
963
|
+
response_data = http_response.env.response_body
|
|
964
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ClerkErrors)
|
|
965
|
+
obj.raw_response = http_response
|
|
966
|
+
raise obj
|
|
967
|
+
else
|
|
968
|
+
raise ::Clerk::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
|
|
969
|
+
end
|
|
970
|
+
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
971
|
+
raise ::Clerk::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
|
972
|
+
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
973
|
+
raise ::Clerk::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
|
974
|
+
else
|
|
975
|
+
raise ::Clerk::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown status code received'
|
|
976
|
+
|
|
977
|
+
end
|
|
978
|
+
end
|
|
719
979
|
end
|
|
720
980
|
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
# typed: false
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Clerk
|
|
8
|
+
module Models
|
|
9
|
+
module Components
|
|
10
|
+
|
|
11
|
+
class CommercePriceResponse
|
|
12
|
+
|
|
13
|
+
include Crystalline::MetadataFields
|
|
14
|
+
|
|
15
|
+
# String representing the object's type. Objects of the same type share the same value.
|
|
16
|
+
field :object, Models::Components::CommercePriceResponseObject, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('object'), required: true, 'decoder': Utils.enum_from_string(Models::Components::CommercePriceResponseObject, false) } }
|
|
17
|
+
# Unique identifier for the price.
|
|
18
|
+
field :id, ::String, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('id'), required: true } }
|
|
19
|
+
# Unique identifier for the associated plan.
|
|
20
|
+
field :plan_id, ::String, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('plan_id'), required: true } }
|
|
21
|
+
# Unique identifier for the instance.
|
|
22
|
+
field :instance_id, ::String, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('instance_id'), required: true } }
|
|
23
|
+
# The currency code (e.g., "USD").
|
|
24
|
+
field :currency, ::String, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('currency'), required: true } }
|
|
25
|
+
# The currency symbol (e.g., "$").
|
|
26
|
+
field :currency_symbol, ::String, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('currency_symbol'), required: true } }
|
|
27
|
+
# The amount in cents for the price.
|
|
28
|
+
field :amount, ::Integer, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('amount'), required: true } }
|
|
29
|
+
# The monthly amount in cents when billed annually.
|
|
30
|
+
field :annual_monthly_amount, ::Integer, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('annual_monthly_amount'), required: true } }
|
|
31
|
+
|
|
32
|
+
field :fee, Models::Components::CommerceMoneyResponse, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('fee'), required: true } }
|
|
33
|
+
|
|
34
|
+
field :annual_monthly_fee, Models::Components::CommerceMoneyResponse, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('annual_monthly_fee'), required: true } }
|
|
35
|
+
# Unix timestamp (milliseconds) of creation.
|
|
36
|
+
field :created_at, ::Integer, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('created_at'), required: true } }
|
|
37
|
+
# The description of the price.
|
|
38
|
+
field :description, Crystalline::Nilable.new(::String), { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('description') } }
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def initialize(object:, id:, plan_id:, instance_id:, currency:, currency_symbol:, amount:, annual_monthly_amount:, fee:, annual_monthly_fee:, created_at:, description: nil)
|
|
42
|
+
@object = object
|
|
43
|
+
@id = id
|
|
44
|
+
@plan_id = plan_id
|
|
45
|
+
@instance_id = instance_id
|
|
46
|
+
@currency = currency
|
|
47
|
+
@currency_symbol = currency_symbol
|
|
48
|
+
@amount = amount
|
|
49
|
+
@annual_monthly_amount = annual_monthly_amount
|
|
50
|
+
@fee = fee
|
|
51
|
+
@annual_monthly_fee = annual_monthly_fee
|
|
52
|
+
@created_at = created_at
|
|
53
|
+
@description = description
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def ==(other)
|
|
58
|
+
return false unless other.is_a? self.class
|
|
59
|
+
return false unless @object == other.object
|
|
60
|
+
return false unless @id == other.id
|
|
61
|
+
return false unless @plan_id == other.plan_id
|
|
62
|
+
return false unless @instance_id == other.instance_id
|
|
63
|
+
return false unless @currency == other.currency
|
|
64
|
+
return false unless @currency_symbol == other.currency_symbol
|
|
65
|
+
return false unless @amount == other.amount
|
|
66
|
+
return false unless @annual_monthly_amount == other.annual_monthly_amount
|
|
67
|
+
return false unless @fee == other.fee
|
|
68
|
+
return false unless @annual_monthly_fee == other.annual_monthly_fee
|
|
69
|
+
return false unless @created_at == other.created_at
|
|
70
|
+
return false unless @description == other.description
|
|
71
|
+
true
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# typed: false
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Clerk::Models::Components::CommercePriceResponse
|
|
6
|
+
extend ::Crystalline::MetadataFields::ClassMethods
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Clerk::Models::Components::CommercePriceResponse
|
|
11
|
+
def object(); end
|
|
12
|
+
def object=(str_); end
|
|
13
|
+
def id(); end
|
|
14
|
+
def id=(str_); end
|
|
15
|
+
def plan_id(); end
|
|
16
|
+
def plan_id=(str_); end
|
|
17
|
+
def instance_id(); end
|
|
18
|
+
def instance_id=(str_); end
|
|
19
|
+
def currency(); end
|
|
20
|
+
def currency=(str_); end
|
|
21
|
+
def currency_symbol(); end
|
|
22
|
+
def currency_symbol=(str_); end
|
|
23
|
+
def amount(); end
|
|
24
|
+
def amount=(str_); end
|
|
25
|
+
def annual_monthly_amount(); end
|
|
26
|
+
def annual_monthly_amount=(str_); end
|
|
27
|
+
def fee(); end
|
|
28
|
+
def fee=(str_); end
|
|
29
|
+
def annual_monthly_fee(); end
|
|
30
|
+
def annual_monthly_fee=(str_); end
|
|
31
|
+
def created_at(); end
|
|
32
|
+
def created_at=(str_); end
|
|
33
|
+
def description(); end
|
|
34
|
+
def description=(str_); end
|
|
35
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
# typed: false
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Clerk
|
|
8
|
+
module Models
|
|
9
|
+
module Components
|
|
10
|
+
# CommercePriceResponseObject - String representing the object's type. Objects of the same type share the same value.
|
|
11
|
+
class CommercePriceResponseObject
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
include ::Crystalline::Enum
|
|
15
|
+
|
|
16
|
+
enums do
|
|
17
|
+
COMMERCE_PRICE = new('commerce_price')
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
# typed: false
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Clerk
|
|
8
|
+
module Models
|
|
9
|
+
module Components
|
|
10
|
+
|
|
11
|
+
class CommercePriceTransitionDetails
|
|
12
|
+
|
|
13
|
+
include Crystalline::MetadataFields
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
field :previous_plan, Models::Components::SchemasCommercePlan, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('previous_plan'), required: true } }
|
|
17
|
+
|
|
18
|
+
field :previous_price, Models::Components::CommercePriceResponse, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('previous_price'), required: true } }
|
|
19
|
+
# Unix timestamp (milliseconds) when the new price takes effect.
|
|
20
|
+
field :effective_at, ::Integer, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('effective_at'), required: true } }
|
|
21
|
+
# When the new price takes effect.
|
|
22
|
+
field :effective_mode, Models::Components::EffectiveMode, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('effective_mode'), required: true, 'decoder': Utils.enum_from_string(Models::Components::EffectiveMode, false) } }
|
|
23
|
+
# Whether an immediate charge was made.
|
|
24
|
+
field :charged_immediately, Crystalline::Boolean.new, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('charged_immediately'), required: true } }
|
|
25
|
+
# The status of the previous subscription item after transition.
|
|
26
|
+
field :previous_subscription_item_status, Models::Components::PreviousSubscriptionItemStatus, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('previous_subscription_item_status'), required: true, 'decoder': Utils.enum_from_string(Models::Components::PreviousSubscriptionItemStatus, false) } }
|
|
27
|
+
# The ID of the previous subscription item.
|
|
28
|
+
field :previous_subscription_item_id, ::String, { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('previous_subscription_item_id'), required: true } }
|
|
29
|
+
# Unix timestamp (milliseconds) for the next billing date.
|
|
30
|
+
field :next_billing_date, Crystalline::Nilable.new(::Integer), { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('next_billing_date') } }
|
|
31
|
+
# Amount charged immediately, if any.
|
|
32
|
+
field :immediate_charge, Crystalline::Nilable.new(Models::Components::ImmediateCharge), { 'format_json': { 'letter_case': ::Clerk::Utils.field_name('immediate_charge') } }
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def initialize(previous_plan:, previous_price:, effective_at:, effective_mode:, charged_immediately:, previous_subscription_item_status:, previous_subscription_item_id:, next_billing_date: nil, immediate_charge: nil)
|
|
36
|
+
@previous_plan = previous_plan
|
|
37
|
+
@previous_price = previous_price
|
|
38
|
+
@effective_at = effective_at
|
|
39
|
+
@effective_mode = effective_mode
|
|
40
|
+
@charged_immediately = charged_immediately
|
|
41
|
+
@previous_subscription_item_status = previous_subscription_item_status
|
|
42
|
+
@previous_subscription_item_id = previous_subscription_item_id
|
|
43
|
+
@next_billing_date = next_billing_date
|
|
44
|
+
@immediate_charge = immediate_charge
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def ==(other)
|
|
49
|
+
return false unless other.is_a? self.class
|
|
50
|
+
return false unless @previous_plan == other.previous_plan
|
|
51
|
+
return false unless @previous_price == other.previous_price
|
|
52
|
+
return false unless @effective_at == other.effective_at
|
|
53
|
+
return false unless @effective_mode == other.effective_mode
|
|
54
|
+
return false unless @charged_immediately == other.charged_immediately
|
|
55
|
+
return false unless @previous_subscription_item_status == other.previous_subscription_item_status
|
|
56
|
+
return false unless @previous_subscription_item_id == other.previous_subscription_item_id
|
|
57
|
+
return false unless @next_billing_date == other.next_billing_date
|
|
58
|
+
return false unless @immediate_charge == other.immediate_charge
|
|
59
|
+
true
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|