Class: Square::Mobile::Client
- Inherits:
-
Object
- Object
- Square::Mobile::Client
- Defined in:
- lib/square/mobile/client.rb
Instance Method Summary collapse
-
#authorization_code(request_options: {}, **params) ⇒ Square::Types::CreateMobileAuthorizationCodeResponse
Note: This endpoint is used by the deprecated Reader SDK.
- #initialize(client:) ⇒ Square::Mobile::Client constructor
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 42 43 44 45 46 47 |
# File 'lib/square/mobile/client.rb', line 28 def (request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "mobile/authorization-code", 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::CreateMobileAuthorizationCodeResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |