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
- #get_company_billing_details(request_options: {}, **params) ⇒ Schematic::Checkout::Types::GetCompanyBillingDetailsResponse
- #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_company_billing_details(request_options: {}, **params) ⇒ Schematic::Checkout::Types::UpdateCompanyBillingDetailsResponse
- #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
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
# File 'lib/schematic/checkout/client.rb', line 363 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
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/schematic/checkout/client.rb', line 84 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 |
#get_company_billing_details(request_options: {}, **params) ⇒ Schematic::Checkout::Types::GetCompanyBillingDetailsResponse
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/schematic/checkout/client.rb', line 179 def get_company_billing_details(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "companies/#{URI.encode_uri_component(params[:company_id].to_s)}/billing-details", 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::GetCompanyBillingDetailsResponse.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
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/schematic/checkout/client.rb', line 49 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
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/schematic/checkout/client.rb', line 276 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
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/schematic/checkout/client.rb', line 143 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
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/schematic/checkout/client.rb', line 328 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_company_billing_details(request_options: {}, **params) ⇒ Schematic::Checkout::Types::UpdateCompanyBillingDetailsResponse
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/schematic/checkout/client.rb', line 220 def update_company_billing_details(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request_data = Schematic::Checkout::Types::UpdateCompanyBillingDetailsRequestBody.new(params).to_h non_body_param_names = %w[company_id] body = request_data.except(*non_body_param_names) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "companies/#{URI.encode_uri_component(params[:company_id].to_s)}/billing-details", 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::UpdateCompanyBillingDetailsResponse.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
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/schematic/checkout/client.rb', line 399 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 = %w[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 |