Class: Square::Terminal::Checkouts::Client
- Inherits:
-
Object
- Object
- Square::Terminal::Checkouts::Client
- Defined in:
- lib/square/terminal/checkouts/client.rb
Instance Method Summary collapse
-
#cancel(request_options: {}, **params) ⇒ Square::Types::CancelTerminalCheckoutResponse
Cancels a Terminal checkout request if the status of the request permits it.
-
#create(request_options: {}, **params) ⇒ Square::Types::CreateTerminalCheckoutResponse
Creates a Terminal checkout request and sends it to the specified device to take a payment for the requested amount.
-
#get(request_options: {}, **params) ⇒ Square::Types::GetTerminalCheckoutResponse
Retrieves a Terminal checkout request by ‘checkout_id`.
- #initialize(client:) ⇒ void constructor
-
#search(request_options: {}, **params) ⇒ Square::Types::SearchTerminalCheckoutsResponse
Returns a filtered list of Terminal checkout requests created by the application making the request.
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/square/terminal/checkouts/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#cancel(request_options: {}, **params) ⇒ Square::Types::CancelTerminalCheckoutResponse
Cancels a Terminal checkout request if the status of the request permits it.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/square/terminal/checkouts/client.rb', line 131 def cancel(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/terminals/checkouts/#{params[:checkout_id]}/cancel", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::CancelTerminalCheckoutResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#create(request_options: {}, **params) ⇒ Square::Types::CreateTerminalCheckoutResponse
Creates a Terminal checkout request and sends it to the specified device to take a payment for the requested amount.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/square/terminal/checkouts/client.rb', line 26 def create(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/terminals/checkouts", body: Square::Terminal::Checkouts::Types::CreateTerminalCheckoutRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::CreateTerminalCheckoutResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get(request_options: {}, **params) ⇒ Square::Types::GetTerminalCheckoutResponse
Retrieves a Terminal checkout request by ‘checkout_id`. Terminal checkout requests are available for 30 days.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/square/terminal/checkouts/client.rb', line 97 def get(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/terminals/checkouts/#{params[:checkout_id]}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::GetTerminalCheckoutResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#search(request_options: {}, **params) ⇒ Square::Types::SearchTerminalCheckoutsResponse
Returns a filtered list of Terminal checkout requests created by the application making the request. Only Terminal checkout requests created for the merchant scoped to the OAuth token are returned. Terminal checkout requests are available for 30 days.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/square/terminal/checkouts/client.rb', line 62 def search(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/terminals/checkouts/search", body: Square::Terminal::Checkouts::Types::SearchTerminalCheckoutsRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::SearchTerminalCheckoutsResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |