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
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/schematic/scheduledcheckout/client.rb', line 80 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
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/schematic/scheduledcheckout/client.rb', line 116 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
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/schematic/scheduledcheckout/client.rb', line 34 def list_scheduled_checkouts(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) 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) 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
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/schematic/scheduledcheckout/client.rb', line 151 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 = %w[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 |