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:) ⇒ Square::Terminal::Checkouts::Client 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:) ⇒ Square::Terminal::Checkouts::Client
8 9 10 |
# File 'lib/square/terminal/checkouts/client.rb', line 8 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.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/square/terminal/checkouts/client.rb', line 87 def cancel(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/terminals/checkouts/#{params[:checkout_id]}/cancel" ) 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.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/square/terminal/checkouts/client.rb', line 16 def create(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/terminals/checkouts", body: params ) 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.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/square/terminal/checkouts/client.rb', line 64 def get(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/terminals/checkouts/#{params[:checkout_id]}" ) 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.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/square/terminal/checkouts/client.rb', line 40 def search(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/terminals/checkouts/search", body: params ) 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 |