UNPKG

square-connect

Version:

JavaScript client library for the Square Connect v2 API

86 lines (73 loc) 3.86 kB
/** * Square Connect API * Client library for accessing the Square Connect APIs * * OpenAPI spec version: 2.0 * Contact: developers@squareup.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * * Swagger Codegen version: 2.3.0-SNAPSHOT * */ var ApiClient = require('../ApiClient'); var CreateMobileAuthorizationCodeRequest = require('../model/CreateMobileAuthorizationCodeRequest'); var CreateMobileAuthorizationCodeResponse = require('../model/CreateMobileAuthorizationCodeResponse'); /** * MobileAuthorization service. * @module api/MobileAuthorizationApi */ /** * Constructs a new MobileAuthorizationApi. * @alias module:api/MobileAuthorizationApi * @class * @param {module:ApiClient} apiClient Optional API client implementation to use, * default to {@link module:ApiClient#instance} if unspecified. */ module.exports = function(apiClient) { this.apiClient = apiClient || ApiClient.instance; /** * CreateMobileAuthorizationCode * Generates code to authorize a mobile application to connect to a Square card reader Authorization codes are one-time-use 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](/docs/build-basics/access-tokens). * @param {module:model/CreateMobileAuthorizationCodeRequest} body An object containing the fields to POST for the request. See the corresponding object definition for field details. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/CreateMobileAuthorizationCodeResponse} and HTTP response */ this.createMobileAuthorizationCodeWithHttpInfo = function(body) { var postBody = body; // verify the required parameter 'body' is set if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling createMobileAuthorizationCode"); } var pathParams = { }; var queryParams = { }; var headerParams = { }; headerParams['Square-Version'] = '2020-12-16'; var formParams = { }; var authNames = ['oauth2']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = CreateMobileAuthorizationCodeResponse; return this.apiClient.callApi( '/mobile/authorization-code', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * CreateMobileAuthorizationCode * Generates code to authorize a mobile application to connect to a Square card reader Authorization codes are one-time-use 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](/docs/build-basics/access-tokens). * @param {module:model/CreateMobileAuthorizationCodeRequest} body An object containing the fields to POST for the request. See the corresponding object definition for field details. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/CreateMobileAuthorizationCodeResponse} */ this.createMobileAuthorizationCode = function(body) { return this.createMobileAuthorizationCodeWithHttpInfo(body) .then(function(response_and_data) { return response_and_data.data; }); } };