merchi_sdk_js 0.0.71 → 0.0.72
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/package.json +1 -1
- package/src/agent_conversation.js +63 -0
- package/src/merchi.js +3 -0
package/package.json
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { generateUUID } from './uuid.js';
|
|
2
|
+
import { addPropertyTo, serialise, fromJson, create, enumerateFiles, getOne, getList, fromJsonList } from './model.js';
|
|
3
|
+
import { User } from './user.js';
|
|
4
|
+
import { Domain } from './domain.js';
|
|
5
|
+
|
|
6
|
+
export function AgentConversation() {
|
|
7
|
+
this.resource = '/agent_conversations';
|
|
8
|
+
this.json = 'agentConversation';
|
|
9
|
+
this.temporaryId = generateUUID();
|
|
10
|
+
|
|
11
|
+
addPropertyTo(this, 'archived');
|
|
12
|
+
addPropertyTo(this, 'id');
|
|
13
|
+
addPropertyTo(this, 'conversationId');
|
|
14
|
+
addPropertyTo(this, 'initialPrompt');
|
|
15
|
+
addPropertyTo(this, 'creationDate');
|
|
16
|
+
addPropertyTo(this, 'serviceProvider');
|
|
17
|
+
addPropertyTo(this, 'user', User);
|
|
18
|
+
addPropertyTo(this, 'domain', Domain);
|
|
19
|
+
|
|
20
|
+
this.create = function (success, error, embed, as_domain) {
|
|
21
|
+
var data = serialise(this),
|
|
22
|
+
self = this;
|
|
23
|
+
function handleResponse(result) {
|
|
24
|
+
success(fromJson(self, result[self.json]));
|
|
25
|
+
}
|
|
26
|
+
create({resource: this.resource,
|
|
27
|
+
parameters: data[0],
|
|
28
|
+
files: enumerateFiles(data[1]),
|
|
29
|
+
as_domain: as_domain,
|
|
30
|
+
success: handleResponse,
|
|
31
|
+
error: error,
|
|
32
|
+
embed: embed});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
this.get = function (success, error, embed) {
|
|
36
|
+
var self = this;
|
|
37
|
+
function handleResponse(result) {
|
|
38
|
+
success(fromJson(self, result[self.json],
|
|
39
|
+
{makesDirty: false}));
|
|
40
|
+
}
|
|
41
|
+
getOne({resource: this.resource,
|
|
42
|
+
id: this.id(),
|
|
43
|
+
success: handleResponse,
|
|
44
|
+
error: error,
|
|
45
|
+
embed: embed});
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function AgentConversations() {
|
|
50
|
+
this.resource = '/agent_conversations';
|
|
51
|
+
this.json = 'agentConversations';
|
|
52
|
+
this.single = AgentConversation;
|
|
53
|
+
|
|
54
|
+
this.get = function (success, error, parameters) {
|
|
55
|
+
var self = this;
|
|
56
|
+
function handleResponse(result) {
|
|
57
|
+
success(fromJsonList(self, result, {makesDirty: false}));
|
|
58
|
+
}
|
|
59
|
+
getList(this.resource, handleResponse, error, parameters || {});
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
package/src/merchi.js
CHANGED
|
@@ -79,6 +79,7 @@ import { VariationsGroup } from './variations_group.js';
|
|
|
79
79
|
import { QuoteItem, QuoteItems } from './quote_item.js';
|
|
80
80
|
import { Quotes, Quote } from './quote.js';
|
|
81
81
|
import { InternalTag, InternalTags } from './internal_tag.js';
|
|
82
|
+
import { AgentConversation, AgentConversations } from './agent_conversation.js';
|
|
82
83
|
|
|
83
84
|
export function merchi(backendUri, websocketUri) {
|
|
84
85
|
getGlobal().merchiJsonpHandlers = {};
|
|
@@ -998,6 +999,8 @@ export function merchi(backendUri, websocketUri) {
|
|
|
998
999
|
'GSTrate': GSTrate,
|
|
999
1000
|
'Notification': Notification,
|
|
1000
1001
|
'notifications': new Notifications(),
|
|
1002
|
+
'AgentConversation': AgentConversation,
|
|
1003
|
+
'agentConversations': new AgentConversations(),
|
|
1001
1004
|
'SubscriptionPlan': SubscriptionPlan,
|
|
1002
1005
|
'subscriptionPlans': new SubscriptionPlans(),
|
|
1003
1006
|
'VariationField': VariationField,
|