bkper-js 2.42.0 → 2.43.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -2077,6 +2077,16 @@ export declare class Book extends ResourceProperty<bkper.Book> {
2077
2077
  * @returns The [[Transaction]] object
2078
2078
  */
2079
2079
  getTransaction(id: string): Promise<Transaction | undefined>;
2080
+ /**
2081
+ * Retrieve complete transactions by id.
2082
+ *
2083
+ * Requests are sent sequentially in batches of up to 200 IDs.
2084
+ *
2085
+ * @param ids - The transaction IDs
2086
+ *
2087
+ * @returns The matching Transactions in input order
2088
+ */
2089
+ getTransactionsByIds(ids: string[]): Promise<Transaction[]>;
2080
2090
  /**
2081
2091
  * Retrieve a file by id.
2082
2092
  *
package/lib/model/Book.js CHANGED
@@ -1224,6 +1224,41 @@ export class Book extends ResourceProperty {
1224
1224
  return transaction;
1225
1225
  });
1226
1226
  }
1227
+ /**
1228
+ * Retrieve complete transactions by id.
1229
+ *
1230
+ * Requests are sent sequentially in batches of up to 200 IDs.
1231
+ *
1232
+ * @param ids - The transaction IDs
1233
+ *
1234
+ * @returns The matching Transactions in input order
1235
+ */
1236
+ getTransactionsByIds(ids) {
1237
+ return __awaiter(this, void 0, void 0, function* () {
1238
+ if (ids == null) {
1239
+ throw new Error('Transaction IDs are required.');
1240
+ }
1241
+ const distinctIds = new Set();
1242
+ const normalizedIds = [];
1243
+ for (const id of ids) {
1244
+ if (id == null || typeof id !== 'string' || id.trim() === '') {
1245
+ throw new Error('Transaction IDs must be non-blank strings.');
1246
+ }
1247
+ const normalizedId = id.trim();
1248
+ if (distinctIds.has(normalizedId)) {
1249
+ throw new Error(`Duplicate transaction ID: ${normalizedId}`);
1250
+ }
1251
+ distinctIds.add(normalizedId);
1252
+ normalizedIds.push(normalizedId);
1253
+ }
1254
+ const transactions = [];
1255
+ for (let index = 0; index < normalizedIds.length; index += 200) {
1256
+ const payloads = yield TransactionService.getTransactionsByIds(this.getId(), normalizedIds.slice(index, index + 200), this.getConfig());
1257
+ transactions.push(...payloads.map(payload => new Transaction(this, payload)));
1258
+ }
1259
+ return transactions;
1260
+ });
1261
+ }
1227
1262
  /**
1228
1263
  * Retrieve a file by id.
1229
1264
  *
@@ -108,6 +108,19 @@ export function getTransaction(bookId, id, config) {
108
108
  return response.data;
109
109
  });
110
110
  }
111
+ export function getTransactionsByIds(bookId, ids, config) {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ const payload = {
114
+ items: ids.map(id => ({ id: id })),
115
+ };
116
+ const response = yield new HttpBooksApiV5Request(`${bookId}/transactions/load`, config)
117
+ .setMethod('POST')
118
+ .setPayload(payload)
119
+ .fetch();
120
+ const transactionList = response.data;
121
+ return transactionList != null && transactionList.items != null ? transactionList.items : [];
122
+ });
123
+ }
111
124
  export function listTransactions(bookId, query, limit, cursor, config) {
112
125
  return __awaiter(this, void 0, void 0, function* () {
113
126
  if (!query) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.42.0",
3
+ "version": "2.43.1",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",