Class: Square::Terminal::Checkouts::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/square/terminal/checkouts/client.rb

Instance Method Summary collapse

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.



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/square/terminal/checkouts/client.rb', line 69

def cancel(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/terminals/checkouts/#{params[:checkout_id]}/cancel"
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::CancelTerminalCheckoutResponse.load(_response.body)
  end

  raise _response.body
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
# File 'lib/square/terminal/checkouts/client.rb', line 16

def create(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/terminals/checkouts",
    body: params
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::CreateTerminalCheckoutResponse.load(_response.body)
  end

  raise _response.body
end

#get(request_options: {}, **params) ⇒ Square::Types::GetTerminalCheckoutResponse

Retrieves a Terminal checkout request by ‘checkout_id`. Terminal checkout requests are available for 30 days.



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/square/terminal/checkouts/client.rb', line 52

def get(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "GET",
    path: "v2/terminals/checkouts/#{params[:checkout_id]}"
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::GetTerminalCheckoutResponse.load(_response.body)
  end

  raise _response.body
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.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/square/terminal/checkouts/client.rb', line 34

def search(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/terminals/checkouts/search",
    body: params
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::SearchTerminalCheckoutsResponse.load(_response.body)
  end

  raise _response.body
end