@airwallex/node-sdk
Version:
Airwallex Node.js SDK
142 lines • 6.99 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutoPaymentsApi = void 0;
const apiClient_1 = require("../../client/apiClient");
const dataParser_1 = require("../../utils/dataParser");
const pagedSchedulePaymentDto_1 = require("../../model/pagedSchedulePaymentDto");
const pagedSchedulePaymentTaskDto_1 = require("../../model/pagedSchedulePaymentTaskDto");
const schedulePaymentResponseDto_1 = require("../../model/schedulePaymentResponseDto");
class AutoPaymentsApi {
async createSchedulePayment(request, options = {}) {
const localVarPath = '/api/v1/auto_payments/create';
const { headers, timeout, responseType } = options;
let localVarHeaderParams = Object.assign({}, headers ? headers : {});
if (request === null || request === undefined) {
throw new Error('Required parameter request was null or undefined when calling createSchedulePayment.');
}
const data = await apiClient_1.apiClient.post(localVarPath, {
headers: localVarHeaderParams,
timeout,
responseType,
}, request);
const typeName = schedulePaymentResponseDto_1.SchedulePaymentResponseDto.discriminator;
return (0, dataParser_1.parseDataToType)(data, typeName);
}
async disableSchedulePayment(id, options = {}) {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling disableSchedulePayment.');
}
const localVarPath = '/api/v1/auto_payments/{id}/disable'.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 = 'string';
return (0, dataParser_1.parseDataToType)(data, typeName);
}
async enableSchedulePayment(id, options = {}) {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling enableSchedulePayment.');
}
const localVarPath = '/api/v1/auto_payments/{id}/enable'.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 = 'string';
return (0, dataParser_1.parseDataToType)(data, typeName);
}
async getSchedulePaymentTasks({ from_created_at, page_num, page_size, to_created_at }, options = {}) {
const localVarPath = '/api/v1/auto_payments/task';
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 = pagedSchedulePaymentTaskDto_1.PagedSchedulePaymentTaskDto.discriminator;
return (0, dataParser_1.parseDataToType)(data, typeName);
}
async getSchedulePayment(id, options = {}) {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling getSchedulePayment.');
}
const localVarPath = '/api/v1/auto_payments/{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 = schedulePaymentResponseDto_1.SchedulePaymentResponseDto.discriminator;
return (0, dataParser_1.parseDataToType)(data, typeName);
}
async getSchedulePayments({ from_created_at, page_num, page_size, to_created_at }, options = {}) {
const localVarPath = '/api/v1/auto_payments';
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 = pagedSchedulePaymentDto_1.PagedSchedulePaymentDto.discriminator;
return (0, dataParser_1.parseDataToType)(data, typeName);
}
async updateSchedulePayment(id, request, options = {}) {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling updateSchedulePayment.');
}
const localVarPath = '/api/v1/auto_payments/{id}/update'.replace('{' + 'id' + '}', encodeURIComponent(String(id)));
const { headers, timeout, responseType } = options;
let localVarHeaderParams = Object.assign({}, headers ? headers : {});
if (request === null || request === undefined) {
throw new Error('Required parameter request was null or undefined when calling updateSchedulePayment.');
}
const data = await apiClient_1.apiClient.post(localVarPath, {
headers: localVarHeaderParams,
timeout,
responseType,
}, request);
const typeName = schedulePaymentResponseDto_1.SchedulePaymentResponseDto.discriminator;
return (0, dataParser_1.parseDataToType)(data, typeName);
}
}
exports.AutoPaymentsApi = AutoPaymentsApi;
//# sourceMappingURL=autoPaymentsApi.js.map