square-connect
Version:
JavaScript client library for the Square Connect v2 API
198 lines (168 loc) • 8.28 kB
JavaScript
/**
* 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 GetBankAccountByV1IdResponse = require('../model/GetBankAccountByV1IdResponse');
var GetBankAccountResponse = require('../model/GetBankAccountResponse');
var ListBankAccountsResponse = require('../model/ListBankAccountsResponse');
/**
* BankAccounts service.
* @module api/BankAccountsApi
*/
/**
* Constructs a new BankAccountsApi.
* @alias module:api/BankAccountsApi
* @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;
/**
* GetBankAccount
* Returns details of a [BankAccount](#type-bankaccount) linked to a Square account.
* @param {String} bankAccountId Square-issued ID of the desired `BankAccount`.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GetBankAccountResponse} and HTTP response
*/
this.getBankAccountWithHttpInfo = function(bankAccountId) {
var postBody = null;
// verify the required parameter 'bankAccountId' is set
if (bankAccountId === undefined || bankAccountId === null) {
throw new Error("Missing the required parameter 'bankAccountId' when calling getBankAccount");
}
var pathParams = {
'bank_account_id': bankAccountId
};
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 = GetBankAccountResponse;
return this.apiClient.callApi(
'/v2/bank-accounts/{bank_account_id}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* GetBankAccount
* Returns details of a [BankAccount](#type-bankaccount) linked to a Square account.
* @param {String} bankAccountId Square-issued ID of the desired `BankAccount`.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GetBankAccountResponse}
*/
this.getBankAccount = function(bankAccountId) {
return this.getBankAccountWithHttpInfo(bankAccountId)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* GetBankAccountByV1Id
* Returns details of a [BankAccount](#type-bankaccount) identified by V1 bank account ID.
* @param {String} v1BankAccountId Connect V1 ID of the desired `BankAccount`. For more information, see [Retrieve a bank account by using an ID issued by V1 Bank Accounts API](https://developer.squareup.com/docs/docs/bank-accounts-api#retrieve-a-bank-account-by-using-an-id-issued-by-v1-bank-accounts-api).
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GetBankAccountByV1IdResponse} and HTTP response
*/
this.getBankAccountByV1IdWithHttpInfo = function(v1BankAccountId) {
var postBody = null;
// verify the required parameter 'v1BankAccountId' is set
if (v1BankAccountId === undefined || v1BankAccountId === null) {
throw new Error("Missing the required parameter 'v1BankAccountId' when calling getBankAccountByV1Id");
}
var pathParams = {
'v1_bank_account_id': v1BankAccountId
};
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 = GetBankAccountByV1IdResponse;
return this.apiClient.callApi(
'/v2/bank-accounts/by-v1-id/{v1_bank_account_id}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* GetBankAccountByV1Id
* Returns details of a [BankAccount](#type-bankaccount) identified by V1 bank account ID.
* @param {String} v1BankAccountId Connect V1 ID of the desired `BankAccount`. For more information, see [Retrieve a bank account by using an ID issued by V1 Bank Accounts API](https://developer.squareup.com/docs/docs/bank-accounts-api#retrieve-a-bank-account-by-using-an-id-issued-by-v1-bank-accounts-api).
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GetBankAccountByV1IdResponse}
*/
this.getBankAccountByV1Id = function(v1BankAccountId) {
return this.getBankAccountByV1IdWithHttpInfo(v1BankAccountId)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* ListBankAccounts
* Returns a list of [BankAccount](#type-bankaccount) objects linked to a Square account.
* @param {Object} opts Optional parameters
* @param {String} opts.cursor The pagination cursor returned by a previous call to this endpoint. Use it in the next `ListBankAccounts` request to retrieve the next set of results. See the [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination) guide for more information.
* @param {Number} opts.limit Upper limit on the number of bank accounts to return in the response. Currently, 1000 is the largest supported limit. You can specify a limit of up to 1000 bank accounts. This is also the default limit.
* @param {String} opts.locationId Location ID. You can specify this optional filter to retrieve only the linked bank accounts belonging to a specific location.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ListBankAccountsResponse} and HTTP response
*/
this.listBankAccountsWithHttpInfo = function(opts) {
opts = opts || {};
var postBody = null;
var pathParams = {
};
var queryParams = {
'cursor': opts['cursor'],
'limit': opts['limit'],
'location_id': opts['locationId']
};
var headerParams = {
};
headerParams['Square-Version'] = '2020-12-16';
var formParams = {
};
var authNames = ['oauth2'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = ListBankAccountsResponse;
return this.apiClient.callApi(
'/v2/bank-accounts', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* ListBankAccounts
* Returns a list of [BankAccount](#type-bankaccount) objects linked to a Square account.
* @param {Object} opts Optional parameters
* @param {String} opts.cursor The pagination cursor returned by a previous call to this endpoint. Use it in the next `ListBankAccounts` request to retrieve the next set of results. See the [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination) guide for more information.
* @param {Number} opts.limit Upper limit on the number of bank accounts to return in the response. Currently, 1000 is the largest supported limit. You can specify a limit of up to 1000 bank accounts. This is also the default limit.
* @param {String} opts.locationId Location ID. You can specify this optional filter to retrieve only the linked bank accounts belonging to a specific location.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ListBankAccountsResponse}
*/
this.listBankAccounts = function(opts) {
return this.listBankAccountsWithHttpInfo(opts)
.then(function(response_and_data) {
return response_and_data.data;
});
}
};