bkper-js 1.32.1 → 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 +12 -3
- package/lib/model/Bkper.js +9 -2
- package/lib/model/Conversation.js +5 -7
- package/lib/model/Message.js +11 -1
- 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
|
*/
|
|
@@ -1483,11 +1484,12 @@ export declare class Conversation {
|
|
|
1483
1484
|
/**
|
|
1484
1485
|
*
|
|
1485
1486
|
* @param message The Message to add to this Conversation
|
|
1487
|
+
*
|
|
1486
1488
|
* @returns This Conversation, for chaining
|
|
1487
1489
|
*/
|
|
1488
1490
|
addMessage(message: Message): Conversation;
|
|
1489
1491
|
/**
|
|
1490
|
-
* @return The
|
|
1492
|
+
* @return The updated Conversation object
|
|
1491
1493
|
*/
|
|
1492
1494
|
send(): Promise<Conversation>;
|
|
1493
1495
|
}
|
|
@@ -2035,9 +2037,16 @@ export declare class Message {
|
|
|
2035
2037
|
getCreatedAt(): Date | undefined;
|
|
2036
2038
|
/**
|
|
2037
2039
|
*
|
|
2038
|
-
* @returns The content
|
|
2040
|
+
* @returns The text content of the Message
|
|
2039
2041
|
*/
|
|
2040
2042
|
getContent(): string | undefined;
|
|
2043
|
+
/**
|
|
2044
|
+
*
|
|
2045
|
+
* @param content The text content of the Message
|
|
2046
|
+
*
|
|
2047
|
+
* @returns This Message, for chaining
|
|
2048
|
+
*/
|
|
2049
|
+
setContent(content: string): Message;
|
|
2041
2050
|
}
|
|
2042
2051
|
|
|
2043
2052
|
/**
|
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
|
|
@@ -86,6 +84,7 @@ export class Conversation {
|
|
|
86
84
|
/**
|
|
87
85
|
*
|
|
88
86
|
* @param message The Message to add to this Conversation
|
|
87
|
+
*
|
|
89
88
|
* @returns This Conversation, for chaining
|
|
90
89
|
*/
|
|
91
90
|
addMessage(message) {
|
|
@@ -97,12 +96,11 @@ export class Conversation {
|
|
|
97
96
|
return this;
|
|
98
97
|
}
|
|
99
98
|
/**
|
|
100
|
-
* @return The
|
|
99
|
+
* @return The updated Conversation object
|
|
101
100
|
*/
|
|
102
101
|
send() {
|
|
103
102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
|
|
105
|
-
const agentId = (_a = this.getAgent()) === null || _a === void 0 ? void 0 : _a.getId();
|
|
103
|
+
const agentId = this.agent.getId();
|
|
106
104
|
if (agentId) {
|
|
107
105
|
this.payload = yield ConversationService.send(agentId, this.payload);
|
|
108
106
|
}
|
package/lib/model/Message.js
CHANGED
|
@@ -48,10 +48,20 @@ export class Message {
|
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
*
|
|
51
|
-
* @returns The content
|
|
51
|
+
* @returns The text content of the Message
|
|
52
52
|
*/
|
|
53
53
|
getContent() {
|
|
54
54
|
return this.payload.content;
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @param content The text content of the Message
|
|
59
|
+
*
|
|
60
|
+
* @returns This Message, for chaining
|
|
61
|
+
*/
|
|
62
|
+
setContent(content) {
|
|
63
|
+
this.payload.content = content;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
56
66
|
}
|
|
57
67
|
//# sourceMappingURL=Message.js.map
|