bkper-js 1.32.2 → 1.32.3
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 +2 -1
- package/lib/model/Bkper.js +9 -2
- package/lib/model/Conversation.js +3 -6
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1445,7 +1445,8 @@ export declare class Connection {
|
|
|
1445
1445
|
export declare class Conversation {
|
|
1446
1446
|
payload: bkper.Conversation;
|
|
1447
1447
|
|
|
1448
|
-
|
|
1448
|
+
|
|
1449
|
+
constructor(agent: Agent, payload?: bkper.Conversation);
|
|
1449
1450
|
/**
|
|
1450
1451
|
* @returns The wrapped plain json object
|
|
1451
1452
|
*/
|
package/lib/model/Bkper.js
CHANGED
|
@@ -19,6 +19,7 @@ import { User } from "./User.js";
|
|
|
19
19
|
import { Template } from "./Template.js";
|
|
20
20
|
import { Collection } from "./Collection.js";
|
|
21
21
|
import { Conversation } from "./Conversation.js";
|
|
22
|
+
import { Agent } from "./Agent.js";
|
|
22
23
|
/**
|
|
23
24
|
* This is the main entry point of the [bkper-js](https://www.npmjs.com/package/bkper-js) library.
|
|
24
25
|
*
|
|
@@ -92,8 +93,14 @@ export class Bkper {
|
|
|
92
93
|
*/
|
|
93
94
|
static getConversations() {
|
|
94
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
const conversationPayloads = yield AppService.getConversations();
|
|
97
|
+
let conversations = [];
|
|
98
|
+
for (const payload of conversationPayloads) {
|
|
99
|
+
const agent = new Agent(payload.agent);
|
|
100
|
+
const conversation = new Conversation(agent, payload);
|
|
101
|
+
conversations.push(conversation);
|
|
102
|
+
}
|
|
103
|
+
return conversations;
|
|
97
104
|
});
|
|
98
105
|
}
|
|
99
106
|
/**
|
|
@@ -18,11 +18,9 @@ import { Message } from "./Message.js";
|
|
|
18
18
|
* @public
|
|
19
19
|
*/
|
|
20
20
|
export class Conversation {
|
|
21
|
-
constructor(
|
|
21
|
+
constructor(agent, payload) {
|
|
22
|
+
this.agent = agent;
|
|
22
23
|
this.payload = payload || {};
|
|
23
|
-
if (agent) {
|
|
24
|
-
this.payload.agent = agent;
|
|
25
|
-
}
|
|
26
24
|
}
|
|
27
25
|
/**
|
|
28
26
|
* @returns The wrapped plain json object
|
|
@@ -102,8 +100,7 @@ export class Conversation {
|
|
|
102
100
|
*/
|
|
103
101
|
send() {
|
|
104
102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
|
|
106
|
-
const agentId = (_a = this.getAgent()) === null || _a === void 0 ? void 0 : _a.getId();
|
|
103
|
+
const agentId = this.agent.getId();
|
|
107
104
|
if (agentId) {
|
|
108
105
|
this.payload = yield ConversationService.send(agentId, this.payload);
|
|
109
106
|
}
|