@zohoim/client-sdk 1.0.0-canned07 → 1.0.0-canned08
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/CannedMessage/CannedMessage.js +1 -1
- package/es/domain/entities/CannedMessage/Translation.js +21 -2
- package/es/domain/entities/TemplateMessage/TemplateItemButton.js +48 -0
- package/es/domain/entities/TemplateMessage/TemplateItemFooter.js +27 -0
- package/es/domain/entities/TemplateMessage/TemplateItemHeader.js +48 -0
- package/es/domain/entities/TemplateMessage/index.js +4 -1
- package/es/domain/enum/cannedMessage/TemplateItemButtonType.js +2 -1
- package/es/domain/enum/cannedMessage/TemplateItemHeaderType.js +3 -1
- package/es/domain/schema/cannedMessage/TemplateItem/TemplateItemButtonsSchema.js +1 -1
- package/es/domain/schema/cannedMessage/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
import { validateSchema } from '../../../core/utils';
|
|
2
2
|
import TranslationsSchema from '../../schema/cannedMessage/TranslationsSchema';
|
|
3
|
+
import { TemplateItemButton, TemplateItemHeader, TemplateItemFooter } from '../TemplateMessage';
|
|
3
4
|
export default class Translation {
|
|
4
5
|
constructor() {
|
|
5
6
|
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
6
7
|
const validatedData = validateSchema({
|
|
7
8
|
schema: TranslationsSchema,
|
|
8
9
|
data,
|
|
9
|
-
entityName:
|
|
10
|
+
entityName: `Translation${data?.id ? `_${data.id}` : ''}`
|
|
10
11
|
});
|
|
12
|
+
const {
|
|
13
|
+
templateItems
|
|
14
|
+
} = validatedData;
|
|
15
|
+
let adaptedTemplateItems = null;
|
|
16
|
+
|
|
17
|
+
if (templateItems) {
|
|
18
|
+
const {
|
|
19
|
+
header,
|
|
20
|
+
footer,
|
|
21
|
+
buttons
|
|
22
|
+
} = templateItems;
|
|
23
|
+
adaptedTemplateItems = {
|
|
24
|
+
header: header ? new TemplateItemHeader(header).toJSON() : null,
|
|
25
|
+
footer: footer ? new TemplateItemFooter(footer).toJSON() : null,
|
|
26
|
+
buttons: Array.isArray(buttons) ? buttons.map(btn => new TemplateItemButton(btn).toJSON()) : null
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
11
30
|
this.data = {
|
|
12
31
|
id: validatedData.id,
|
|
13
32
|
language: validatedData.language,
|
|
@@ -17,7 +36,7 @@ export default class Translation {
|
|
|
17
36
|
status: validatedData.status,
|
|
18
37
|
modifiedTime: validatedData.modifiedTime,
|
|
19
38
|
failedReason: validatedData.failedReason,
|
|
20
|
-
templateItems:
|
|
39
|
+
templateItems: adaptedTemplateItems
|
|
21
40
|
};
|
|
22
41
|
}
|
|
23
42
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { validateSchema } from '../../../core/utils';
|
|
2
|
+
import { TemplateItemButtonType } from '../../enum';
|
|
3
|
+
import { TemplateItemButtonsSchema } from '../../schema';
|
|
4
|
+
export default class TemplateItemButton {
|
|
5
|
+
constructor() {
|
|
6
|
+
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7
|
+
const validatedData = validateSchema({
|
|
8
|
+
schema: TemplateItemButtonsSchema,
|
|
9
|
+
data,
|
|
10
|
+
entityName: 'TemplateItemButton'
|
|
11
|
+
});
|
|
12
|
+
this.data = {
|
|
13
|
+
type: validatedData.type,
|
|
14
|
+
message: validatedData.message,
|
|
15
|
+
action: validatedData.action
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static isPhoneNumber(type) {
|
|
20
|
+
return type === TemplateItemButtonType.PHONE_NUMBER;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static isURL(type) {
|
|
24
|
+
return type === TemplateItemButtonType.URL;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static isCallToAction(type) {
|
|
28
|
+
return TemplateItemButton.isPhoneNumber(type) || TemplateItemButton.isURL(type);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static isQuickReply(type) {
|
|
32
|
+
return type === TemplateItemButtonType.QUICK_REPLY;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static isOTP(type) {
|
|
36
|
+
return type === TemplateItemButtonType.OTP;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static isCatalog(type) {
|
|
40
|
+
return type === TemplateItemButtonType.CATALOG;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
toJSON() {
|
|
44
|
+
return { ...this.data
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { validateSchema } from '../../../core/utils';
|
|
2
|
+
import { TemplateItemFooterType } from '../../enum';
|
|
3
|
+
import { TemplateItemFooterSchema } from '../../schema';
|
|
4
|
+
export default class TemplateItemFooter {
|
|
5
|
+
constructor() {
|
|
6
|
+
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7
|
+
const validatedData = validateSchema({
|
|
8
|
+
schema: TemplateItemFooterSchema,
|
|
9
|
+
data,
|
|
10
|
+
entityName: 'TemplateItemFooter'
|
|
11
|
+
});
|
|
12
|
+
this.data = {
|
|
13
|
+
type: validatedData.type,
|
|
14
|
+
message: validatedData.message
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static isText(type) {
|
|
19
|
+
return type === TemplateItemFooterType.TEXT;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
toJSON() {
|
|
23
|
+
return { ...this.data
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { validateSchema } from '../../../core/utils';
|
|
2
|
+
import { TemplateItemHeaderType } from '../../enum';
|
|
3
|
+
import { TemplateItemHeaderSchema } from '../../schema';
|
|
4
|
+
export default class TemplateItemHeader {
|
|
5
|
+
constructor() {
|
|
6
|
+
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7
|
+
const validatedData = validateSchema({
|
|
8
|
+
schema: TemplateItemHeaderSchema,
|
|
9
|
+
data,
|
|
10
|
+
entityName: 'TemplateItemHeader'
|
|
11
|
+
});
|
|
12
|
+
this.data = {
|
|
13
|
+
type: validatedData.type,
|
|
14
|
+
message: validatedData.message,
|
|
15
|
+
attachment: validatedData.attachment
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static isNone(type) {
|
|
20
|
+
return type === TemplateItemHeaderType.NONE;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static isText(type) {
|
|
24
|
+
return type === TemplateItemHeaderType.TEXT;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static isImage(type) {
|
|
28
|
+
return type === TemplateItemHeaderType.IMAGE;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static isVideo(type) {
|
|
32
|
+
return type === TemplateItemHeaderType.VIDEO;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static isDocument(type) {
|
|
36
|
+
return type === TemplateItemHeaderType.DOCUMENT;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static isMedia(type) {
|
|
40
|
+
return TemplateItemHeader.isImage(type) || TemplateItemHeader.isVideo(type) || TemplateItemHeader.isDocument(type);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
toJSON() {
|
|
44
|
+
return { ...this.data
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import TemplateLanguage from './TemplateLanguage';
|
|
2
2
|
import TemplateCreditExhaustStatus from './TemplateCreditExhaustStatus';
|
|
3
|
-
|
|
3
|
+
import TemplateItemButton from './TemplateItemButton';
|
|
4
|
+
import TemplateItemHeader from './TemplateItemHeader';
|
|
5
|
+
import TemplateItemFooter from './TemplateItemFooter';
|
|
6
|
+
export { TemplateLanguage, TemplateCreditExhaustStatus, TemplateItemButton, TemplateItemHeader, TemplateItemFooter };
|