bkper-js 1.43.0 → 1.44.0

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
@@ -973,8 +973,10 @@ export declare class Book {
973
973
  *
974
974
  * @param updateChecked True to also update checked transactions
975
975
  *
976
+ * @returns The updated draft Transactions
977
+ *
976
978
  */
977
- batchUpdateTransactions(transactions: Transaction[], updateChecked?: boolean): Promise<void>;
979
+ batchUpdateTransactions(transactions: Transaction[], updateChecked?: boolean): Promise<Transaction[]>;
978
980
  /**
979
981
  * Batch check [[Transactions]] on the Book.
980
982
  *
@@ -998,6 +1000,13 @@ export declare class Book {
998
1000
  *
999
1001
  */
1000
1002
  batchTrashTransactions(transactions: Transaction[], trashChecked?: boolean): Promise<void>;
1003
+ /**
1004
+ * Batch untrash [[Transactions]] on the Book.
1005
+ *
1006
+ * @param transactions The transactions to be untrashed
1007
+ *
1008
+ */
1009
+ batchUntrashTransactions(transactions: Transaction[]): Promise<void>;
1001
1010
  /**
1002
1011
  * Replay [[Events]] on the Book, in batch.
1003
1012
  */
package/lib/model/Book.js CHANGED
@@ -428,12 +428,16 @@ export class Book {
428
428
  *
429
429
  * @param updateChecked True to also update checked transactions
430
430
  *
431
+ * @returns The updated draft Transactions
432
+ *
431
433
  */
432
434
  batchUpdateTransactions(transactions, updateChecked) {
433
435
  return __awaiter(this, void 0, void 0, function* () {
434
- let transactionsPayload = [];
435
- transactions.forEach(tx => transactionsPayload.push(tx.json()));
436
- yield TransactionService.updateTransactionsBatch(this.getId(), transactionsPayload, updateChecked);
436
+ let transactionPayloads = [];
437
+ transactions.forEach(tx => transactionPayloads.push(tx.json()));
438
+ transactionPayloads = yield TransactionService.updateTransactionsBatch(this.getId(), transactionPayloads, updateChecked);
439
+ transactions = transactionPayloads.map(tx => new Transaction(this, tx));
440
+ return transactions;
437
441
  });
438
442
  }
439
443
  /**
@@ -477,6 +481,19 @@ export class Book {
477
481
  yield TransactionService.trashTransactionsBatch(this.getId(), transactionPayloads, trashChecked);
478
482
  });
479
483
  }
484
+ /**
485
+ * Batch untrash [[Transactions]] on the Book.
486
+ *
487
+ * @param transactions The transactions to be untrashed
488
+ *
489
+ */
490
+ batchUntrashTransactions(transactions) {
491
+ return __awaiter(this, void 0, void 0, function* () {
492
+ let transactionPayloads = [];
493
+ transactions.forEach(tx => transactionPayloads.push(tx.json()));
494
+ yield TransactionService.untrashTransactionsBatch(this.getId(), transactionPayloads);
495
+ });
496
+ }
480
497
  /**
481
498
  * Replay [[Events]] on the Book, in batch.
482
499
  */
@@ -16,22 +16,20 @@ export function createTransaction(bookId, transaction) {
16
16
  }
17
17
  export function createTransactionsBatch(bookId, transactions) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
- let transactionList = {
20
- items: transactions
21
- };
22
- var payload = transactionList;
23
- let response = yield new HttpBooksApiV5Request(`${bookId}/transactions/batch`)
24
- .setMethod('POST')
25
- .setPayload(payload)
26
- .fetch();
19
+ let transactionList = { items: transactions };
20
+ const payload = transactionList;
21
+ const response = yield new HttpBooksApiV5Request(`${bookId}/transactions/batch`).setMethod('POST').setPayload(payload).fetch();
27
22
  transactionList = yield response.data;
28
23
  return transactionList != null && transactionList.items != null ? transactionList.items : [];
29
24
  });
30
25
  }
31
26
  export function updateTransactionsBatch(bookId, transactions, updateChecked) {
32
27
  return __awaiter(this, void 0, void 0, function* () {
33
- const payload = { items: transactions };
34
- yield new HttpBooksApiV5Request(`${bookId}/transactions/batch`).setMethod('PUT').setPayload(payload).addParam('updateChecked', updateChecked).fetch();
28
+ let transactionList = { items: transactions };
29
+ const payload = transactionList;
30
+ const response = yield new HttpBooksApiV5Request(`${bookId}/transactions/batch`).setMethod('PUT').setPayload(payload).addParam('updateChecked', updateChecked).fetch();
31
+ transactionList = yield response.data;
32
+ return transactionList != null && transactionList.items != null ? transactionList.items : [];
35
33
  });
36
34
  }
37
35
  export function checkTransactionsBatch(bookId, transactions) {
@@ -54,6 +52,14 @@ export function trashTransactionsBatch(bookId, transactions, trashChecked) {
54
52
  transactionList = yield response.data;
55
53
  });
56
54
  }
55
+ export function untrashTransactionsBatch(bookId, transactions) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ let transactionList = { items: transactions };
58
+ const payload = transactionList;
59
+ const response = yield new HttpBooksApiV5Request(`${bookId}/transactions/untrash/batch`).setMethod('PATCH').setPayload(payload).fetch();
60
+ transactionList = yield response.data;
61
+ });
62
+ }
57
63
  export function updateTransaction(bookId, transaction) {
58
64
  return __awaiter(this, void 0, void 0, function* () {
59
65
  var response = yield new HttpBooksApiV5Request(`${bookId}/transactions`).setMethod('PUT').setPayload(transaction).fetch();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "1.43.0",
3
+ "version": "1.44.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -34,7 +34,7 @@
34
34
  "postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
35
35
  },
36
36
  "peerDependencies": {
37
- "@bkper/bkper-api-types": "^5.19.0"
37
+ "@bkper/bkper-api-types": "^5.20.0"
38
38
  },
39
39
  "dependencies": {
40
40
  "@google-cloud/local-auth": "^3.0.1",