@zohoim/client-sdk 1.0.0-poc1
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/es/domain/entities/Actor/ActorType.js +6 -0
- package/es/domain/entities/Actor/index.js +2 -0
- package/es/domain/entities/Agent/Agent.js +111 -0
- package/es/domain/entities/Agent/index.js +2 -0
- package/es/domain/entities/index.js +2 -0
- package/es/domain/errors/ValidationError.js +7 -0
- package/es/domain/index.js +3 -0
- package/es/domain/interfaces/channels/IChannelAgent.js +6 -0
- package/es/domain/interfaces/channels/index.js +2 -0
- package/es/domain/interfaces/index.js +1 -0
- package/es/domain/services/channels/ChannelAgentService.js +14 -0
- package/es/domain/services/channels/index.js +2 -0
- package/es/domain/services/index.js +1 -0
- package/es/index.html +25 -0
- package/es/index.js +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import ValidationError from '../../errors/ValidationError';
|
|
2
|
+
import ActorType from '../Actor/ActorType';
|
|
3
|
+
export default class Agent {
|
|
4
|
+
constructor() {
|
|
5
|
+
let {
|
|
6
|
+
id = '',
|
|
7
|
+
name = '',
|
|
8
|
+
email = '',
|
|
9
|
+
photoURL = '',
|
|
10
|
+
zuid = '',
|
|
11
|
+
type = ''
|
|
12
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
13
|
+
this.validateFields({
|
|
14
|
+
id,
|
|
15
|
+
email,
|
|
16
|
+
name,
|
|
17
|
+
zuid
|
|
18
|
+
});
|
|
19
|
+
this._id = id;
|
|
20
|
+
this._name = name;
|
|
21
|
+
this._email = email;
|
|
22
|
+
this._photoURL = photoURL;
|
|
23
|
+
this._zuid = zuid;
|
|
24
|
+
this.setType(type);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
validateFields(_ref) {
|
|
28
|
+
let {
|
|
29
|
+
id,
|
|
30
|
+
email,
|
|
31
|
+
name,
|
|
32
|
+
zuid
|
|
33
|
+
} = _ref;
|
|
34
|
+
this.validateId(id);
|
|
35
|
+
this.validateEmail(email);
|
|
36
|
+
this.validateName(name);
|
|
37
|
+
this.validateZuid(zuid);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static validateId(id) {
|
|
41
|
+
if (!id) {
|
|
42
|
+
throw new ValidationError('Agent ID is required');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static validateEmail(email) {
|
|
47
|
+
if (!email) {
|
|
48
|
+
throw new ValidationError('Agent email is required');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static validateName(name) {
|
|
53
|
+
if (!name) {
|
|
54
|
+
throw new ValidationError('Agent name is required');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static validateZuid(zuid) {
|
|
59
|
+
if (!zuid) {
|
|
60
|
+
throw new ValidationError('Agent zuid is required');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static validateType(type) {
|
|
65
|
+
return type === ActorType.AGENT;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
setType(type) {
|
|
69
|
+
if (!Agent.validateType(type)) {
|
|
70
|
+
throw new Error('Invalid actor type. Must be AGENT');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
this._type = type;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get id() {
|
|
77
|
+
return this._id;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get name() {
|
|
81
|
+
return this._name;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get email() {
|
|
85
|
+
return this._email;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get photoURL() {
|
|
89
|
+
return this._photoURL;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get zuid() {
|
|
93
|
+
return this._zuid;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
get type() {
|
|
97
|
+
return this._type;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
toJSON() {
|
|
101
|
+
return {
|
|
102
|
+
id: this._id,
|
|
103
|
+
name: this._name,
|
|
104
|
+
email: this._email,
|
|
105
|
+
photoURL: this._photoURL,
|
|
106
|
+
zuid: this._zuid,
|
|
107
|
+
type: this._type
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './channels';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import IChannelAgent from '../../interfaces/channels/IChannelAgent';
|
|
2
|
+
export default class ChannelAgentService extends IChannelAgent {
|
|
3
|
+
constructor(channelAPI, channelAgentAdapter) {
|
|
4
|
+
super();
|
|
5
|
+
this.channelAPI = channelAPI;
|
|
6
|
+
this.channelAgentAdapter = channelAgentAdapter;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async getChannelAgents() {
|
|
10
|
+
const channelAgents = await this.channelAPI.getChannelAgents();
|
|
11
|
+
return channelAgents.map(this.channelAgentAdapter.adapt);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './channels';
|
package/es/index.html
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en" dir="{{--dir}}">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8" />
|
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
|
+
<link rel="stylesheet" href="https://webfonts.zoho.com/css?family=Poppins:400,600,700" />
|
|
9
|
+
<link rel="stylesheet"
|
|
10
|
+
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/styles/github-dark.min.css" />
|
|
11
|
+
<title>Demo Docs</title>
|
|
12
|
+
<script src="https://kit.fontawesome.com/6812a5e4e0.js" crossorigin="anonymous"></script>
|
|
13
|
+
<style>
|
|
14
|
+
#root {
|
|
15
|
+
height: 100%;
|
|
16
|
+
width: 100%;
|
|
17
|
+
}
|
|
18
|
+
</style>
|
|
19
|
+
</head>
|
|
20
|
+
|
|
21
|
+
<body>
|
|
22
|
+
<div id="root" data-mode="light" data-theme="blue" class="zd-contrast"></div>
|
|
23
|
+
</body>
|
|
24
|
+
|
|
25
|
+
</html>
|
package/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './domain';
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zohoim/client-sdk",
|
|
3
|
+
"version": "1.0.0-poc1",
|
|
4
|
+
"description": "To have the client sdk for the IM",
|
|
5
|
+
"main": "es/index.js",
|
|
6
|
+
"module": "es/index.js",
|
|
7
|
+
"author": "ZohoDesk - IM Team",
|
|
8
|
+
"license": "ISC",
|
|
9
|
+
"private": false,
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./es/index.js",
|
|
15
|
+
"./interfaces": "./es/interfaces/index.js",
|
|
16
|
+
"./entities": "./es/entities/index.js",
|
|
17
|
+
"./services": "./es/services/index.js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"es",
|
|
21
|
+
"!**/__tests__"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"start": "cbt start --config_file=./cbt.config.js",
|
|
25
|
+
"build": "react-cli build:component:es",
|
|
26
|
+
"build_watch": "npm run build -- -w",
|
|
27
|
+
"clean": "react-cli clean unittest coverage es result.json",
|
|
28
|
+
"rtl": "react-cli rtl ./src ./es",
|
|
29
|
+
"prepare": "npm run clean && npm run build && npm run rtl",
|
|
30
|
+
"test": "react-cli test",
|
|
31
|
+
"docs": "react-cli docs"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@zohodesk-private/client_dev_cert": "1.0.5",
|
|
35
|
+
"@zohodesk/client_build_tool": "0.0.6-exp.37",
|
|
36
|
+
"@zohodesk/docs-builder": "1.0.2",
|
|
37
|
+
"@testing-library/jest-dom": "^5.16.5"
|
|
38
|
+
}
|
|
39
|
+
}
|