@airwallex/node-sdk
Version:
Airwallex Node.js SDK
112 lines • 6.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PaymentAcceptancePaymentMethodsApi = void 0;
const apiClient_1 = require("../../client/apiClient");
const dataParser_1 = require("../../utils/dataParser");
const paymentAcceptanceListResponseOfPaymentAcceptancePaymentMethod_1 = require("../../model/paymentAcceptanceListResponseOfPaymentAcceptancePaymentMethod");
const paymentAcceptancePaymentMethod_1 = require("../../model/paymentAcceptancePaymentMethod");
class PaymentAcceptancePaymentMethodsApi {
async createPaymentMethod(payment_method_create_request, options = {}) {
const localVarPath = '/api/v1/pa/payment_methods/create';
const { headers, timeout, responseType } = options;
let localVarHeaderParams = Object.assign({}, headers ? headers : {});
if (payment_method_create_request === null || payment_method_create_request === undefined) {
throw new Error('Required parameter payment_method_create_request was null or undefined when calling createPaymentMethod.');
}
const data = await apiClient_1.apiClient.post(localVarPath, {
headers: localVarHeaderParams,
timeout,
responseType,
}, payment_method_create_request);
const typeName = paymentAcceptancePaymentMethod_1.PaymentAcceptancePaymentMethod.discriminator;
return (0, dataParser_1.parseDataToType)(data, typeName);
}
async disablePaymentMethod(id, payment_method_disable_request, options = {}) {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling disablePaymentMethod.');
}
const localVarPath = '/api/v1/pa/payment_methods/{id}/disable'.replace('{' + 'id' + '}', encodeURIComponent(String(id)));
const { headers, timeout, responseType } = options;
let localVarHeaderParams = Object.assign({}, headers ? headers : {});
if (payment_method_disable_request === null || payment_method_disable_request === undefined) {
throw new Error('Required parameter payment_method_disable_request was null or undefined when calling disablePaymentMethod.');
}
const data = await apiClient_1.apiClient.post(localVarPath, {
headers: localVarHeaderParams,
timeout,
responseType,
}, payment_method_disable_request);
const typeName = paymentAcceptancePaymentMethod_1.PaymentAcceptancePaymentMethod.discriminator;
return (0, dataParser_1.parseDataToType)(data, typeName);
}
async listPaymentMethods({ customer_id, from_created_at, page_num, page_size, status, to_created_at, type }, options = {}) {
const localVarPath = '/api/v1/pa/payment_methods';
const { headers, timeout, responseType } = options;
let localVarHeaderParams = Object.assign({}, headers ? headers : {});
let queryParams = {};
if (customer_id !== undefined) {
queryParams['customer_id'] = customer_id;
}
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;
}
if (type !== undefined) {
queryParams['type'] = type;
}
const data = await apiClient_1.apiClient.get(localVarPath, {
headers: localVarHeaderParams,
params: queryParams,
timeout,
responseType,
});
const typeName = paymentAcceptanceListResponseOfPaymentAcceptancePaymentMethod_1.PaymentAcceptanceListResponseOfPaymentAcceptancePaymentMethod.discriminator;
return (0, dataParser_1.parseDataToType)(data, typeName);
}
async retrievePaymentMethod(id, options = {}) {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling retrievePaymentMethod.');
}
const localVarPath = '/api/v1/pa/payment_methods/{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 = paymentAcceptancePaymentMethod_1.PaymentAcceptancePaymentMethod.discriminator;
return (0, dataParser_1.parseDataToType)(data, typeName);
}
async updatePaymentMethod(id, payment_method_update_request, options = {}) {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling updatePaymentMethod.');
}
const localVarPath = '/api/v1/pa/payment_methods/{id}/update'.replace('{' + 'id' + '}', encodeURIComponent(String(id)));
const { headers, timeout, responseType } = options;
let localVarHeaderParams = Object.assign({}, headers ? headers : {});
if (payment_method_update_request === null || payment_method_update_request === undefined) {
throw new Error('Required parameter payment_method_update_request was null or undefined when calling updatePaymentMethod.');
}
const data = await apiClient_1.apiClient.post(localVarPath, {
headers: localVarHeaderParams,
timeout,
responseType,
}, payment_method_update_request);
const typeName = paymentAcceptancePaymentMethod_1.PaymentAcceptancePaymentMethod.discriminator;
return (0, dataParser_1.parseDataToType)(data, typeName);
}
}
exports.PaymentAcceptancePaymentMethodsApi = PaymentAcceptancePaymentMethodsApi;
//# sourceMappingURL=paymentAcceptancePaymentMethodsApi.js.map