@zohoim/client-sdk 1.0.0-canned05 → 1.0.0-canned07
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/application/services/cannedMessages/CannedMessageService.js +6 -1
- package/es/domain/dto/cannedMessages/getCannedPlaceholdersRequest.js +10 -0
- package/es/domain/dto/cannedMessages/index.js +2 -1
- package/es/domain/entities/Placeholder/Placeholder.js +24 -0
- package/es/domain/entities/Placeholder/index.js +2 -0
- package/es/domain/entities/index.js +2 -1
- package/es/domain/interfaces/repositories/cannedMessages/ICannedMessageRepository.js +6 -1
- package/es/domain/schema/index.js +2 -1
- package/es/domain/schema/placeholder/PlaceholderSchema.js +19 -0
- package/es/domain/schema/placeholder/index.js +2 -0
- package/es/infrastructure/adapters/cannedMessages/CannedMessageAdapter.js +3 -2
- package/es/infrastructure/adapters/cannedMessages/TranslationAdapter.js +27 -0
- package/es/infrastructure/adapters/cannedMessages/index.js +2 -1
- package/es/infrastructure/adapters/index.js +2 -1
- package/es/infrastructure/adapters/placeholders/PlaceholderAdapter.js +22 -0
- package/es/infrastructure/adapters/placeholders/index.js +2 -0
- package/es/infrastructure/api/cannedMessages/CannedMessageAPI.js +11 -1
- package/es/infrastructure/api/registry/cannedMessages/cannedMessageAPIRegistry.js +7 -2
- package/es/infrastructure/repositories/cannedMessages/CannedMessageRepository.js +20 -5
- package/package.json +1 -1
|
@@ -48,6 +48,10 @@ export default class CannedMessageService extends ICannedMessageRepository {
|
|
|
48
48
|
return this.cannedMessageRepository.deleteTranslation(request);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
async getCannedPlaceholders(request) {
|
|
52
|
+
return this.cannedMessageRepository.getCannedPlaceholders(request);
|
|
53
|
+
}
|
|
54
|
+
|
|
51
55
|
toJSON() {
|
|
52
56
|
return {
|
|
53
57
|
getCannedMessages: this.getCannedMessages.bind(this),
|
|
@@ -59,7 +63,8 @@ export default class CannedMessageService extends ICannedMessageRepository {
|
|
|
59
63
|
disableCannedMessage: this.disableCannedMessage.bind(this),
|
|
60
64
|
addTranslation: this.addTranslation.bind(this),
|
|
61
65
|
updateTranslation: this.updateTranslation.bind(this),
|
|
62
|
-
deleteTranslation: this.deleteTranslation.bind(this)
|
|
66
|
+
deleteTranslation: this.deleteTranslation.bind(this),
|
|
67
|
+
getCannedPlaceholders: this.getCannedPlaceholders.bind(this)
|
|
63
68
|
};
|
|
64
69
|
}
|
|
65
70
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import RequestBuilder from '../RequestBuilder';
|
|
2
|
+
|
|
3
|
+
function getCannedPlaceholdersRequest() {
|
|
4
|
+
let {
|
|
5
|
+
params = {}
|
|
6
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7
|
+
return new RequestBuilder().withParams(params).build();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default getCannedPlaceholdersRequest;
|
|
@@ -7,4 +7,5 @@ export { default as disableCannedMessageRequest } from './disableCannedMessageRe
|
|
|
7
7
|
export { default as updateCannedMessageRequest } from './updateCannedMessageRequest';
|
|
8
8
|
export { default as addTranslationRequest } from './addTranslationRequest';
|
|
9
9
|
export { default as updateTranslationRequest } from './updateTranslationRequest';
|
|
10
|
-
export { default as deleteTranslationRequest } from './deleteTranslationRequest';
|
|
10
|
+
export { default as deleteTranslationRequest } from './deleteTranslationRequest';
|
|
11
|
+
export { default as getCannedPlaceholdersRequest } from './getCannedPlaceholdersRequest';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { validateSchema } from '../../../core/utils';
|
|
2
|
+
import { PlaceholderSchema } from '../../schema/placeholder';
|
|
3
|
+
export default class Placeholder {
|
|
4
|
+
constructor() {
|
|
5
|
+
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
6
|
+
const validatedData = validateSchema({
|
|
7
|
+
schema: PlaceholderSchema,
|
|
8
|
+
data,
|
|
9
|
+
entityName: 'Placeholder'
|
|
10
|
+
});
|
|
11
|
+
this.data = {
|
|
12
|
+
apiName: validatedData.apiName,
|
|
13
|
+
i18nFieldLabel: validatedData.i18nFieldLabel,
|
|
14
|
+
fieldLabel: validatedData.fieldLabel,
|
|
15
|
+
placeHolder: validatedData.placeHolder
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
toJSON() {
|
|
20
|
+
return { ...this.data
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-unused-vars */
|
|
2
2
|
import { ModuleNames } from '../../../../core/constants';
|
|
3
3
|
import BaseAPI from '../../../../infrastructure/api/BaseAPI';
|
|
4
|
-
import { getCannedMessageRequest, getCannedMessagesRequest, createCannedMessageRequest, updateCannedMessageRequest, deleteCannedMessageRequest, disableCannedMessageRequest, enableCannedMessageRequest, addTranslationRequest, updateTranslationRequest, deleteTranslationRequest } from '../../../dto';
|
|
4
|
+
import { getCannedMessageRequest, getCannedMessagesRequest, createCannedMessageRequest, updateCannedMessageRequest, deleteCannedMessageRequest, disableCannedMessageRequest, enableCannedMessageRequest, addTranslationRequest, updateTranslationRequest, deleteTranslationRequest, getCannedPlaceholdersRequest } from '../../../dto';
|
|
5
5
|
export default class ICannedMessageRepository extends BaseAPI {
|
|
6
6
|
constructor() {
|
|
7
7
|
super({
|
|
@@ -59,4 +59,9 @@ export default class ICannedMessageRepository extends BaseAPI {
|
|
|
59
59
|
throw new Error('Method not implemented.');
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
getCannedPlaceholders() {
|
|
63
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getCannedPlaceholdersRequest();
|
|
64
|
+
throw new Error('Method not implemented.');
|
|
65
|
+
}
|
|
66
|
+
|
|
62
67
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const PlaceholderSchema = {
|
|
2
|
+
apiName: {
|
|
3
|
+
type: 'string',
|
|
4
|
+
required: false
|
|
5
|
+
},
|
|
6
|
+
i18nFieldLabel: {
|
|
7
|
+
type: 'string',
|
|
8
|
+
required: true
|
|
9
|
+
},
|
|
10
|
+
fieldLabel: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
placeHolder: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
required: true
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export default PlaceholderSchema;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AdapterError } from '../../../core/errors';
|
|
2
|
-
import { CannedMessage } from '../../../domain/entities';
|
|
2
|
+
import { CannedMessage, Translation } from '../../../domain/entities';
|
|
3
3
|
import { IAdapter } from '../../../domain/interfaces';
|
|
4
4
|
export default class CannedMessageAdapter extends IAdapter {
|
|
5
5
|
adapt(cannedMessageData) {
|
|
@@ -8,6 +8,7 @@ export default class CannedMessageAdapter extends IAdapter {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
try {
|
|
11
|
+
const translations = Array.isArray(cannedMessageData.translations) ? cannedMessageData.translations.map(translation => new Translation(translation).toJSON()) : cannedMessageData.translations;
|
|
11
12
|
return new CannedMessage({
|
|
12
13
|
id: cannedMessageData.id,
|
|
13
14
|
title: cannedMessageData.title,
|
|
@@ -19,7 +20,7 @@ export default class CannedMessageAdapter extends IAdapter {
|
|
|
19
20
|
createdBy: cannedMessageData.createdBy,
|
|
20
21
|
isActive: cannedMessageData.isActive,
|
|
21
22
|
isPrivate: cannedMessageData.isPrivate,
|
|
22
|
-
translations
|
|
23
|
+
translations,
|
|
23
24
|
uuid: cannedMessageData.uuid,
|
|
24
25
|
meta: cannedMessageData.meta,
|
|
25
26
|
rejectedReason: cannedMessageData.rejectedReason,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AdapterError } from '../../../core/errors';
|
|
2
|
+
import { Translation } from '../../../domain/entities';
|
|
3
|
+
import { IAdapter } from '../../../domain/interfaces';
|
|
4
|
+
export default class TranslationAdapter extends IAdapter {
|
|
5
|
+
adapt(translationData) {
|
|
6
|
+
if (!translationData) {
|
|
7
|
+
throw new AdapterError('Translation data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new Translation({
|
|
12
|
+
id: translationData.id,
|
|
13
|
+
language: translationData.language,
|
|
14
|
+
message: translationData.message,
|
|
15
|
+
displayMessage: translationData.displayMessage,
|
|
16
|
+
uuid: translationData.uuid,
|
|
17
|
+
status: translationData.status,
|
|
18
|
+
modifiedTime: translationData.modifiedTime,
|
|
19
|
+
failedReason: translationData.failedReason,
|
|
20
|
+
templateItems: translationData.templateItems
|
|
21
|
+
}).toJSON();
|
|
22
|
+
} catch (error) {
|
|
23
|
+
throw new AdapterError(`Failed to adapt translation: ${error.message}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AdapterError } from '../../../core/errors';
|
|
2
|
+
import { Placeholder } from '../../../domain/entities/Placeholder';
|
|
3
|
+
import { IAdapter } from '../../../domain/interfaces';
|
|
4
|
+
export default class PlaceholderAdapter extends IAdapter {
|
|
5
|
+
adapt(placeholderData) {
|
|
6
|
+
if (!placeholderData) {
|
|
7
|
+
throw new AdapterError('Placeholder data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new Placeholder({
|
|
12
|
+
apiName: placeholderData.apiName,
|
|
13
|
+
i18nFieldLabel: placeholderData.i18nFieldLabel,
|
|
14
|
+
fieldLabel: placeholderData.fieldLabel,
|
|
15
|
+
placeHolder: placeholderData.placeHolder
|
|
16
|
+
}).toJSON();
|
|
17
|
+
} catch (error) {
|
|
18
|
+
throw new AdapterError(`Failed to adapt placeholder: ${error.message}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getCannedMessageRequest, getCannedMessagesRequest, createCannedMessageRequest, updateCannedMessageRequest, deleteCannedMessageRequest, enableCannedMessageRequest, disableCannedMessageRequest, addTranslationRequest, updateTranslationRequest, deleteTranslationRequest } from '../../../domain/dto';
|
|
1
|
+
import { getCannedMessageRequest, getCannedMessagesRequest, createCannedMessageRequest, updateCannedMessageRequest, deleteCannedMessageRequest, enableCannedMessageRequest, disableCannedMessageRequest, addTranslationRequest, updateTranslationRequest, deleteTranslationRequest, getCannedPlaceholdersRequest } from '../../../domain/dto';
|
|
2
2
|
import { ICannedMessageRepository } from '../../../domain/interfaces/repositories';
|
|
3
3
|
export default class CannedMessageAPI extends ICannedMessageRepository {
|
|
4
4
|
async getCannedMessages() {
|
|
@@ -101,4 +101,14 @@ export default class CannedMessageAPI extends ICannedMessageRepository {
|
|
|
101
101
|
return httpRequest;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
async getCannedPlaceholders() {
|
|
105
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getCannedPlaceholdersRequest();
|
|
106
|
+
const operation = 'getCannedPlaceholders';
|
|
107
|
+
const httpRequest = await this.request({
|
|
108
|
+
operation,
|
|
109
|
+
request
|
|
110
|
+
});
|
|
111
|
+
return httpRequest;
|
|
112
|
+
}
|
|
113
|
+
|
|
104
114
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HTTP_METHODS } from '../../../../core/constants';
|
|
2
|
-
import { getCannedMessageRequest, getCannedMessagesRequest, createCannedMessageRequest, updateCannedMessageRequest, deleteCannedMessageRequest, enableCannedMessageRequest, disableCannedMessageRequest, addTranslationRequest, updateTranslationRequest, deleteTranslationRequest } from '../../../../domain/dto';
|
|
2
|
+
import { getCannedMessageRequest, getCannedMessagesRequest, createCannedMessageRequest, updateCannedMessageRequest, deleteCannedMessageRequest, enableCannedMessageRequest, disableCannedMessageRequest, addTranslationRequest, updateTranslationRequest, deleteTranslationRequest, getCannedPlaceholdersRequest } from '../../../../domain/dto';
|
|
3
3
|
import constructCannedMessageEndPoint from './constructCannedMessageEndPoint';
|
|
4
4
|
import createAPIRegistry from '../createAPIRegistry';
|
|
5
5
|
|
|
@@ -43,6 +43,10 @@ function deleteTranslation() {
|
|
|
43
43
|
return createAPIRegistry(constructCannedMessageEndPoint('/:cannedMessageId/translations/:translationId'), HTTP_METHODS.DELETE, deleteTranslationRequest());
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
function getCannedPlaceholders() {
|
|
47
|
+
return createAPIRegistry(constructCannedMessageEndPoint('/placeholders'), HTTP_METHODS.GET, getCannedPlaceholdersRequest());
|
|
48
|
+
}
|
|
49
|
+
|
|
46
50
|
export default {
|
|
47
51
|
getCannedMessage,
|
|
48
52
|
getCannedMessages,
|
|
@@ -53,5 +57,6 @@ export default {
|
|
|
53
57
|
disableCannedMessage,
|
|
54
58
|
addTranslation,
|
|
55
59
|
updateTranslation,
|
|
56
|
-
deleteTranslation
|
|
60
|
+
deleteTranslation,
|
|
61
|
+
getCannedPlaceholders
|
|
57
62
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CannedMessageAdapter } from '../../adapters';
|
|
1
|
+
import { CannedMessageAdapter, PlaceholderAdapter, TranslationAdapter } from '../../adapters';
|
|
2
2
|
import { CannedMessageAPI } from '../../api';
|
|
3
3
|
import { ICannedMessageRepository } from '../../../domain/interfaces/repositories/cannedMessages';
|
|
4
4
|
import { ResponseTypes } from '../../../core/constants';
|
|
@@ -6,13 +6,16 @@ export default class CannedMessageRepository extends ICannedMessageRepository {
|
|
|
6
6
|
constructor(_ref) {
|
|
7
7
|
let {
|
|
8
8
|
cannedMessageAPI,
|
|
9
|
-
cannedMessageAdapter
|
|
9
|
+
cannedMessageAdapter,
|
|
10
|
+
placeholderAdapter
|
|
10
11
|
} = _ref;
|
|
11
12
|
super();
|
|
12
13
|
this.defaultAPI = new CannedMessageAPI();
|
|
13
14
|
this.customAPI = cannedMessageAPI;
|
|
14
15
|
this.cannedMessageAPI = this.createAPIProxy(this.customAPI, this.defaultAPI);
|
|
15
16
|
this.cannedMessageAdapter = cannedMessageAdapter || new CannedMessageAdapter();
|
|
17
|
+
this.translationAdapter = new TranslationAdapter();
|
|
18
|
+
this.placeholderAdapter = placeholderAdapter || new PlaceholderAdapter();
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
async invokeAPI(_ref2) {
|
|
@@ -88,14 +91,16 @@ export default class CannedMessageRepository extends ICannedMessageRepository {
|
|
|
88
91
|
async addTranslation(request) {
|
|
89
92
|
return this.invokeAPI({
|
|
90
93
|
operation: 'addTranslation',
|
|
91
|
-
request
|
|
94
|
+
request,
|
|
95
|
+
adapter: this.translationAdapter
|
|
92
96
|
});
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
async updateTranslation(request) {
|
|
96
100
|
return this.invokeAPI({
|
|
97
101
|
operation: 'updateTranslation',
|
|
98
|
-
request
|
|
102
|
+
request,
|
|
103
|
+
adapter: this.translationAdapter
|
|
99
104
|
});
|
|
100
105
|
}
|
|
101
106
|
|
|
@@ -107,6 +112,15 @@ export default class CannedMessageRepository extends ICannedMessageRepository {
|
|
|
107
112
|
});
|
|
108
113
|
}
|
|
109
114
|
|
|
115
|
+
async getCannedPlaceholders(request) {
|
|
116
|
+
return this.invokeAPI({
|
|
117
|
+
operation: 'getCannedPlaceholders',
|
|
118
|
+
request,
|
|
119
|
+
adapter: this.placeholderAdapter,
|
|
120
|
+
responseType: ResponseTypes.LIST
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
110
124
|
toJSON() {
|
|
111
125
|
return {
|
|
112
126
|
getCannedMessages: this.getCannedMessages.bind(this),
|
|
@@ -118,7 +132,8 @@ export default class CannedMessageRepository extends ICannedMessageRepository {
|
|
|
118
132
|
disableCannedMessage: this.disableCannedMessage.bind(this),
|
|
119
133
|
addTranslation: this.addTranslation.bind(this),
|
|
120
134
|
updateTranslation: this.updateTranslation.bind(this),
|
|
121
|
-
deleteTranslation: this.deleteTranslation.bind(this)
|
|
135
|
+
deleteTranslation: this.deleteTranslation.bind(this),
|
|
136
|
+
getCannedPlaceholders: this.getCannedPlaceholders.bind(this)
|
|
122
137
|
};
|
|
123
138
|
}
|
|
124
139
|
|