bkper-js 1.29.1 → 1.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
@@ -357,6 +357,13 @@ export declare class App {
357
357
  * @returns This App, for chainning.
358
358
  */
359
359
  setWebhookUrlDev(webhookUrlDev: string): App;
360
+ /**
361
+ *
362
+ * Sets the conversation url for development.
363
+ *
364
+ * @returns This App, for chainning.
365
+ */
366
+ setConversationUrlDev(conversationUrlDev: string): App;
360
367
  /**
361
368
  *
362
369
  * @returns The App universal identifier
@@ -378,6 +385,10 @@ export declare class App {
378
385
  * @return The logo url of this App
379
386
  */
380
387
  getLogoUrl(): string | undefined;
388
+ /**
389
+ * @return The logo url of this App in dark mode
390
+ */
391
+ getLogoUrlDark(): string | undefined;
381
392
  /**
382
393
  * @return The description of this App
383
394
  */
@@ -623,6 +634,12 @@ export declare class Bkper {
623
634
  * @returns The retrieved list of Apps
624
635
  */
625
636
  static getApps(): Promise<App[]>;
637
+ /**
638
+ * Gets all [[Conversations]] available for the user.
639
+ *
640
+ * @returns The retrieved list of Conversations
641
+ */
642
+ static getConversations(): Promise<Conversation[]>;
626
643
  /**
627
644
  * Gets all [[Templates]] available for the user.
628
645
  *
@@ -1414,6 +1431,53 @@ export declare class Connection {
1414
1431
  remove(): Promise<Connection>;
1415
1432
  }
1416
1433
 
1434
+ /**
1435
+ * Defines a Conversation on Bkper.
1436
+ *
1437
+ * A Conversation represents an interaction between [[Users]] and [[Apps]].
1438
+ *
1439
+ * @public
1440
+ */
1441
+ export declare class Conversation {
1442
+ payload: bkper.Conversation;
1443
+
1444
+ constructor(payload?: bkper.Conversation);
1445
+ /**
1446
+ * @returns The wrapped plain json object
1447
+ */
1448
+ json(): bkper.Conversation;
1449
+ /**
1450
+ *
1451
+ * @returns The Conversation universal identifier
1452
+ */
1453
+ getId(): string | undefined;
1454
+ /**
1455
+ *
1456
+ * @returns The title of the Conversation
1457
+ */
1458
+ getTitle(): string | undefined;
1459
+ /**
1460
+ *
1461
+ * @returns The Agent associated to this Conversation
1462
+ */
1463
+ getAgent(): Agent | undefined;
1464
+ /**
1465
+ *
1466
+ * @returns The Date the Conversation was created
1467
+ */
1468
+ getCreatedAt(): Date | undefined;
1469
+ /**
1470
+ *
1471
+ * @returns The Date the Conversation was last updated
1472
+ */
1473
+ getUpdatedAt(): Date | undefined;
1474
+ /**
1475
+ *
1476
+ * @returns The Messages associated to this Conversation
1477
+ */
1478
+ getMessages(): Message[];
1479
+ }
1480
+
1417
1481
  /**
1418
1482
  * Decimal separator of numbers on book
1419
1483
  *
@@ -1460,7 +1524,7 @@ export declare class Event {
1460
1524
  */
1461
1525
  getUser(): User | undefined;
1462
1526
  /**
1463
- * @returns The user who performed the Event
1527
+ * @returns The Agent who performed the Event
1464
1528
  */
1465
1529
  getAgent(): Agent | undefined;
1466
1530
  /**
@@ -1920,6 +1984,48 @@ export declare class Integration {
1920
1984
  remove(): Promise<Integration>;
1921
1985
  }
1922
1986
 
1987
+ /**
1988
+ * Defines a Message on Bkper.
1989
+ *
1990
+ * A Message is a building block of a [[Conversation]].
1991
+ *
1992
+ * @public
1993
+ */
1994
+ export declare class Message {
1995
+ payload: bkper.Message;
1996
+
1997
+ constructor(conversation: Conversation, payload?: bkper.Message);
1998
+ /**
1999
+ * @returns The wrapped plain json object
2000
+ */
2001
+ json(): bkper.Message;
2002
+ /**
2003
+ *
2004
+ * @returns The Message universal identifier
2005
+ */
2006
+ getId(): string | undefined;
2007
+ /**
2008
+ *
2009
+ * @returns The Agent who created the Message, if any
2010
+ */
2011
+ getAgent(): Agent | undefined;
2012
+ /**
2013
+ *
2014
+ * @returns The User who created the Message, if any
2015
+ */
2016
+ getUser(): User | undefined;
2017
+ /**
2018
+ *
2019
+ * @returns The Date the Message was created
2020
+ */
2021
+ getCreatedAt(): Date | undefined;
2022
+ /**
2023
+ *
2024
+ * @returns The content text of the Message
2025
+ */
2026
+ getContent(): string | undefined;
2027
+ }
2028
+
1923
2029
  /**
1924
2030
  * Enum that represents a Month.
1925
2031
  *
package/lib/index.js CHANGED
@@ -14,9 +14,11 @@ export { Bkper } from './model/Bkper.js';
14
14
  export { Book } from './model/Book.js';
15
15
  export { Collection } from './model/Collection.js';
16
16
  export { Connection } from './model/Connection.js';
17
+ export { Conversation } from './model/Conversation.js';
17
18
  export { File } from './model/File.js';
18
19
  export { Group } from './model/Group.js';
19
20
  export { Integration } from './model/Integration.js';
21
+ export { Message } from './model/Message.js';
20
22
  export { Template } from './model/Template.js';
21
23
  export { Transaction } from './model/Transaction.js';
22
24
  export { TransactionList } from './model/TransactionList.js';
package/lib/model/App.js CHANGED
@@ -32,12 +32,17 @@ export class App {
32
32
  * @returns This App, for chainning.
33
33
  */
34
34
  setWebhookUrlDev(webhookUrlDev) {
35
- if (webhookUrlDev) {
36
- this.payload.webhookUrlDev = webhookUrlDev;
37
- }
38
- else {
39
- this.payload.webhookUrlDev = 'null';
40
- }
35
+ this.payload.webhookUrlDev = webhookUrlDev;
36
+ return this;
37
+ }
38
+ /**
39
+ *
40
+ * Sets the conversation url for development.
41
+ *
42
+ * @returns This App, for chainning.
43
+ */
44
+ setConversationUrlDev(conversationUrlDev) {
45
+ this.payload.conversationUrlDev = conversationUrlDev;
41
46
  return this;
42
47
  }
43
48
  /**
@@ -72,6 +77,12 @@ export class App {
72
77
  getLogoUrl() {
73
78
  return this.payload.logoUrl;
74
79
  }
80
+ /**
81
+ * @return The logo url of this App in dark mode
82
+ */
83
+ getLogoUrlDark() {
84
+ return this.payload.logoUrlDark;
85
+ }
75
86
  /**
76
87
  * @return The description of this App
77
88
  */
@@ -18,6 +18,7 @@ import { HttpApiRequest } from '../service/http-api-request.js';
18
18
  import { User } from "./User.js";
19
19
  import { Template } from "./Template.js";
20
20
  import { Collection } from "./Collection.js";
21
+ import { Conversation } from "./Conversation.js";
21
22
  /**
22
23
  * This is the main entry point of the [bkper-js](https://www.npmjs.com/package/bkper-js) library.
23
24
  *
@@ -84,6 +85,17 @@ export class Bkper {
84
85
  return apps.map(app => new App(app));
85
86
  });
86
87
  }
88
+ /**
89
+ * Gets all [[Conversations]] available for the user.
90
+ *
91
+ * @returns The retrieved list of Conversations
92
+ */
93
+ static getConversations() {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ let conversations = yield AppService.getConversations();
96
+ return conversations.map(c => new Conversation(c));
97
+ });
98
+ }
87
99
  /**
88
100
  * Gets all [[Templates]] available for the user.
89
101
  *
@@ -0,0 +1,73 @@
1
+ import { Agent } from "./Agent.js";
2
+ import { Message } from "./Message.js";
3
+ /**
4
+ * Defines a Conversation on Bkper.
5
+ *
6
+ * A Conversation represents an interaction between [[Users]] and [[Apps]].
7
+ *
8
+ * @public
9
+ */
10
+ export class Conversation {
11
+ constructor(payload) {
12
+ this.payload = payload || {};
13
+ }
14
+ /**
15
+ * @returns The wrapped plain json object
16
+ */
17
+ json() {
18
+ return Object.assign({}, this.payload);
19
+ }
20
+ /**
21
+ *
22
+ * @returns The Conversation universal identifier
23
+ */
24
+ getId() {
25
+ return this.payload.id;
26
+ }
27
+ /**
28
+ *
29
+ * @returns The title of the Conversation
30
+ */
31
+ getTitle() {
32
+ return this.payload.title;
33
+ }
34
+ /**
35
+ *
36
+ * @returns The Agent associated to this Conversation
37
+ */
38
+ getAgent() {
39
+ return this.payload.agent ? new Agent(this.payload.agent) : undefined;
40
+ }
41
+ /**
42
+ *
43
+ * @returns The Date the Conversation was created
44
+ */
45
+ getCreatedAt() {
46
+ return this.payload.createdAt ? new Date(this.payload.createdAt) : undefined;
47
+ }
48
+ /**
49
+ *
50
+ * @returns The Date the Conversation was last updated
51
+ */
52
+ getUpdatedAt() {
53
+ return this.payload.updatedAt ? new Date(this.payload.updatedAt) : undefined;
54
+ }
55
+ /**
56
+ *
57
+ * @returns The Messages associated to this Conversation
58
+ */
59
+ getMessages() {
60
+ if (this.messages !== undefined) {
61
+ return this.messages;
62
+ }
63
+ let messages = [];
64
+ if (this.payload.messages) {
65
+ for (const message of this.payload.messages) {
66
+ messages.push(new Message(this, message));
67
+ }
68
+ }
69
+ this.messages = messages;
70
+ return this.messages;
71
+ }
72
+ }
73
+ //# sourceMappingURL=Conversation.js.map
@@ -40,7 +40,7 @@ export class Event {
40
40
  return this.payload.user ? new User(this.payload.user) : undefined;
41
41
  }
42
42
  /**
43
- * @returns The user who performed the Event
43
+ * @returns The Agent who performed the Event
44
44
  */
45
45
  getAgent() {
46
46
  return this.payload.agent ? new Agent(this.payload.agent) : undefined;
@@ -0,0 +1,57 @@
1
+ import { Agent } from "./Agent.js";
2
+ import { User } from "./User.js";
3
+ /**
4
+ * Defines a Message on Bkper.
5
+ *
6
+ * A Message is a building block of a [[Conversation]].
7
+ *
8
+ * @public
9
+ */
10
+ export class Message {
11
+ constructor(conversation, payload) {
12
+ this.conversation = conversation;
13
+ this.payload = payload || {};
14
+ }
15
+ /**
16
+ * @returns The wrapped plain json object
17
+ */
18
+ json() {
19
+ return Object.assign({}, this.payload);
20
+ }
21
+ /**
22
+ *
23
+ * @returns The Message universal identifier
24
+ */
25
+ getId() {
26
+ return this.payload.id;
27
+ }
28
+ /**
29
+ *
30
+ * @returns The Agent who created the Message, if any
31
+ */
32
+ getAgent() {
33
+ return this.payload.agent ? new Agent(this.payload.agent) : undefined;
34
+ }
35
+ /**
36
+ *
37
+ * @returns The User who created the Message, if any
38
+ */
39
+ getUser() {
40
+ return this.payload.user ? new User(this.payload.user) : undefined;
41
+ }
42
+ /**
43
+ *
44
+ * @returns The Date the Message was created
45
+ */
46
+ getCreatedAt() {
47
+ return this.payload.createdAt ? new Date(this.payload.createdAt) : undefined;
48
+ }
49
+ /**
50
+ *
51
+ * @returns The content text of the Message
52
+ */
53
+ getContent() {
54
+ return this.payload.content;
55
+ }
56
+ }
57
+ //# sourceMappingURL=Message.js.map
@@ -22,6 +22,13 @@ export function getApps() {
22
22
  return appsJson;
23
23
  });
24
24
  }
25
+ export function getConversations() {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ var _a;
28
+ const response = yield new HttpApiRequest(`v5/apps/conversations`).setMethod('GET').fetch();
29
+ return ((_a = response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
30
+ });
31
+ }
25
32
  export function createApp(app) {
26
33
  return __awaiter(this, void 0, void 0, function* () {
27
34
  var response = yield new HttpApiRequest(`v5/apps`).setMethod('POST').setPayload(app).fetch();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "1.29.1",
3
+ "version": "1.31.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.14.0"
37
+ "@bkper/bkper-api-types": "^5.15.2"
38
38
  },
39
39
  "dependencies": {
40
40
  "@google-cloud/local-auth": "^3.0.1",