Class: Schematic::Scheduledcheckout::Client
- Inherits:
-
Object
- Object
- Schematic::Scheduledcheckout::Client
- Defined in:
- lib/schematic/scheduledcheckout/client.rb
Instance Method Summary collapse
- #create_scheduled_checkout(request_options: {}, **params) ⇒ Schematic::Scheduledcheckout::Types::CreateScheduledCheckoutResponse
- #get_scheduled_checkout(request_options: {}, **params) ⇒ Schematic::Scheduledcheckout::Types::GetScheduledCheckoutResponse
- #initialize(client:) ⇒ void constructor
- #list_scheduled_checkouts(request_options: {}, **params) ⇒ Schematic::Scheduledcheckout::Types::ListScheduledCheckoutsResponse
- #update_scheduled_checkout(request_options: {}, **params) ⇒ Schematic::Scheduledcheckout::Types::UpdateScheduledCheckoutResponse
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/schematic/scheduledcheckout/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create_scheduled_checkout(request_options: {}, **params) ⇒ Schematic::Scheduledcheckout::Types::CreateScheduledCheckoutResponse
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/schematic/scheduledcheckout/client.rb', line 66 def create_scheduled_checkout(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "scheduled-checkout", body: Schematic::Scheduledcheckout::Types::CreateScheduledCheckoutRequest.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::Scheduledcheckout::Types::CreateScheduledCheckoutResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_scheduled_checkout(request_options: {}, **params) ⇒ Schematic::Scheduledcheckout::Types::GetScheduledCheckoutResponse
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/schematic/scheduledcheckout/client.rb', line 99 def get_scheduled_checkout(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "scheduled-checkout/#{URI.encode_uri_component(params[:scheduled_checkout_id].to_s)}", 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::Scheduledcheckout::Types::GetScheduledCheckoutResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_scheduled_checkouts(request_options: {}, **params) ⇒ Schematic::Scheduledcheckout::Types::ListScheduledCheckoutsResponse
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/schematic/scheduledcheckout/client.rb', line 26 def list_scheduled_checkouts(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[company_id status limit offset] query_params = {} query_params["company_id"] = params[:company_id] if params.key?(:company_id) query_params["status"] = params[:status] if params.key?(:status) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["offset"] = params[:offset] if params.key?(:offset) params.except(*query_param_names) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "scheduled-checkout", query: query_params, 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::Scheduledcheckout::Types::ListScheduledCheckoutsResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update_scheduled_checkout(request_options: {}, **params) ⇒ Schematic::Scheduledcheckout::Types::UpdateScheduledCheckoutResponse
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/schematic/scheduledcheckout/client.rb', line 131 def update_scheduled_checkout(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request_data = Schematic::Scheduledcheckout::Types::UpdateScheduledCheckoutRequest.new(params).to_h non_body_param_names = ["scheduled_checkout_id"] body = request_data.except(*non_body_param_names) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "scheduled-checkout/#{URI.encode_uri_component(params[:scheduled_checkout_id].to_s)}", 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::Scheduledcheckout::Types::UpdateScheduledCheckoutResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |