UNPKG

square-connect

Version:

JavaScript client library for the Square Connect v2 API

468 lines (392 loc) 17.5 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 CancelTerminalCheckoutResponse = require('../model/CancelTerminalCheckoutResponse'); var CancelTerminalRefundResponse = require('../model/CancelTerminalRefundResponse'); var CreateTerminalCheckoutRequest = require('../model/CreateTerminalCheckoutRequest'); var CreateTerminalCheckoutResponse = require('../model/CreateTerminalCheckoutResponse'); var CreateTerminalRefundRequest = require('../model/CreateTerminalRefundRequest'); var CreateTerminalRefundResponse = require('../model/CreateTerminalRefundResponse'); var GetTerminalCheckoutResponse = require('../model/GetTerminalCheckoutResponse'); var GetTerminalRefundResponse = require('../model/GetTerminalRefundResponse'); var SearchTerminalCheckoutsRequest = require('../model/SearchTerminalCheckoutsRequest'); var SearchTerminalCheckoutsResponse = require('../model/SearchTerminalCheckoutsResponse'); var SearchTerminalRefundsRequest = require('../model/SearchTerminalRefundsRequest'); var SearchTerminalRefundsResponse = require('../model/SearchTerminalRefundsResponse'); /** * Terminal service. * @module api/TerminalApi */ /** * Constructs a new TerminalApi. * @alias module:api/TerminalApi * @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; /** * CancelTerminalCheckout * Cancels a Terminal checkout request if the status of the request permits it. * @param {String} checkoutId Unique ID for the desired `TerminalCheckout` * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/CancelTerminalCheckoutResponse} and HTTP response */ this.cancelTerminalCheckoutWithHttpInfo = function(checkoutId) { var postBody = null; // verify the required parameter 'checkoutId' is set if (checkoutId === undefined || checkoutId === null) { throw new Error("Missing the required parameter 'checkoutId' when calling cancelTerminalCheckout"); } var pathParams = { 'checkout_id': checkoutId }; 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 = CancelTerminalCheckoutResponse; return this.apiClient.callApi( '/v2/terminals/checkouts/{checkout_id}/cancel', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * CancelTerminalCheckout * Cancels a Terminal checkout request if the status of the request permits it. * @param {String} checkoutId Unique ID for the desired `TerminalCheckout` * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/CancelTerminalCheckoutResponse} */ this.cancelTerminalCheckout = function(checkoutId) { return this.cancelTerminalCheckoutWithHttpInfo(checkoutId) .then(function(response_and_data) { return response_and_data.data; }); } /** * CancelTerminalRefund * Note: This endpoint is in beta. * Cancels an Interac terminal refund request by refund request ID if the status of the request permits it. * @param {String} terminalRefundId Unique ID for the desired `TerminalRefund` * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/CancelTerminalRefundResponse} and HTTP response */ this.cancelTerminalRefundWithHttpInfo = function(terminalRefundId) { var postBody = null; // verify the required parameter 'terminalRefundId' is set if (terminalRefundId === undefined || terminalRefundId === null) { throw new Error("Missing the required parameter 'terminalRefundId' when calling cancelTerminalRefund"); } var pathParams = { 'terminal_refund_id': terminalRefundId }; 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 = CancelTerminalRefundResponse; return this.apiClient.callApi( '/v2/terminals/refunds/{terminal_refund_id}/cancel', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * CancelTerminalRefund * Cancels an Interac terminal refund request by refund request ID if the status of the request permits it. * @param {String} terminalRefundId Unique ID for the desired `TerminalRefund` * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/CancelTerminalRefundResponse} */ this.cancelTerminalRefund = function(terminalRefundId) { return this.cancelTerminalRefundWithHttpInfo(terminalRefundId) .then(function(response_and_data) { return response_and_data.data; }); } /** * CreateTerminalCheckout * Creates a new Terminal checkout request and sends it to the specified device to take a payment for the requested amount. * @param {module:model/CreateTerminalCheckoutRequest} 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/CreateTerminalCheckoutResponse} and HTTP response */ this.createTerminalCheckoutWithHttpInfo = 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 createTerminalCheckout"); } 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 = CreateTerminalCheckoutResponse; return this.apiClient.callApi( '/v2/terminals/checkouts', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * CreateTerminalCheckout * Creates a new Terminal checkout request and sends it to the specified device to take a payment for the requested amount. * @param {module:model/CreateTerminalCheckoutRequest} 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/CreateTerminalCheckoutResponse} */ this.createTerminalCheckout = function(body) { return this.createTerminalCheckoutWithHttpInfo(body) .then(function(response_and_data) { return response_and_data.data; }); } /** * CreateTerminalRefund * Note: This endpoint is in beta. * Creates a request to refund an Interac payment completed on a Square Terminal. * @param {module:model/CreateTerminalRefundRequest} 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/CreateTerminalRefundResponse} and HTTP response */ this.createTerminalRefundWithHttpInfo = 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 createTerminalRefund"); } 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 = CreateTerminalRefundResponse; return this.apiClient.callApi( '/v2/terminals/refunds', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * CreateTerminalRefund * Creates a request to refund an Interac payment completed on a Square Terminal. * @param {module:model/CreateTerminalRefundRequest} 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/CreateTerminalRefundResponse} */ this.createTerminalRefund = function(body) { return this.createTerminalRefundWithHttpInfo(body) .then(function(response_and_data) { return response_and_data.data; }); } /** * GetTerminalCheckout * Retrieves a Terminal checkout request by checkout_id. * @param {String} checkoutId Unique ID for the desired `TerminalCheckout` * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GetTerminalCheckoutResponse} and HTTP response */ this.getTerminalCheckoutWithHttpInfo = function(checkoutId) { var postBody = null; // verify the required parameter 'checkoutId' is set if (checkoutId === undefined || checkoutId === null) { throw new Error("Missing the required parameter 'checkoutId' when calling getTerminalCheckout"); } var pathParams = { 'checkout_id': checkoutId }; 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 = GetTerminalCheckoutResponse; return this.apiClient.callApi( '/v2/terminals/checkouts/{checkout_id}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * GetTerminalCheckout * Retrieves a Terminal checkout request by checkout_id. * @param {String} checkoutId Unique ID for the desired `TerminalCheckout` * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GetTerminalCheckoutResponse} */ this.getTerminalCheckout = function(checkoutId) { return this.getTerminalCheckoutWithHttpInfo(checkoutId) .then(function(response_and_data) { return response_and_data.data; }); } /** * GetTerminalRefund * Note: This endpoint is in beta. * Retrieves an Interac terminal refund object by ID. * @param {String} terminalRefundId Unique ID for the desired `TerminalRefund` * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GetTerminalRefundResponse} and HTTP response */ this.getTerminalRefundWithHttpInfo = function(terminalRefundId) { var postBody = null; // verify the required parameter 'terminalRefundId' is set if (terminalRefundId === undefined || terminalRefundId === null) { throw new Error("Missing the required parameter 'terminalRefundId' when calling getTerminalRefund"); } var pathParams = { 'terminal_refund_id': terminalRefundId }; 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 = GetTerminalRefundResponse; return this.apiClient.callApi( '/v2/terminals/refunds/{terminal_refund_id}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * GetTerminalRefund * Retrieves an Interac terminal refund object by ID. * @param {String} terminalRefundId Unique ID for the desired `TerminalRefund` * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GetTerminalRefundResponse} */ this.getTerminalRefund = function(terminalRefundId) { return this.getTerminalRefundWithHttpInfo(terminalRefundId) .then(function(response_and_data) { return response_and_data.data; }); } /** * SearchTerminalCheckouts * Retrieves a filtered list of Terminal checkout requests created by the account making the request. * @param {module:model/SearchTerminalCheckoutsRequest} 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/SearchTerminalCheckoutsResponse} and HTTP response */ this.searchTerminalCheckoutsWithHttpInfo = 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 searchTerminalCheckouts"); } 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 = SearchTerminalCheckoutsResponse; return this.apiClient.callApi( '/v2/terminals/checkouts/search', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * SearchTerminalCheckouts * Retrieves a filtered list of Terminal checkout requests created by the account making the request. * @param {module:model/SearchTerminalCheckoutsRequest} 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/SearchTerminalCheckoutsResponse} */ this.searchTerminalCheckouts = function(body) { return this.searchTerminalCheckoutsWithHttpInfo(body) .then(function(response_and_data) { return response_and_data.data; }); } /** * SearchTerminalRefunds * Note: This endpoint is in beta. * Retrieves a filtered list of Terminal Interac refund requests created by the seller making the request. * @param {module:model/SearchTerminalRefundsRequest} 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/SearchTerminalRefundsResponse} and HTTP response */ this.searchTerminalRefundsWithHttpInfo = 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 searchTerminalRefunds"); } 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 = SearchTerminalRefundsResponse; return this.apiClient.callApi( '/v2/terminals/refunds/search', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * SearchTerminalRefunds * Retrieves a filtered list of Terminal Interac refund requests created by the seller making the request. * @param {module:model/SearchTerminalRefundsRequest} 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/SearchTerminalRefundsResponse} */ this.searchTerminalRefunds = function(body) { return this.searchTerminalRefundsWithHttpInfo(body) .then(function(response_and_data) { return response_and_data.data; }); } };