Class: Square::MobileAuthorizationApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/square/api/mobile_authorization_api.rb

Overview

MobileAuthorizationApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from Square::BaseApi

Instance Method Details

#create_mobile_authorization_code(body:) ⇒ CreateMobileAuthorizationCodeResponse Hash

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. Important: 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 ). object containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (CreateMobileAuthorizationCodeRequest)

    Required parameter: An

Returns:

  • (CreateMobileAuthorizationCodeResponse Hash)

    response from the API call



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/square/api/mobile_authorization_api.rb', line 21

def create_mobile_authorization_code(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/mobile/authorization-code',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end