Class: Square::TerminalApi
- Defined in:
- lib/square/api/terminal_api.rb
Overview
TerminalApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#cancel_terminal_action(action_id:) ⇒ CancelTerminalActionResponse Hash
Cancels a Terminal action request if the status of the request permits it.
-
#cancel_terminal_checkout(checkout_id:) ⇒ CancelTerminalCheckoutResponse Hash
Cancels a Terminal checkout request if the status of the request permits it.
-
#cancel_terminal_refund(terminal_refund_id:) ⇒ CancelTerminalRefundResponse Hash
Cancels an Interac Terminal refund request by refund request ID if the status of the request permits it.
-
#create_terminal_action(body:) ⇒ CreateTerminalActionResponse Hash
Creates a Terminal action request and sends it to the specified device to take a payment for the requested amount.
-
#create_terminal_checkout(body:) ⇒ CreateTerminalCheckoutResponse Hash
Creates a Terminal checkout request and sends it to the specified device to take a payment for the requested amount.
-
#create_terminal_refund(body:) ⇒ CreateTerminalRefundResponse Hash
Creates a request to refund an Interac payment completed on a Square Terminal.
-
#get_terminal_action(action_id:) ⇒ GetTerminalActionResponse Hash
Retrieves a Terminal action request by ‘action_id`.
-
#get_terminal_checkout(checkout_id:) ⇒ GetTerminalCheckoutResponse Hash
Retrieves a Terminal checkout request by ‘checkout_id`.
-
#get_terminal_refund(terminal_refund_id:) ⇒ GetTerminalRefundResponse Hash
Retrieves an Interac Terminal refund object by ID.
-
#initialize(config, http_call_back: nil) ⇒ TerminalApi
constructor
A new instance of TerminalApi.
-
#search_terminal_actions(body:) ⇒ SearchTerminalActionsResponse Hash
Retrieves a filtered list of Terminal action requests created by the account making the request.
-
#search_terminal_checkouts(body:) ⇒ SearchTerminalCheckoutsResponse Hash
Returns a filtered list of Terminal checkout requests created by the application making the request.
-
#search_terminal_refunds(body:) ⇒ SearchTerminalRefundsResponse Hash
Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request.
Methods inherited from BaseApi
#execute_request, #get_user_agent, #validate_parameters
Constructor Details
#initialize(config, http_call_back: nil) ⇒ TerminalApi
Returns a new instance of TerminalApi.
4 5 6 |
# File 'lib/square/api/terminal_api.rb', line 4 def initialize(config, http_call_back: nil) super(config, http_call_back: http_call_back) end |
Instance Method Details
#cancel_terminal_action(action_id:) ⇒ CancelTerminalActionResponse Hash
Cancels a Terminal action request if the status of the request permits it. ‘TerminalAction`
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/square/api/terminal_api.rb', line 120 def cancel_terminal_action(action_id:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/terminals/actions/{action_id}/cancel' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'action_id' => { 'value' => action_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#cancel_terminal_checkout(checkout_id:) ⇒ CancelTerminalCheckoutResponse Hash
Cancels a Terminal checkout request if the status of the request permits it. desired ‘TerminalCheckout`.
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/square/api/terminal_api.rb', line 265 def cancel_terminal_checkout(checkout_id:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/terminals/checkouts/{checkout_id}/cancel' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'checkout_id' => { 'value' => checkout_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#cancel_terminal_refund(terminal_refund_id:) ⇒ CancelTerminalRefundResponse Hash
Cancels an Interac Terminal refund request by refund request ID if the status of the request permits it. the desired ‘TerminalRefund`.
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
# File 'lib/square/api/terminal_api.rb', line 411 def cancel_terminal_refund(terminal_refund_id:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/terminals/refunds/{terminal_refund_id}/cancel' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'terminal_refund_id' => { 'value' => terminal_refund_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#create_terminal_action(body:) ⇒ CreateTerminalActionResponse Hash
Creates a Terminal action request and sends it to the specified device to take a payment for the requested amount. containing the fields to POST for the request. See the corresponding object definition for field details.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/square/api/terminal_api.rb', line 15 def create_terminal_action(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/terminals/actions' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#create_terminal_checkout(body:) ⇒ CreateTerminalCheckoutResponse Hash
Creates a Terminal checkout request and sends it to the specified device to take a payment for the requested amount. containing the fields to POST for the request. See the corresponding object definition for field details.
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/square/api/terminal_api.rb', line 158 def create_terminal_checkout(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/terminals/checkouts' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#create_terminal_refund(body:) ⇒ CreateTerminalRefundResponse Hash
Creates a request to refund an Interac payment completed on a Square Terminal. Refunds for Interac payments on a Square Terminal are supported only for Interac debit cards in Canada. Other refunds for Terminal payments should use the Refunds API. For more information, see [Refunds API]($e/Refunds). containing the fields to POST for the request. See the corresponding object definition for field details.
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'lib/square/api/terminal_api.rb', line 305 def create_terminal_refund(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/terminals/refunds' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#get_terminal_action(action_id:) ⇒ GetTerminalActionResponse Hash
Retrieves a Terminal action request by ‘action_id`. Terminal action requests are available for 30 days. `TerminalAction`
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/square/api/terminal_api.rb', line 85 def get_terminal_action(action_id:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/terminals/actions/{action_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'action_id' => { 'value' => action_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#get_terminal_checkout(checkout_id:) ⇒ GetTerminalCheckoutResponse Hash
Retrieves a Terminal checkout request by ‘checkout_id`. Terminal checkout requests are available for 30 days. desired `TerminalCheckout`.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/square/api/terminal_api.rb', line 229 def get_terminal_checkout(checkout_id:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/terminals/checkouts/{checkout_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'checkout_id' => { 'value' => checkout_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#get_terminal_refund(terminal_refund_id:) ⇒ GetTerminalRefundResponse Hash
Retrieves an Interac Terminal refund object by ID. Terminal refund objects are available for 30 days. the desired ‘TerminalRefund`.
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/square/api/terminal_api.rb', line 375 def get_terminal_refund(terminal_refund_id:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/terminals/refunds/{terminal_refund_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'terminal_refund_id' => { 'value' => terminal_refund_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#search_terminal_actions(body:) ⇒ SearchTerminalActionsResponse Hash
Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days. containing the fields to POST for the request. See the corresponding object definition for field details.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/square/api/terminal_api.rb', line 51 def search_terminal_actions(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/terminals/actions/search' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#search_terminal_checkouts(body:) ⇒ SearchTerminalCheckoutsResponse Hash
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. containing the fields to POST for the request. See the corresponding object definition for field details.
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/square/api/terminal_api.rb', line 195 def search_terminal_checkouts(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/terminals/checkouts/search' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#search_terminal_refunds(body:) ⇒ SearchTerminalRefundsResponse Hash
Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days. containing the fields to POST for the request. See the corresponding object definition for field details.
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
# File 'lib/square/api/terminal_api.rb', line 341 def search_terminal_refunds(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/terminals/refunds/search' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |