bkper-js 1.32.3 → 1.32.4

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
@@ -1451,6 +1451,11 @@ export declare class Conversation {
1451
1451
  * @returns The wrapped plain json object
1452
1452
  */
1453
1453
  json(): bkper.Conversation;
1454
+ /**
1455
+ *
1456
+ * @returns The Agent associated to this Conversation
1457
+ */
1458
+ getAgent(): Agent;
1454
1459
  /**
1455
1460
  *
1456
1461
  * @returns The Conversation universal identifier
@@ -1461,11 +1466,6 @@ export declare class Conversation {
1461
1466
  * @returns The title of the Conversation
1462
1467
  */
1463
1468
  getTitle(): string | undefined;
1464
- /**
1465
- *
1466
- * @returns The Agent associated to this Conversation
1467
- */
1468
- getAgent(): Agent | undefined;
1469
1469
  /**
1470
1470
  *
1471
1471
  * @returns The Date the Conversation was created
@@ -1489,6 +1489,7 @@ export declare class Conversation {
1489
1489
  */
1490
1490
  addMessage(message: Message): Conversation;
1491
1491
  /**
1492
+ *
1492
1493
  * @return The updated Conversation object
1493
1494
  */
1494
1495
  send(): Promise<Conversation>;
@@ -28,6 +28,13 @@ export class Conversation {
28
28
  json() {
29
29
  return Object.assign({}, this.payload);
30
30
  }
31
+ /**
32
+ *
33
+ * @returns The Agent associated to this Conversation
34
+ */
35
+ getAgent() {
36
+ return this.agent;
37
+ }
31
38
  /**
32
39
  *
33
40
  * @returns The Conversation universal identifier
@@ -42,13 +49,6 @@ export class Conversation {
42
49
  getTitle() {
43
50
  return this.payload.title;
44
51
  }
45
- /**
46
- *
47
- * @returns The Agent associated to this Conversation
48
- */
49
- getAgent() {
50
- return this.payload.agent ? new Agent(this.payload.agent) : undefined;
51
- }
52
52
  /**
53
53
  *
54
54
  * @returns The Date the Conversation was created
@@ -96,13 +96,27 @@ export class Conversation {
96
96
  return this;
97
97
  }
98
98
  /**
99
+ *
99
100
  * @return The updated Conversation object
100
101
  */
101
102
  send() {
102
103
  return __awaiter(this, void 0, void 0, function* () {
103
104
  const agentId = this.agent.getId();
104
105
  if (agentId) {
105
- this.payload = yield ConversationService.send(agentId, this.payload);
106
+ const updatedPayload = yield ConversationService.send(agentId, this.payload);
107
+ this.payload = updatedPayload;
108
+ if (updatedPayload.agent) {
109
+ this.agent = new Agent(updatedPayload.agent);
110
+ }
111
+ if (updatedPayload.messages) {
112
+ if (!this.messages) {
113
+ this.messages = [];
114
+ }
115
+ for (const messagePayload of updatedPayload.messages) {
116
+ this.messages.push(new Message(this, messagePayload));
117
+ }
118
+ this.payload.messages = this.messages.map(message => message.json());
119
+ }
106
120
  }
107
121
  return this;
108
122
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "1.32.3",
3
+ "version": "1.32.4",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",