@adyen/api-library
Version:
The Adyen API Library for NodeJS enables you to work with Adyen APIs.
89 lines • 6.77 kB
JavaScript
;
/*
* The version of the OpenAPI document: v4
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit this class manually.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransactionsApi = void 0;
const getJsonResponse_1 = __importDefault(require("../../helpers/getJsonResponse"));
const service_1 = __importDefault(require("../../service"));
const resource_1 = __importDefault(require("../resource"));
const objectSerializer_1 = require("../../typings/transfers/objectSerializer");
/**
* API handler for TransactionsApi
*/
class TransactionsApi extends service_1.default {
constructor(client) {
super(client);
this.API_BASEPATH = "https://balanceplatform-api-test.adyen.com/btl/v4";
this.baseUrl = this.createBaseUrl(this.API_BASEPATH);
}
/**
* @summary Get all transactions
* @param requestOptions {@link IRequest.Options }
* @param createdSince {@link Date } (Required) Only include transactions that have been created on or after this point in time. The value must be in ISO 8601 format. For example, **2021-05-30T15:07:40Z**.
* @param createdUntil {@link Date } (Required) Only include transactions that have been created on or before this point in time. The value must be in ISO 8601 format. For example, **2021-05-30T15:07:40Z**.
* @param balancePlatform {@link string } The unique identifier of the [balance platform](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/get/balancePlatforms/{id}__queryParam_id). Required if you don\'t provide a `balanceAccountId` or `accountHolderId`.
* @param paymentInstrumentId {@link string } The unique identifier of the [payment instrument](https://docs.adyen.com/api-explorer/balanceplatform/latest/get/paymentInstruments/_id_). To use this parameter, you must also provide a `balanceAccountId`, `accountHolderId`, or `balancePlatform`. The `paymentInstrumentId` must be related to the `balanceAccountId` or `accountHolderId` that you provide.
* @param accountHolderId {@link string } The unique identifier of the [account holder](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/get/accountHolders/{id}__queryParam_id). Required if you don\'t provide a `balanceAccountId` or `balancePlatform`. If you provide a `balanceAccountId`, the `accountHolderId` must be related to the `balanceAccountId`.
* @param balanceAccountId {@link string } The unique identifier of the [balance account](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/get/balanceAccounts/{id}__queryParam_id). Required if you don\'t provide an `accountHolderId` or `balancePlatform`. If you provide an `accountHolderId`, the `balanceAccountId` must be related to the `accountHolderId`.
* @param cursor {@link string } The `cursor` returned in the links of the previous response.
* @param sortOrder {@link 'asc' | 'desc' } Determines the sort order of the returned transactions. The sort order is based on the creation date of the transaction. Possible values: - **asc**: Ascending order, from oldest to most recent. - **desc**: Descending order, from most recent to oldest. Default value: **asc**.
* @param limit {@link number } The number of items returned per page, maximum of 100 items. By default, the response returns 10 items per page.
* @return {@link TransactionSearchResponse }
*/
async getAllTransactions(createdSince, createdUntil, balancePlatform, paymentInstrumentId, accountHolderId, balanceAccountId, cursor, sortOrder, limit, requestOptions) {
var _a, _b, _c, _d, _e, _f, _g;
const endpoint = `${this.baseUrl}/transactions`;
const resource = new resource_1.default(this, endpoint);
const hasDefinedQueryParams = (_g = (_f = (_e = (_d = (_c = (_b = (_a = balancePlatform !== null && balancePlatform !== void 0 ? balancePlatform : paymentInstrumentId) !== null && _a !== void 0 ? _a : accountHolderId) !== null && _b !== void 0 ? _b : balanceAccountId) !== null && _c !== void 0 ? _c : cursor) !== null && _d !== void 0 ? _d : createdSince) !== null && _e !== void 0 ? _e : createdUntil) !== null && _f !== void 0 ? _f : sortOrder) !== null && _g !== void 0 ? _g : limit;
if (hasDefinedQueryParams) {
if (!requestOptions)
requestOptions = {};
if (!requestOptions.params)
requestOptions.params = {};
if (balancePlatform)
requestOptions.params["balancePlatform"] = balancePlatform;
if (paymentInstrumentId)
requestOptions.params["paymentInstrumentId"] = paymentInstrumentId;
if (accountHolderId)
requestOptions.params["accountHolderId"] = accountHolderId;
if (balanceAccountId)
requestOptions.params["balanceAccountId"] = balanceAccountId;
if (cursor)
requestOptions.params["cursor"] = cursor;
if (createdSince)
requestOptions.params["createdSince"] = createdSince.toISOString();
if (createdUntil)
requestOptions.params["createdUntil"] = createdUntil.toISOString();
if (sortOrder)
requestOptions.params["sortOrder"] = sortOrder;
if (limit)
requestOptions.params["limit"] = limit;
}
const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" });
return objectSerializer_1.ObjectSerializer.deserialize(response, "TransactionSearchResponse");
}
/**
* @summary Get a transaction
* @param id {@link string } The unique identifier of the transaction.
* @param requestOptions {@link IRequest.Options }
* @return {@link Transaction }
*/
async getTransaction(id, requestOptions) {
const endpoint = `${this.baseUrl}/transactions/{id}`
.replace("{" + "id" + "}", encodeURIComponent(String(id)));
const resource = new resource_1.default(this, endpoint);
const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" });
return objectSerializer_1.ObjectSerializer.deserialize(response, "Transaction");
}
}
exports.TransactionsApi = TransactionsApi;
//# sourceMappingURL=transactionsApi.js.map