Class: Square::Mobile::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Square::Mobile::Client



7
8
9
# File 'lib/square/mobile/client.rb', line 7

def initialize(client:)
  @client = client
end

Instance Method Details

#authorization_code(request_options: {}, **params) ⇒ Square::Types::CreateMobileAuthorizationCodeResponse

Note: This endpoint is used by the deprecated Reader SDK. Developers should update their integration to use the [Mobile Payments SDK](developer.squareup.com/docs/mobile-payments-sdk), which includes its own authorization methods.

Generates code to authorize a mobile application to connect to a Square card reader.

Authorization codes are one-time-use codes and expire 60 minutes after being issued.

The ‘Authorization` header you provide to this endpoint must have the following format:

“‘ Authorization: Bearer ACCESS_TOKEN “`

Replace ‘ACCESS_TOKEN` with a [valid production authorization credential](developer.squareup.com/docs/build-basics/access-tokens).



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/square/mobile/client.rb', line 28

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

  raise _response.body
end