bkper-js 1.22.0 → 1.24.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
@@ -362,6 +362,22 @@ export declare class App {
362
362
  * @returns The App universal identifier
363
363
  */
364
364
  getId(): string | undefined;
365
+ /**
366
+ * @return The name of this App
367
+ */
368
+ getName(): string | undefined;
369
+ /**
370
+ * @return The type of this App
371
+ */
372
+ getType(): AppType | undefined;
373
+ /**
374
+ * @return The logo url of this App
375
+ */
376
+ getLogoUrl(): string | undefined;
377
+ /**
378
+ * @return The description of this App
379
+ */
380
+ getDescription(): string | undefined;
365
381
  /**
366
382
  * Sets the whitelabeled user emails
367
383
  *
@@ -402,6 +418,28 @@ export declare class App {
402
418
  update(): Promise<App>;
403
419
  }
404
420
 
421
+ /**
422
+ * Enum that represents the type of an App.
423
+ *
424
+ * @public
425
+ */
426
+ export declare enum AppType {
427
+ /**
428
+ * Interactive solutions that can run independently and integrate with third-party services.
429
+ * Apps can range from simple URL openers to complex add-ons with business logic.
430
+ *
431
+ * Learn more on [Bkper Apps](https://bkper.com/docs/#apps).
432
+ */
433
+ APP = "APP",
434
+ /**
435
+ * Specialized type of App that react to events from Books.
436
+ * Bots can perform automated tasks like calculating taxes, converting currencies, or posting notifications when specific events occur.
437
+ *
438
+ * Learn more on [Bkper Bots](https://bkper.com/docs/#bots).
439
+ */
440
+ BOT = "BOT"
441
+ }
442
+
405
443
  /**
406
444
  * The container of balances of an [[Account]] or [[Group]]
407
445
  *
@@ -660,6 +698,7 @@ export declare class Book {
660
698
 
661
699
 
662
700
 
701
+
663
702
  constructor(payload?: bkper.Book);
664
703
  /**
665
704
  * @returns An immutable copy of the json payload
@@ -905,6 +944,12 @@ export declare class Book {
905
944
  * Trigger [Balances Audit](https://help.bkper.com/en/articles/4412038-balances-audit) async process.
906
945
  */
907
946
  audit(): void;
947
+ /**
948
+ * Retrieve installed [[Apps]] for this Book
949
+ *
950
+ * @returns The Apps objects
951
+ */
952
+ getApps(): Promise<App[]>;
908
953
  /**
909
954
  * Gets the existing [[Integrations]] in the Book.
910
955
  *
package/lib/index.js CHANGED
@@ -23,5 +23,5 @@ export { TransactionList } from './model/TransactionList.js';
23
23
  export { Event } from './model/Event.js';
24
24
  export { EventList } from './model/EventList.js';
25
25
  export { User } from './model/User.js';
26
- export { Periodicity, DecimalSeparator, Permission, Visibility, AccountType, Period, Month, EventType } from './model/Enums.js';
26
+ export { Periodicity, DecimalSeparator, Permission, Visibility, AccountType, Period, Month, EventType, AppType } from './model/Enums.js';
27
27
  //# sourceMappingURL=index.js.map
package/lib/model/App.js CHANGED
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { createApp, patchApp, updateApp } from "../service/app-service.js";
11
+ import { AppType } from "./Enums.js";
11
12
  /**
12
13
  * Defines an App on Bkper.
13
14
  *
@@ -47,6 +48,31 @@ export class App {
47
48
  getId() {
48
49
  return this.payload.id;
49
50
  }
51
+ /**
52
+ * @return The name of this App
53
+ */
54
+ getName() {
55
+ return this.payload.name;
56
+ }
57
+ /**
58
+ * @return The type of this App
59
+ */
60
+ getType() {
61
+ const events = this.payload.events;
62
+ return events && events.length > 0 ? AppType.BOT : AppType.APP;
63
+ }
64
+ /**
65
+ * @return The logo url of this App
66
+ */
67
+ getLogoUrl() {
68
+ return this.payload.logoUrl;
69
+ }
70
+ /**
71
+ * @return The description of this App
72
+ */
73
+ getDescription() {
74
+ return this.payload.description;
75
+ }
50
76
  /**
51
77
  * Sets the whitelabeled user emails
52
78
  *
package/lib/model/Book.js CHANGED
@@ -26,6 +26,7 @@ import { Integration } from './Integration.js';
26
26
  import { Transaction } from './Transaction.js';
27
27
  import { TransactionList } from './TransactionList.js';
28
28
  import { BalancesReport } from './BalancesReport.js';
29
+ import { App } from './App.js';
29
30
  /**
30
31
  *
31
32
  * A Book represents [General Ledger](https://en.wikipedia.org/wiki/General_ledger) for a company or business, but can also represent a [Ledger](https://en.wikipedia.org/wiki/Ledger) for a project or department
@@ -430,6 +431,21 @@ export class Book {
430
431
  audit() {
431
432
  BookService.audit(this.getId());
432
433
  }
434
+ /**
435
+ * Retrieve installed [[Apps]] for this Book
436
+ *
437
+ * @returns The Apps objects
438
+ */
439
+ getApps() {
440
+ return __awaiter(this, void 0, void 0, function* () {
441
+ if (this.apps != null) {
442
+ return this.apps;
443
+ }
444
+ const appsPlain = yield BookService.getApps(this.getId());
445
+ this.apps = appsPlain.map(a => new App(a));
446
+ return this.apps;
447
+ });
448
+ }
433
449
  /**
434
450
  * Gets the existing [[Integrations]] in the Book.
435
451
  *
@@ -148,6 +148,28 @@ export var Month;
148
148
  Month["NOVEMBER"] = "NOVEMBER";
149
149
  Month["DECEMBER"] = "DECEMBER";
150
150
  })(Month || (Month = {}));
151
+ /**
152
+ * Enum that represents the type of an App.
153
+ *
154
+ * @public
155
+ */
156
+ export var AppType;
157
+ (function (AppType) {
158
+ /**
159
+ * Interactive solutions that can run independently and integrate with third-party services.
160
+ * Apps can range from simple URL openers to complex add-ons with business logic.
161
+ *
162
+ * Learn more on [Bkper Apps](https://bkper.com/docs/#apps).
163
+ */
164
+ AppType["APP"] = "APP";
165
+ /**
166
+ * Specialized type of App that react to events from Books.
167
+ * Bots can perform automated tasks like calculating taxes, converting currencies, or posting notifications when specific events occur.
168
+ *
169
+ * Learn more on [Bkper Bots](https://bkper.com/docs/#bots).
170
+ */
171
+ AppType["BOT"] = "BOT";
172
+ })(AppType || (AppType = {}));
151
173
  /**
152
174
  * Enum that represents event types.
153
175
  *
@@ -49,4 +49,11 @@ export function audit(bookId) {
49
49
  new HttpBooksApiV5Request(`${bookId}/audit`).setMethod('PATCH').fetch();
50
50
  });
51
51
  }
52
+ export function getApps(bookId) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ var _a;
55
+ let response = yield new HttpBooksApiV5Request(`${bookId}/apps`).setMethod('GET').fetch();
56
+ return ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
57
+ });
58
+ }
52
59
  //# sourceMappingURL=book-service.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "1.22.0",
3
+ "version": "1.24.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",