UNPKG

@airwallex/node-sdk

Version:

Airwallex Node.js SDK

234 lines 12.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GlobalAccountApi = void 0; const apiClient_1 = require("../../client/apiClient"); const dataParser_1 = require("../../utils/dataParser"); const activeGlobalAccountDto_1 = require("../../model/activeGlobalAccountDto"); const directDebitOutMandateDto_1 = require("../../model/directDebitOutMandateDto"); const globalAccountClientDto_1 = require("../../model/globalAccountClientDto"); const pagedDirectDebitOutMandateDto_1 = require("../../model/pagedDirectDebitOutMandateDto"); const pagedGlobalAccountDto_1 = require("../../model/pagedGlobalAccountDto"); const pagedTransactionDto_1 = require("../../model/pagedTransactionDto"); class GlobalAccountApi { async cancelMandate(global_account_id, id, options = {}) { if (global_account_id === null || global_account_id === undefined) { throw new Error('Required parameter global_account_id was null or undefined when calling cancelMandate.'); } if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling cancelMandate.'); } const localVarPath = '/api/v1/global_accounts/{global_account_id}/mandates/{id}/cancel'.replace('{' + 'global_account_id' + '}', encodeURIComponent(String(global_account_id))).replace('{' + 'id' + '}', encodeURIComponent(String(id))); const { headers, timeout, responseType } = options; let localVarHeaderParams = Object.assign({}, headers ? headers : {}); const data = await apiClient_1.apiClient.post(localVarPath, { headers: localVarHeaderParams, timeout, responseType, }); const typeName = 'boolean'; return (0, dataParser_1.parseDataToType)(data, typeName); } async closeGlobalAccount(id, options = {}) { if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling closeGlobalAccount.'); } const localVarPath = '/api/v1/global_accounts/{id}/close'.replace('{' + 'id' + '}', encodeURIComponent(String(id))); const { headers, timeout, responseType } = options; let localVarHeaderParams = Object.assign({}, headers ? headers : {}); const data = await apiClient_1.apiClient.post(localVarPath, { headers: localVarHeaderParams, timeout, responseType, }); const typeName = globalAccountClientDto_1.GlobalAccountClientDto.discriminator; return (0, dataParser_1.parseDataToType)(data, typeName); } async createGlobalAccount(globalAccountRequestDto, options = {}) { const localVarPath = '/api/v1/global_accounts/create'; const { headers, timeout, responseType } = options; let localVarHeaderParams = Object.assign({}, headers ? headers : {}); if (globalAccountRequestDto === null || globalAccountRequestDto === undefined) { throw new Error('Required parameter globalAccountRequestDto was null or undefined when calling createGlobalAccount.'); } const data = await apiClient_1.apiClient.post(localVarPath, { headers: localVarHeaderParams, timeout, responseType, }, globalAccountRequestDto); const typeName = activeGlobalAccountDto_1.ActiveGlobalAccountDto.discriminator; return (0, dataParser_1.parseDataToType)(data, typeName); } async getAccountStatementLetter(id, globalAccountStatementLetterDto, options = {}) { if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getAccountStatementLetter.'); } const localVarPath = '/api/v1/global_accounts/{id}/generate_statement_letter'.replace('{' + 'id' + '}', encodeURIComponent(String(id))); const { headers, timeout, responseType } = options; let localVarHeaderParams = Object.assign({}, headers ? headers : {}); if (globalAccountStatementLetterDto === null || globalAccountStatementLetterDto === undefined) { throw new Error('Required parameter globalAccountStatementLetterDto was null or undefined when calling getAccountStatementLetter.'); } const data = await apiClient_1.apiClient.post(localVarPath, { headers: localVarHeaderParams, timeout, responseType, }, globalAccountStatementLetterDto); const typeName = 'string'; return (0, dataParser_1.parseDataToType)(data, typeName); } async getGlobalAccountTransactions(id, { from_created_at, page_num, page_size, to_created_at }, options = {}) { if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getGlobalAccountTransactions.'); } const localVarPath = '/api/v1/global_accounts/{id}/transactions'.replace('{' + 'id' + '}', encodeURIComponent(String(id))); const { headers, timeout, responseType } = options; let localVarHeaderParams = Object.assign({}, headers ? headers : {}); let queryParams = {}; if (from_created_at !== undefined) { queryParams['from_created_at'] = from_created_at; } if (page_num !== undefined) { queryParams['page_num'] = page_num; } if (page_size !== undefined) { queryParams['page_size'] = page_size; } if (to_created_at !== undefined) { queryParams['to_created_at'] = to_created_at; } const data = await apiClient_1.apiClient.get(localVarPath, { headers: localVarHeaderParams, params: queryParams, timeout, responseType, }); const typeName = pagedTransactionDto_1.PagedTransactionDto.discriminator; return (0, dataParser_1.parseDataToType)(data, typeName); } async getGlobalAccount(id, options = {}) { if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getGlobalAccount.'); } const localVarPath = '/api/v1/global_accounts/{id}'.replace('{' + 'id' + '}', encodeURIComponent(String(id))); const { headers, timeout, responseType } = options; let localVarHeaderParams = Object.assign({}, headers ? headers : {}); const data = await apiClient_1.apiClient.get(localVarPath, { headers: localVarHeaderParams, timeout, responseType, }); const typeName = globalAccountClientDto_1.GlobalAccountClientDto.discriminator; return (0, dataParser_1.parseDataToType)(data, typeName); } async getGlobalAccounts({ country_code, from_created_at, nick_name, page, page_size, required_features_currency, status, supported_features_currency, to_created_at }, options = {}) { const localVarPath = '/api/v1/global_accounts'; const { headers, timeout, responseType } = options; let localVarHeaderParams = Object.assign({}, headers ? headers : {}); let queryParams = {}; if (country_code !== undefined) { queryParams['country_code'] = country_code; } if (from_created_at !== undefined) { queryParams['from_created_at'] = from_created_at; } if (nick_name !== undefined) { queryParams['nick_name'] = nick_name; } if (page !== undefined) { queryParams['page'] = page; } if (page_size !== undefined) { queryParams['page_size'] = page_size; } if (required_features_currency !== undefined) { queryParams['required_features.currency'] = required_features_currency; } if (status !== undefined) { queryParams['status'] = status; } if (supported_features_currency !== undefined) { queryParams['supported_features.currency'] = supported_features_currency; } if (to_created_at !== undefined) { queryParams['to_created_at'] = to_created_at; } const data = await apiClient_1.apiClient.get(localVarPath, { headers: localVarHeaderParams, params: queryParams, timeout, responseType, }); const typeName = pagedGlobalAccountDto_1.PagedGlobalAccountDto.discriminator; return (0, dataParser_1.parseDataToType)(data, typeName); } async getMandate(global_account_id, id, options = {}) { if (global_account_id === null || global_account_id === undefined) { throw new Error('Required parameter global_account_id was null or undefined when calling getMandate.'); } if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getMandate.'); } const localVarPath = '/api/v1/global_accounts/{global_account_id}/mandates/{id}'.replace('{' + 'global_account_id' + '}', encodeURIComponent(String(global_account_id))).replace('{' + 'id' + '}', encodeURIComponent(String(id))); const { headers, timeout, responseType } = options; let localVarHeaderParams = Object.assign({}, headers ? headers : {}); const data = await apiClient_1.apiClient.get(localVarPath, { headers: localVarHeaderParams, timeout, responseType, }); const typeName = directDebitOutMandateDto_1.DirectDebitOutMandateDto.discriminator; return (0, dataParser_1.parseDataToType)(data, typeName); } async getMandatesByGAId(global_account_id, { from_created_at, page_num, page_size, status, to_created_at }, options = {}) { if (global_account_id === null || global_account_id === undefined) { throw new Error('Required parameter global_account_id was null or undefined when calling getMandatesByGAId.'); } const localVarPath = '/api/v1/global_accounts/{global_account_id}/mandates'.replace('{' + 'global_account_id' + '}', encodeURIComponent(String(global_account_id))); const { headers, timeout, responseType } = options; let localVarHeaderParams = Object.assign({}, headers ? headers : {}); let queryParams = {}; if (from_created_at !== undefined) { queryParams['from_created_at'] = from_created_at; } if (page_num !== undefined) { queryParams['page_num'] = page_num; } if (page_size !== undefined) { queryParams['page_size'] = page_size; } if (status !== undefined) { queryParams['status'] = status; } if (to_created_at !== undefined) { queryParams['to_created_at'] = to_created_at; } const data = await apiClient_1.apiClient.get(localVarPath, { headers: localVarHeaderParams, params: queryParams, timeout, responseType, }); const typeName = pagedDirectDebitOutMandateDto_1.PagedDirectDebitOutMandateDto.discriminator; return (0, dataParser_1.parseDataToType)(data, typeName); } async updateGlobalAccount(id, globalAccountUpdateDto, options = {}) { if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling updateGlobalAccount.'); } const localVarPath = '/api/v1/global_accounts/{id}/update'.replace('{' + 'id' + '}', encodeURIComponent(String(id))); const { headers, timeout, responseType } = options; let localVarHeaderParams = Object.assign({}, headers ? headers : {}); if (globalAccountUpdateDto === null || globalAccountUpdateDto === undefined) { throw new Error('Required parameter globalAccountUpdateDto was null or undefined when calling updateGlobalAccount.'); } const data = await apiClient_1.apiClient.post(localVarPath, { headers: localVarHeaderParams, timeout, responseType, }, globalAccountUpdateDto); const typeName = globalAccountClientDto_1.GlobalAccountClientDto.discriminator; return (0, dataParser_1.parseDataToType)(data, typeName); } } exports.GlobalAccountApi = GlobalAccountApi; //# sourceMappingURL=globalAccountApi.js.map