bkper-js 1.21.0 → 1.23.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
@@ -220,6 +220,37 @@ export declare enum AccountType {
220
220
  OUTGOING = "OUTGOING"
221
221
  }
222
222
 
223
+ /**
224
+ * Defines an Agent on Bkper.
225
+ *
226
+ * An Agent represents an entity (such as an App or Bot) that interacts with Bkper, executing actions on behalf of users.
227
+ *
228
+ * @public
229
+ */
230
+ export declare class Agent {
231
+ payload: bkper.Agent;
232
+ constructor(payload?: bkper.Agent);
233
+ /**
234
+ * @returns The wrapped plain json object
235
+ */
236
+ json(): bkper.Agent;
237
+ /**
238
+ *
239
+ * @returns The Agent universal identifier
240
+ */
241
+ getId(): string | undefined;
242
+ /**
243
+ *
244
+ * @returns The Agent name
245
+ */
246
+ getName(): string | undefined;
247
+ /**
248
+ *
249
+ * @returns The Agent logo url
250
+ */
251
+ getLogoUrl(): string | undefined;
252
+ }
253
+
223
254
  /**
224
255
  * This class defines an Amount for arbitrary-precision decimal arithmetic.
225
256
  *
@@ -331,6 +362,18 @@ export declare class App {
331
362
  * @returns The App universal identifier
332
363
  */
333
364
  getId(): string | undefined;
365
+ /**
366
+ * @return The name of this App
367
+ */
368
+ getName(): string | undefined;
369
+ /**
370
+ * @return The logo url of this App
371
+ */
372
+ getLogoUrl(): string | undefined;
373
+ /**
374
+ * @return The description of this App
375
+ */
376
+ getDescription(): string | undefined;
334
377
  /**
335
378
  * Sets the whitelabeled user emails
336
379
  *
@@ -629,6 +672,7 @@ export declare class Book {
629
672
 
630
673
 
631
674
 
675
+
632
676
  constructor(payload?: bkper.Book);
633
677
  /**
634
678
  * @returns An immutable copy of the json payload
@@ -874,6 +918,12 @@ export declare class Book {
874
918
  * Trigger [Balances Audit](https://help.bkper.com/en/articles/4412038-balances-audit) async process.
875
919
  */
876
920
  audit(): void;
921
+ /**
922
+ * Retrieve installed [[Apps]] for this Book
923
+ *
924
+ * @returns The Apps objects
925
+ */
926
+ getApps(): Promise<App[]>;
877
927
  /**
878
928
  * Gets the existing [[Integrations]] in the Book.
879
929
  *
@@ -1304,7 +1354,10 @@ export declare enum DecimalSeparator {
1304
1354
  }
1305
1355
 
1306
1356
  /**
1307
- * Represents an Event in the system.
1357
+ *
1358
+ * This class defines an Event from a [[Book]].
1359
+ *
1360
+ * An event is an object that represents an action (such as posting or deleting a [[Transaction]]) made by an actor (such as a user or a [Bot](https://bkper.com/apps) acting on behalf of a user).
1308
1361
  *
1309
1362
  * @public
1310
1363
  */
@@ -1315,6 +1368,22 @@ export declare class Event {
1315
1368
  * @returns The wrapped plain json object
1316
1369
  */
1317
1370
  json(): bkper.Event;
1371
+ /**
1372
+ * @returns The user who performed the event
1373
+ */
1374
+ getUser(): User | undefined;
1375
+ /**
1376
+ * @returns The user who performed the event
1377
+ */
1378
+ getAgent(): Agent | undefined;
1379
+ /**
1380
+ * @returns The date the event was created
1381
+ */
1382
+ getCreatedAt(): Date | undefined;
1383
+ /**
1384
+ * @returns The type of the event
1385
+ */
1386
+ getType(): EventType | undefined;
1318
1387
  }
1319
1388
 
1320
1389
  /**
@@ -1347,6 +1416,41 @@ export declare class EventList {
1347
1416
  getItems(): Event[];
1348
1417
  }
1349
1418
 
1419
+ /**
1420
+ * Enum that represents event types.
1421
+ *
1422
+ * @public
1423
+ */
1424
+ export declare enum EventType {
1425
+ FILE_CREATED = "FILE_CREATED",
1426
+ TRANSACTION_CREATED = "TRANSACTION_CREATED",
1427
+ TRANSACTION_UPDATED = "TRANSACTION_UPDATED",
1428
+ TRANSACTION_DELETED = "TRANSACTION_DELETED",
1429
+ TRANSACTION_POSTED = "TRANSACTION_POSTED",
1430
+ TRANSACTION_CHECKED = "TRANSACTION_CHECKED",
1431
+ TRANSACTION_UNCHECKED = "TRANSACTION_UNCHECKED",
1432
+ TRANSACTION_RESTORED = "TRANSACTION_RESTORED",
1433
+ ACCOUNT_CREATED = "ACCOUNT_CREATED",
1434
+ ACCOUNT_UPDATED = "ACCOUNT_UPDATED",
1435
+ ACCOUNT_DELETED = "ACCOUNT_DELETED",
1436
+ QUERY_CREATED = "QUERY_CREATED",
1437
+ QUERY_UPDATED = "QUERY_UPDATED",
1438
+ QUERY_DELETED = "QUERY_DELETED",
1439
+ GROUP_CREATED = "GROUP_CREATED",
1440
+ GROUP_UPDATED = "GROUP_UPDATED",
1441
+ GROUP_DELETED = "GROUP_DELETED",
1442
+ COMMENT_CREATED = "COMMENT_CREATED",
1443
+ COMMENT_DELETED = "COMMENT_DELETED",
1444
+ COLLABORATOR_ADDED = "COLLABORATOR_ADDED",
1445
+ COLLABORATOR_UPDATED = "COLLABORATOR_UPDATED",
1446
+ COLLABORATOR_REMOVED = "COLLABORATOR_REMOVED",
1447
+ INTEGRATION_CREATED = "INTEGRATION_CREATED",
1448
+ INTEGRATION_UPDATED = "INTEGRATION_UPDATED",
1449
+ INTEGRATION_DELETED = "INTEGRATION_DELETED",
1450
+ BOOK_UPDATED = "BOOK_UPDATED",
1451
+ BOOK_DELETED = "BOOK_DELETED"
1452
+ }
1453
+
1350
1454
  /**
1351
1455
  *
1352
1456
  * This class defines a File uploaded to a [[Book]].
@@ -2285,6 +2389,12 @@ export declare class User {
2285
2389
  * @returns The User's name
2286
2390
  */
2287
2391
  getName(): string | undefined;
2392
+ /**
2393
+ * Gets the avatar url of the User.
2394
+ *
2395
+ * @returns The User's avatar url
2396
+ */
2397
+ getAvatarUrl(): string | undefined;
2288
2398
  /**
2289
2399
  * Gets the full name of the User.
2290
2400
  *
package/lib/index.js CHANGED
@@ -6,6 +6,7 @@
6
6
  * @packageDocumentation
7
7
  */
8
8
  export { Account } from './model/Account.js';
9
+ export { Agent } from './model/Agent.js';
9
10
  export { Amount } from "./model/Amount.js";
10
11
  export { App } from './model/App.js';
11
12
  export { BalancesReport } from './model/BalancesReport.js';
@@ -22,5 +23,5 @@ export { TransactionList } from './model/TransactionList.js';
22
23
  export { Event } from './model/Event.js';
23
24
  export { EventList } from './model/EventList.js';
24
25
  export { User } from './model/User.js';
25
- export { Periodicity, DecimalSeparator, Permission, Visibility, AccountType, Period, Month } from './model/Enums.js';
26
+ export { Periodicity, DecimalSeparator, Permission, Visibility, AccountType, Period, Month, EventType } from './model/Enums.js';
26
27
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Defines an Agent on Bkper.
3
+ *
4
+ * An Agent represents an entity (such as an App or Bot) that interacts with Bkper, executing actions on behalf of users.
5
+ *
6
+ * @public
7
+ */
8
+ export class Agent {
9
+ constructor(payload) {
10
+ this.payload = payload || {};
11
+ }
12
+ /**
13
+ * @returns The wrapped plain json object
14
+ */
15
+ json() {
16
+ return Object.assign({}, this.payload);
17
+ }
18
+ /**
19
+ *
20
+ * @returns The Agent universal identifier
21
+ */
22
+ getId() {
23
+ return this.payload.id;
24
+ }
25
+ /**
26
+ *
27
+ * @returns The Agent name
28
+ */
29
+ getName() {
30
+ return this.payload.name;
31
+ }
32
+ /**
33
+ *
34
+ * @returns The Agent logo url
35
+ */
36
+ getLogoUrl() {
37
+ return this.payload.logo;
38
+ }
39
+ }
40
+ //# sourceMappingURL=Agent.js.map
package/lib/model/App.js CHANGED
@@ -47,6 +47,24 @@ export class App {
47
47
  getId() {
48
48
  return this.payload.id;
49
49
  }
50
+ /**
51
+ * @return The name of this App
52
+ */
53
+ getName() {
54
+ return this.payload.name;
55
+ }
56
+ /**
57
+ * @return The logo url of this App
58
+ */
59
+ getLogoUrl() {
60
+ return this.payload.logoUrl;
61
+ }
62
+ /**
63
+ * @return The description of this App
64
+ */
65
+ getDescription() {
66
+ return this.payload.description;
67
+ }
50
68
  /**
51
69
  * Sets the whitelabeled user emails
52
70
  *
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,4 +148,39 @@ export var Month;
148
148
  Month["NOVEMBER"] = "NOVEMBER";
149
149
  Month["DECEMBER"] = "DECEMBER";
150
150
  })(Month || (Month = {}));
151
+ /**
152
+ * Enum that represents event types.
153
+ *
154
+ * @public
155
+ */
156
+ export var EventType;
157
+ (function (EventType) {
158
+ EventType["FILE_CREATED"] = "FILE_CREATED";
159
+ EventType["TRANSACTION_CREATED"] = "TRANSACTION_CREATED";
160
+ EventType["TRANSACTION_UPDATED"] = "TRANSACTION_UPDATED";
161
+ EventType["TRANSACTION_DELETED"] = "TRANSACTION_DELETED";
162
+ EventType["TRANSACTION_POSTED"] = "TRANSACTION_POSTED";
163
+ EventType["TRANSACTION_CHECKED"] = "TRANSACTION_CHECKED";
164
+ EventType["TRANSACTION_UNCHECKED"] = "TRANSACTION_UNCHECKED";
165
+ EventType["TRANSACTION_RESTORED"] = "TRANSACTION_RESTORED";
166
+ EventType["ACCOUNT_CREATED"] = "ACCOUNT_CREATED";
167
+ EventType["ACCOUNT_UPDATED"] = "ACCOUNT_UPDATED";
168
+ EventType["ACCOUNT_DELETED"] = "ACCOUNT_DELETED";
169
+ EventType["QUERY_CREATED"] = "QUERY_CREATED";
170
+ EventType["QUERY_UPDATED"] = "QUERY_UPDATED";
171
+ EventType["QUERY_DELETED"] = "QUERY_DELETED";
172
+ EventType["GROUP_CREATED"] = "GROUP_CREATED";
173
+ EventType["GROUP_UPDATED"] = "GROUP_UPDATED";
174
+ EventType["GROUP_DELETED"] = "GROUP_DELETED";
175
+ EventType["COMMENT_CREATED"] = "COMMENT_CREATED";
176
+ EventType["COMMENT_DELETED"] = "COMMENT_DELETED";
177
+ EventType["COLLABORATOR_ADDED"] = "COLLABORATOR_ADDED";
178
+ EventType["COLLABORATOR_UPDATED"] = "COLLABORATOR_UPDATED";
179
+ EventType["COLLABORATOR_REMOVED"] = "COLLABORATOR_REMOVED";
180
+ EventType["INTEGRATION_CREATED"] = "INTEGRATION_CREATED";
181
+ EventType["INTEGRATION_UPDATED"] = "INTEGRATION_UPDATED";
182
+ EventType["INTEGRATION_DELETED"] = "INTEGRATION_DELETED";
183
+ EventType["BOOK_UPDATED"] = "BOOK_UPDATED";
184
+ EventType["BOOK_DELETED"] = "BOOK_DELETED";
185
+ })(EventType || (EventType = {}));
151
186
  //# sourceMappingURL=Enums.js.map
@@ -1,5 +1,10 @@
1
+ import { Agent } from "./Agent";
2
+ import { User } from "./User";
1
3
  /**
2
- * Represents an Event in the system.
4
+ *
5
+ * This class defines an Event from a [[Book]].
6
+ *
7
+ * An event is an object that represents an action (such as posting or deleting a [[Transaction]]) made by an actor (such as a user or a [Bot](https://bkper.com/apps) acting on behalf of a user).
3
8
  *
4
9
  * @public
5
10
  */
@@ -13,5 +18,29 @@ export class Event {
13
18
  json() {
14
19
  return Object.assign({}, this.payload);
15
20
  }
21
+ /**
22
+ * @returns The user who performed the event
23
+ */
24
+ getUser() {
25
+ return this.payload.user ? new User(this.payload.user) : undefined;
26
+ }
27
+ /**
28
+ * @returns The user who performed the event
29
+ */
30
+ getAgent() {
31
+ return this.payload.agent ? new Agent(this.payload.agent) : undefined;
32
+ }
33
+ /**
34
+ * @returns The date the event was created
35
+ */
36
+ getCreatedAt() {
37
+ return this.payload.createdAt ? new Date(new Number(this.payload.createdAt).valueOf()) : undefined;
38
+ }
39
+ /**
40
+ * @returns The type of the event
41
+ */
42
+ getType() {
43
+ return this.payload.type;
44
+ }
16
45
  }
17
46
  //# sourceMappingURL=Event.js.map
package/lib/model/User.js CHANGED
@@ -41,6 +41,14 @@ export class User {
41
41
  getName() {
42
42
  return this.payload.name;
43
43
  }
44
+ /**
45
+ * Gets the avatar url of the User.
46
+ *
47
+ * @returns The User's avatar url
48
+ */
49
+ getAvatarUrl() {
50
+ return this.payload.avatarUrl;
51
+ }
44
52
  /**
45
53
  * Gets the full name of the User.
46
54
  *
@@ -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.21.0",
3
+ "version": "1.23.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",