bkper-js 2.30.0 → 2.31.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
@@ -1830,6 +1830,14 @@ export declare class Book extends ResourceProperty<bkper.Book> {
1830
1830
  * @returns The created Accounts
1831
1831
  */
1832
1832
  batchCreateAccounts(accounts: Account[]): Promise<Account[]>;
1833
+ /**
1834
+ * Update [[Accounts]] on the Book, in batch.
1835
+ *
1836
+ * @param accounts - The accounts to be updated
1837
+ *
1838
+ * @returns The updated Accounts
1839
+ */
1840
+ batchUpdateAccounts(accounts: Account[]): Promise<Account[]>;
1833
1841
  /**
1834
1842
  * Delete [[Accounts]] on the Book, in batch.
1835
1843
  *
package/lib/model/Book.js CHANGED
@@ -574,6 +574,32 @@ export class Book extends ResourceProperty {
574
574
  return [];
575
575
  });
576
576
  }
577
+ /**
578
+ * Update [[Accounts]] on the Book, in batch.
579
+ *
580
+ * @param accounts - The accounts to be updated
581
+ *
582
+ * @returns The updated Accounts
583
+ */
584
+ batchUpdateAccounts(accounts) {
585
+ return __awaiter(this, void 0, void 0, function* () {
586
+ if (accounts.length > 0) {
587
+ const accountList = {
588
+ items: accounts.map(a => a.json()),
589
+ };
590
+ const payloads = yield AccountService.updateAccounts(this.getId(), accountList, this.getConfig());
591
+ const updatedAccounts = [];
592
+ for (const payload of payloads) {
593
+ const account = new Account(this, payload);
594
+ updatedAccounts.push(account);
595
+ this.setAccount(payload);
596
+ }
597
+ this.clearCache();
598
+ return updatedAccounts;
599
+ }
600
+ return [];
601
+ });
602
+ }
577
603
  /**
578
604
  * Delete [[Accounts]] on the Book, in batch.
579
605
  *
@@ -28,6 +28,13 @@ export function updateAccount(bookId, account, config) {
28
28
  return response.data;
29
29
  });
30
30
  }
31
+ export function updateAccounts(bookId, payload, config) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ var _a;
34
+ const response = yield new HttpBooksApiV5Request(`${bookId}/accounts/batch`, config).setMethod('PUT').setPayload(payload).fetch();
35
+ return ((_a = response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
36
+ });
37
+ }
31
38
  export function deleteAccount(bookId, account, config) {
32
39
  return __awaiter(this, void 0, void 0, function* () {
33
40
  var response = yield new HttpBooksApiV5Request(`${bookId}/accounts/${account.id}`, config).setMethod('DELETE').fetch();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.30.0",
3
+ "version": "2.31.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -35,7 +35,7 @@
35
35
  "postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
36
36
  },
37
37
  "dependencies": {
38
- "@bkper/bkper-api-types": "^5.37.0",
38
+ "@bkper/bkper-api-types": "^5.38.0",
39
39
  "big.js": "^6.0.3",
40
40
  "dayjs": "^1.10.3",
41
41
  "luxon": "^1.25.0",