Class: Schematic::Checkout::Client
- Inherits:
-
Object
- Object
- Schematic::Checkout::Client
- Defined in:
- lib/schematic/checkout/client.rb
Instance Method Summary collapse
- #cancel_subscription(request_options: {}, **params) ⇒ Schematic::Checkout::Types::CancelSubscriptionResponse
- #get_checkout_data(request_options: {}, **params) ⇒ Schematic::Checkout::Types::GetCheckoutDataResponse
- #initialize(client:) ⇒ void constructor
- #internal(request_options: {}, **params) ⇒ Schematic::Checkout::Types::CheckoutInternalResponse
- #manage_plan(request_options: {}, **params) ⇒ Schematic::Checkout::Types::ManagePlanResponse
- #preview_checkout_internal(request_options: {}, **params) ⇒ Schematic::Checkout::Types::PreviewCheckoutInternalResponse
- #preview_manage_plan(request_options: {}, **params) ⇒ Schematic::Checkout::Types::PreviewManagePlanResponse
- #update_customer_subscription_trial_end(request_options: {}, **params) ⇒ Schematic::Checkout::Types::UpdateCustomerSubscriptionTrialEndResponse
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/schematic/checkout/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#cancel_subscription(request_options: {}, **params) ⇒ Schematic::Checkout::Types::CancelSubscriptionResponse
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/schematic/checkout/client.rb', line 182 def cancel_subscription(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "manage-plan/subscription/cancel", body: Schematic::Checkout::Types::CancelSubscriptionRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Checkout::Types::CancelSubscriptionResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_checkout_data(request_options: {}, **params) ⇒ Schematic::Checkout::Types::GetCheckoutDataResponse
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/schematic/checkout/client.rb', line 54 def get_checkout_data(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "checkout-internal/data", body: Schematic::Checkout::Types::CheckoutDataRequestBody.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Checkout::Types::GetCheckoutDataResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#internal(request_options: {}, **params) ⇒ Schematic::Checkout::Types::CheckoutInternalResponse
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/schematic/checkout/client.rb', line 22 def internal(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "checkout-internal", body: Schematic::Types::ChangeSubscriptionInternalRequestBody.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Checkout::Types::CheckoutInternalResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#manage_plan(request_options: {}, **params) ⇒ Schematic::Checkout::Types::ManagePlanResponse
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/schematic/checkout/client.rb', line 118 def manage_plan(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "manage-plan", body: Schematic::Types::ManagePlanRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Checkout::Types::ManagePlanResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#preview_checkout_internal(request_options: {}, **params) ⇒ Schematic::Checkout::Types::PreviewCheckoutInternalResponse
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/schematic/checkout/client.rb', line 86 def preview_checkout_internal(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "checkout-internal/preview", body: Schematic::Types::ChangeSubscriptionInternalRequestBody.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Checkout::Types::PreviewCheckoutInternalResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#preview_manage_plan(request_options: {}, **params) ⇒ Schematic::Checkout::Types::PreviewManagePlanResponse
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/schematic/checkout/client.rb', line 150 def preview_manage_plan(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "manage-plan/preview", body: Schematic::Types::ManagePlanRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Checkout::Types::PreviewManagePlanResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update_customer_subscription_trial_end(request_options: {}, **params) ⇒ Schematic::Checkout::Types::UpdateCustomerSubscriptionTrialEndResponse
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/schematic/checkout/client.rb', line 215 def update_customer_subscription_trial_end(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request_data = Schematic::Checkout::Types::UpdateTrialEndRequestBody.new(params).to_h non_body_param_names = ["subscription_id"] body = request_data.except(*non_body_param_names) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "subscription/#{URI.encode_uri_component(params[:subscription_id].to_s)}/edit-trial-end", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Checkout::Types::UpdateCustomerSubscriptionTrialEndResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |