@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.4 → 0.0.1-alpha.40
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/client/chat.client.d.ts +3 -2
- package/lib/client/chat.client.js +98 -33
- package/lib/client/contact-method.client.d.ts +9 -1
- package/lib/client/contact-method.client.js +48 -32
- package/lib/client/http.client.d.ts +11 -7
- package/lib/client/http.client.js +138 -41
- package/lib/client/middleware.client.d.ts +4 -3
- package/lib/client/middleware.client.js +100 -35
- package/lib/contract/custom-component/contact-method-item.js +12 -34
- package/lib/contract/custom-component/contact-method-list.js +6 -34
- package/lib/contract/custom-component/contact-method.js +12 -17
- package/lib/contract/enum/server-entry-type.enum.d.ts +3 -2
- package/lib/contract/enum/server-entry-type.enum.js +5 -7
- package/lib/contract/model/conversation-api-model/list.model.js +1 -2
- package/lib/contract/model/conversation-api-model/message.model.js +1 -2
- package/lib/contract/model/http/action.model.js +1 -2
- package/lib/contract/model/http/client-action.model.js +1 -2
- package/lib/contract/model/http/client-envelope.model.js +1 -2
- package/lib/contract/model/http/connect-options.model.js +1 -2
- package/lib/contract/model/http/global-state.model.js +1 -2
- package/lib/contract/model/http/http-client-options.model.js +1 -2
- package/lib/contract/model/http/server-entry.model.js +1 -2
- package/lib/contract/model/http/server-envelope.model.js +1 -2
- package/lib/contract/model/middleware/aggregator-state.model.js +1 -2
- package/lib/contract/model/shared/loose-object.model.js +1 -2
- package/lib/helper/chat.helper.js +1 -4
- package/lib/helper/http.helper.d.ts +1 -1
- package/lib/helper/http.helper.js +8 -13
- package/lib/helper/middleware.helper.d.ts +1 -1
- package/lib/helper/middleware.helper.js +7 -11
- package/lib/helper/store.helper.d.ts +4 -3
- package/lib/helper/store.helper.js +105 -16
- package/lib/index.js +2 -8
- package/lib/interface/entry.interface.d.ts +6 -3
- package/lib/interface/entry.interface.js +176 -57
- package/lib/interface/middleware/paging.interface.js +3 -5
- package/lib/interface/middleware/processor.interface.js +1 -3
- package/lib/plugin.d.ts +2 -2
- package/lib/plugin.js +73 -90
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +5 -0
- package/lib-esm/client/chat.client.d.ts +3 -2
- package/lib-esm/client/chat.client.js +81 -11
- package/lib-esm/client/contact-method.client.d.ts +9 -1
- package/lib-esm/client/contact-method.client.js +28 -6
- package/lib-esm/client/http.client.d.ts +11 -7
- package/lib-esm/client/http.client.js +125 -22
- package/lib-esm/client/middleware.client.d.ts +4 -3
- package/lib-esm/client/middleware.client.js +89 -19
- package/lib-esm/contract/custom-component/contact-method-item.js +4 -1
- package/lib-esm/contract/enum/server-entry-type.enum.d.ts +3 -2
- package/lib-esm/contract/enum/server-entry-type.enum.js +3 -2
- package/lib-esm/helper/http.helper.d.ts +1 -1
- package/lib-esm/helper/http.helper.js +7 -9
- package/lib-esm/helper/middleware.helper.d.ts +1 -1
- package/lib-esm/helper/middleware.helper.js +5 -6
- package/lib-esm/helper/store.helper.d.ts +4 -3
- package/lib-esm/helper/store.helper.js +103 -11
- package/lib-esm/interface/entry.interface.d.ts +6 -3
- package/lib-esm/interface/entry.interface.js +160 -39
- package/lib-esm/plugin.d.ts +2 -2
- package/lib-esm/plugin.js +66 -55
- package/lib-esm/utils.d.ts +1 -0
- package/lib-esm/utils.js +5 -0
- package/package.json +45 -45
- package/lib/interface/middleware/contact-expanded.interface.d.ts +0 -0
- package/lib/interface/middleware/contact-expanded.interface.js +0 -50
- package/lib/interface/middleware/legacy-contact-methods.interface.d.ts +0 -0
- package/lib/interface/middleware/legacy-contact-methods.interface.js +0 -394
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
1
2
|
import { Message } from '../contract/model/conversation-api-model/message.model';
|
|
2
3
|
import EntryInterface from '../interface/entry.interface';
|
|
3
4
|
export default class ChatClient {
|
|
4
5
|
entryInterface: EntryInterface;
|
|
5
|
-
constructor();
|
|
6
|
+
constructor(container: Container);
|
|
6
7
|
static initialize(user: any, agent: any): void;
|
|
7
|
-
processMessageArrayAndStoreIt(messages: Message[]): void
|
|
8
|
+
processMessageArrayAndStoreIt(messages: Message[]): Promise<void>;
|
|
8
9
|
updateMessageArrayAndStoreIt(messages: Message[]): void;
|
|
9
10
|
printUserMessageAndStoreIt(action: string): void;
|
|
10
11
|
private postUserMessage;
|
|
@@ -1,66 +1,131 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
4
9
|
};
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __values = (this && this.__values) || function(o) {
|
|
38
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
39
|
+
if (m) return m.call(o);
|
|
40
|
+
if (o && typeof o.length === "number") return {
|
|
41
|
+
next: function () {
|
|
42
|
+
if (o && i >= o.length) o = void 0;
|
|
43
|
+
return { value: o && o[i++], done: !o };
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
47
|
+
};
|
|
48
|
+
import { v4 as newGuid } from 'uuid';
|
|
49
|
+
import { ServerEntryTypeEnum } from '../contract/enum/server-entry-type.enum';
|
|
50
|
+
import { ChatHelper } from '../helper/chat.helper';
|
|
51
|
+
import { StoreHelper } from '../helper/store.helper';
|
|
52
|
+
import EntryInterface from '../interface/entry.interface';
|
|
11
53
|
var ChatClient = /** @class */ (function () {
|
|
12
|
-
function ChatClient() {
|
|
13
|
-
this.entryInterface = new
|
|
54
|
+
function ChatClient(container) {
|
|
55
|
+
this.entryInterface = new EntryInterface(container);
|
|
14
56
|
}
|
|
57
|
+
// Initialize from setting the user and agent for the Helper
|
|
15
58
|
ChatClient.initialize = function (user, agent) {
|
|
16
|
-
|
|
17
|
-
|
|
59
|
+
ChatHelper.setUser(user);
|
|
60
|
+
ChatHelper.setAgent(agent);
|
|
18
61
|
};
|
|
62
|
+
// function for posting the messages
|
|
19
63
|
ChatClient.prototype.processMessageArrayAndStoreIt = function (messages) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
+
var _a, _b, message;
|
|
66
|
+
var e_1, _c;
|
|
67
|
+
return __generator(this, function (_d) {
|
|
68
|
+
switch (_d.label) {
|
|
69
|
+
case 0:
|
|
70
|
+
try {
|
|
71
|
+
for (_a = __values(messages.filter(function (o) { return o && o != null; })), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
72
|
+
message = _b.value;
|
|
73
|
+
if (message.isUser)
|
|
74
|
+
this.postUserMessage(message);
|
|
75
|
+
else
|
|
76
|
+
this.postAgentMessage(message);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
80
|
+
finally {
|
|
81
|
+
try {
|
|
82
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
83
|
+
}
|
|
84
|
+
finally { if (e_1) throw e_1.error; }
|
|
85
|
+
}
|
|
86
|
+
return [4 /*yield*/, StoreHelper.insertOrUpdateMessageArrayStore(messages)];
|
|
87
|
+
case 1:
|
|
88
|
+
_d.sent();
|
|
89
|
+
return [2 /*return*/];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
28
92
|
});
|
|
29
|
-
store_helper_1.StoreHelper.insertOrUpdateMessageArrayStore(messages);
|
|
30
93
|
};
|
|
94
|
+
// function for updating current messages
|
|
31
95
|
ChatClient.prototype.updateMessageArrayAndStoreIt = function (messages) {
|
|
32
96
|
var conversationEntry = undefined;
|
|
33
97
|
messages.forEach(function (o) {
|
|
34
|
-
var message =
|
|
98
|
+
var message = StoreHelper.getMessage(o.id);
|
|
35
99
|
message === null || message === void 0 ? void 0 : message.conversationEntry.update(o.message);
|
|
36
100
|
conversationEntry = message === null || message === void 0 ? void 0 : message.conversationEntry;
|
|
37
101
|
});
|
|
38
|
-
|
|
102
|
+
StoreHelper.insertOrUpdateMessageArrayStore(messages, conversationEntry);
|
|
39
103
|
};
|
|
104
|
+
// function for posting a message for the user actions, such as button clicks
|
|
40
105
|
ChatClient.prototype.printUserMessageAndStoreIt = function (action) {
|
|
41
106
|
if (action == 'next' || action == 'help')
|
|
42
107
|
return;
|
|
43
|
-
var entry =
|
|
108
|
+
var entry = StoreHelper.getEntry(action);
|
|
44
109
|
var message = {
|
|
45
|
-
id: (
|
|
110
|
+
id: newGuid(),
|
|
46
111
|
message: !entry ? action : this.getTitleFromEntry(entry, action),
|
|
47
112
|
isUser: true,
|
|
48
113
|
};
|
|
49
114
|
this.postUserMessage(message);
|
|
50
|
-
|
|
115
|
+
StoreHelper.insertOrUpdateMessageArrayStore([message]);
|
|
51
116
|
};
|
|
52
117
|
ChatClient.prototype.postUserMessage = function (message) {
|
|
53
|
-
|
|
118
|
+
ChatHelper.getUser().print(message.message);
|
|
54
119
|
};
|
|
55
120
|
ChatClient.prototype.postAgentMessage = function (message) {
|
|
56
|
-
message.conversationEntry =
|
|
121
|
+
message.conversationEntry = ChatHelper.getAgent().print(message.message);
|
|
57
122
|
};
|
|
58
123
|
ChatClient.prototype.getTitleFromEntry = function (entry, action) {
|
|
59
|
-
var entryType =
|
|
124
|
+
var entryType = ServerEntryTypeEnum[entry.type];
|
|
60
125
|
switch (entryType) {
|
|
61
|
-
case
|
|
126
|
+
case ServerEntryTypeEnum.List:
|
|
62
127
|
return this.getTitleFromList(entry, action);
|
|
63
|
-
case
|
|
128
|
+
case ServerEntryTypeEnum.Text:
|
|
64
129
|
return this.getTitleFromText(entry, action);
|
|
65
130
|
default:
|
|
66
131
|
return '';
|
|
@@ -77,4 +142,4 @@ var ChatClient = /** @class */ (function () {
|
|
|
77
142
|
};
|
|
78
143
|
return ChatClient;
|
|
79
144
|
}());
|
|
80
|
-
|
|
145
|
+
export default ChatClient;
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { ContactMethodPlatform } from '@telia-ace/knowledge-widget-adapters';
|
|
2
2
|
import { DataClient } from '@telia-ace/knowledge-widget-types-grid';
|
|
3
|
+
import { Container } from '@webprovisions/platform';
|
|
3
4
|
export declare class ContactMethodClient {
|
|
4
5
|
private static dataClient;
|
|
5
6
|
private static contactMethodPlatform;
|
|
6
7
|
private static contactMessageEntryArray;
|
|
7
8
|
private static agent;
|
|
8
9
|
private chatClient;
|
|
9
|
-
static
|
|
10
|
+
private static container;
|
|
11
|
+
constructor(container: Container);
|
|
12
|
+
static initialize(container: any, dataClient: DataClient, contactMethodPlatform: ContactMethodPlatform, agent: any): void;
|
|
10
13
|
handleNewForm: (errors: any, entry: any) => Promise<void>;
|
|
11
14
|
handleContactMethod: (input?: string) => Promise<void>;
|
|
12
15
|
validate(form: any): void;
|
|
13
16
|
private handleContactCategoryList;
|
|
14
17
|
private handleForm;
|
|
18
|
+
addContactMethod(contactMethod: any): {
|
|
19
|
+
contactMethods: any;
|
|
20
|
+
type: string;
|
|
21
|
+
noPadding: boolean;
|
|
22
|
+
};
|
|
15
23
|
private handleContactMethodList;
|
|
16
24
|
private handleSingleContactMethod;
|
|
17
25
|
private submit;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __assign = (this && this.__assign) || function () {
|
|
3
2
|
__assign = Object.assign || function(t) {
|
|
4
3
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -46,20 +45,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
46
|
}
|
|
48
47
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var knowledge_widget_types_grid_1 = require("@telia-ace/knowledge-widget-types-grid");
|
|
55
|
-
var widget_forms_1 = require("@telia-ace/widget-forms");
|
|
56
|
-
var uuid_1 = require("uuid");
|
|
57
|
-
var store_helper_1 = require("../helper/store.helper");
|
|
58
|
-
var chat_client_1 = __importDefault(require("./chat.client"));
|
|
48
|
+
import { DataType } from '@telia-ace/knowledge-widget-types-grid';
|
|
49
|
+
import { FormBuilder, submitButton } from '@telia-ace/widget-forms';
|
|
50
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
51
|
+
import { StoreHelper } from '../helper/store.helper';
|
|
52
|
+
import ChatClient from './chat.client';
|
|
59
53
|
var ContactMethodClient = /** @class */ (function () {
|
|
60
|
-
function ContactMethodClient() {
|
|
54
|
+
function ContactMethodClient(container) {
|
|
61
55
|
var _this = this;
|
|
62
|
-
|
|
56
|
+
// function for handling forms as contact methods
|
|
63
57
|
this.handleNewForm = function (errors, entry) { return __awaiter(_this, void 0, void 0, function () {
|
|
64
58
|
return __generator(this, function (_a) {
|
|
65
59
|
this.updateForm(entry.contactMethods, {
|
|
@@ -74,6 +68,7 @@ var ContactMethodClient = /** @class */ (function () {
|
|
|
74
68
|
return [2 /*return*/];
|
|
75
69
|
});
|
|
76
70
|
}); };
|
|
71
|
+
// function for receiving the contact method based on the input
|
|
77
72
|
this.handleContactMethod = function (input) {
|
|
78
73
|
if (input === void 0) { input = ''; }
|
|
79
74
|
return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -112,8 +107,8 @@ var ContactMethodClient = /** @class */ (function () {
|
|
|
112
107
|
return __generator(this, function (_a) {
|
|
113
108
|
switch (_a.label) {
|
|
114
109
|
case 0:
|
|
115
|
-
newGuid = (
|
|
116
|
-
type =
|
|
110
|
+
newGuid = uuidv4();
|
|
111
|
+
type = DataType.ContactMethodCategories;
|
|
117
112
|
return [4 /*yield*/, this.loadContactMethods(type)];
|
|
118
113
|
case 1:
|
|
119
114
|
contactMethods = _a.sent();
|
|
@@ -127,9 +122,9 @@ var ContactMethodClient = /** @class */ (function () {
|
|
|
127
122
|
var _a;
|
|
128
123
|
if ((_a = contactMethod === null || contactMethod === void 0 ? void 0 : contactMethod.body) === null || _a === void 0 ? void 0 : _a.form) {
|
|
129
124
|
var body = contactMethod.body;
|
|
130
|
-
var builder = new
|
|
125
|
+
var builder = new FormBuilder(body.form);
|
|
131
126
|
if (!body.form.layout || !body.form.layout.submit) {
|
|
132
|
-
builder.createComponent(
|
|
127
|
+
builder.createComponent(submitButton(properties.submit, 'submit'));
|
|
133
128
|
}
|
|
134
129
|
if (properties.errors) {
|
|
135
130
|
builder.setValidationErrors(properties.errors);
|
|
@@ -138,12 +133,15 @@ var ContactMethodClient = /** @class */ (function () {
|
|
|
138
133
|
}
|
|
139
134
|
return (contactMethod === null || contactMethod === void 0 ? void 0 : contactMethod.body) || {};
|
|
140
135
|
};
|
|
136
|
+
this.chatClient = new ChatClient(container);
|
|
141
137
|
}
|
|
142
|
-
ContactMethodClient.initialize = function (dataClient, contactMethodPlatform, agent) {
|
|
138
|
+
ContactMethodClient.initialize = function (container, dataClient, contactMethodPlatform, agent) {
|
|
143
139
|
this.dataClient = dataClient;
|
|
144
140
|
this.contactMethodPlatform = contactMethodPlatform;
|
|
145
141
|
this.agent = agent;
|
|
142
|
+
this.container = container;
|
|
146
143
|
};
|
|
144
|
+
// validation of the form provided
|
|
147
145
|
ContactMethodClient.prototype.validate = function (form) {
|
|
148
146
|
var _this = this;
|
|
149
147
|
var entry = ContactMethodClient.contactMessageEntryArray.find(function (o) { return o.id == form.schema.id; });
|
|
@@ -164,9 +162,17 @@ var ContactMethodClient = /** @class */ (function () {
|
|
|
164
162
|
});
|
|
165
163
|
this.printMessage(contactMethods.id, contactMethods, title);
|
|
166
164
|
};
|
|
165
|
+
ContactMethodClient.prototype.addContactMethod = function (contactMethod) {
|
|
166
|
+
contactMethod.expanded = true;
|
|
167
|
+
this.updateForm(contactMethod, {
|
|
168
|
+
submit: 'Submit',
|
|
169
|
+
errors: undefined,
|
|
170
|
+
});
|
|
171
|
+
return this.printMessage(contactMethod.id, contactMethod);
|
|
172
|
+
};
|
|
167
173
|
ContactMethodClient.prototype.handleContactMethodList = function (input, contactMethods) {
|
|
168
174
|
var title = input.split('/')[2];
|
|
169
|
-
var newGuid = (
|
|
175
|
+
var newGuid = uuidv4();
|
|
170
176
|
this.printMessage(newGuid, contactMethods, title);
|
|
171
177
|
};
|
|
172
178
|
ContactMethodClient.prototype.handleSingleContactMethod = function (contactMethods) {
|
|
@@ -180,7 +186,7 @@ var ContactMethodClient = /** @class */ (function () {
|
|
|
180
186
|
type: 'ace-knowledge-contact-method',
|
|
181
187
|
noPadding: true,
|
|
182
188
|
};
|
|
183
|
-
|
|
189
|
+
StoreHelper.insertOrUpdateMessageArrayStore([
|
|
184
190
|
{
|
|
185
191
|
id: entry.id,
|
|
186
192
|
message: message,
|
|
@@ -209,13 +215,14 @@ var ContactMethodClient = /** @class */ (function () {
|
|
|
209
215
|
noPadding: true,
|
|
210
216
|
};
|
|
211
217
|
entry.entry.update(message);
|
|
212
|
-
|
|
218
|
+
StoreHelper.insertOrUpdateMessageArrayStore([
|
|
213
219
|
{
|
|
214
220
|
id: entry.guid,
|
|
215
221
|
message: message,
|
|
216
222
|
isUser: false,
|
|
217
223
|
},
|
|
218
224
|
]);
|
|
225
|
+
return message;
|
|
219
226
|
}
|
|
220
227
|
else {
|
|
221
228
|
if (title)
|
|
@@ -226,7 +233,7 @@ var ContactMethodClient = /** @class */ (function () {
|
|
|
226
233
|
noPadding: true,
|
|
227
234
|
};
|
|
228
235
|
var entry = ContactMethodClient.agent.print(message);
|
|
229
|
-
|
|
236
|
+
StoreHelper.insertOrUpdateMessageArrayStore([
|
|
230
237
|
{
|
|
231
238
|
id: newGuid,
|
|
232
239
|
message: message,
|
|
@@ -238,31 +245,40 @@ var ContactMethodClient = /** @class */ (function () {
|
|
|
238
245
|
contactMethods: contactMethods,
|
|
239
246
|
entry: entry,
|
|
240
247
|
});
|
|
248
|
+
return message;
|
|
241
249
|
}
|
|
242
250
|
};
|
|
243
251
|
ContactMethodClient.prototype.loadContactMethods = function (dataType, id) {
|
|
244
252
|
if (id === void 0) { id = undefined; }
|
|
245
253
|
switch (dataType) {
|
|
246
|
-
case
|
|
247
|
-
return ContactMethodClient.
|
|
248
|
-
.
|
|
249
|
-
.then(function (
|
|
254
|
+
case DataType.ContactMethodCategories: {
|
|
255
|
+
return ContactMethodClient.container
|
|
256
|
+
.getAsync('matchingClient')
|
|
257
|
+
.then(function (matchingClient) {
|
|
258
|
+
return matchingClient.customRequest('/contactmethods', 'GET', {});
|
|
259
|
+
})
|
|
260
|
+
.then(function (contactMethods) {
|
|
261
|
+
return contactMethods;
|
|
262
|
+
});
|
|
263
|
+
// return ContactMethodClient.dataClient
|
|
264
|
+
// .fetch(DataType.ContactMethods, { contactMethodCategoryId: id })
|
|
265
|
+
// .then((contactMethods) => contactMethods);
|
|
250
266
|
}
|
|
251
|
-
case
|
|
267
|
+
case DataType.ContactMethods: {
|
|
252
268
|
if (!!id) {
|
|
253
269
|
return ContactMethodClient.dataClient
|
|
254
|
-
.fetch(
|
|
270
|
+
.fetch(DataType.ContactMethod, { contactMethodId: id })
|
|
255
271
|
.then(function (contactMethods) { return contactMethods; });
|
|
256
272
|
}
|
|
257
273
|
else {
|
|
258
274
|
return ContactMethodClient.dataClient
|
|
259
|
-
.fetch(
|
|
275
|
+
.fetch(DataType.ContactMethods, {})
|
|
260
276
|
.then(function (contactMethods) { return contactMethods; });
|
|
261
277
|
}
|
|
262
278
|
}
|
|
263
|
-
case
|
|
279
|
+
case DataType.ContactMethodCategories: {
|
|
264
280
|
return ContactMethodClient.dataClient
|
|
265
|
-
.fetch(
|
|
281
|
+
.fetch(DataType.ContactMethods, { contactMethodCategoryId: id })
|
|
266
282
|
.then(function (contactMethods) { return contactMethods; });
|
|
267
283
|
}
|
|
268
284
|
default: {
|
|
@@ -273,4 +289,4 @@ var ContactMethodClient = /** @class */ (function () {
|
|
|
273
289
|
ContactMethodClient.contactMessageEntryArray = [];
|
|
274
290
|
return ContactMethodClient;
|
|
275
291
|
}());
|
|
276
|
-
|
|
292
|
+
export { ContactMethodClient };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
2
2
|
export declare class HttpClient {
|
|
3
3
|
private endpointUrl;
|
|
4
4
|
private clientId;
|
|
@@ -7,16 +7,20 @@ export declare class HttpClient {
|
|
|
7
7
|
private options;
|
|
8
8
|
private middlewareClient;
|
|
9
9
|
private chatClient;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
private container;
|
|
11
|
+
constructor(endpoint: string, clientId: string, container: Container);
|
|
12
|
+
firstHit(): Promise<void>;
|
|
13
|
+
handleUpdate(action: string): Promise<any>;
|
|
14
|
+
handleInput(action: string): Promise<void>;
|
|
15
|
+
handleCategories(): Promise<void>;
|
|
16
|
+
handlePhrase(phrase: string): Promise<void>;
|
|
15
17
|
private postAndHandleTheData;
|
|
16
|
-
private
|
|
18
|
+
private postAndHandleTheUpdateData;
|
|
17
19
|
private getHttpOptions;
|
|
18
20
|
private constructInputEnvelope;
|
|
21
|
+
private constructCategoriesEnvelope;
|
|
19
22
|
private constructPhraseEnvelope;
|
|
20
23
|
private constructFirstHitEnvelope;
|
|
21
24
|
private handleResponseData;
|
|
25
|
+
private handleUpdateResponseData;
|
|
22
26
|
}
|