@zohoim/client-sdk 1.0.0-canned11 → 1.0.0-canned13
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/channels/ChannelService.js +6 -1
- package/es/application/services/index.js +2 -0
- package/es/application/services/integrationServices/IntegrationService.js +21 -0
- package/es/application/services/integrationServices/index.js +2 -0
- package/es/application/services/sessions/SessionService.js +6 -1
- package/es/application/services/userPreferences/UserPreferenceService.js +26 -0
- package/es/application/services/userPreferences/index.js +2 -0
- package/es/core/constants/ModuleNames.js +2 -0
- package/es/core/utils/validateSchema.js +23 -10
- package/es/domain/dto/channels/getChannelRequest.js +13 -0
- package/es/domain/dto/channels/getChannelsRequest.js +3 -1
- package/es/domain/dto/channels/index.js +2 -1
- package/es/domain/dto/index.js +2 -0
- package/es/domain/dto/integrationServices/getIntegrationsRequest.js +7 -0
- package/es/domain/dto/integrationServices/index.js +1 -0
- package/es/domain/dto/sessions/getSessionMetricsRequest.js +16 -0
- package/es/domain/dto/sessions/index.js +2 -1
- package/es/domain/dto/userPreferences/getPreferencesRequest.js +7 -0
- package/es/domain/dto/userPreferences/index.js +2 -0
- package/es/domain/dto/userPreferences/updatePreferencesRequest.js +9 -0
- package/es/domain/entities/Channel/Channel.js +22 -4
- package/es/domain/entities/IntegrationService/IntegrationService.js +8 -1
- package/es/domain/entities/Session/SessionMetrics.js +21 -0
- package/es/domain/entities/Session/index.js +2 -1
- package/es/domain/entities/TemplateMessage/TemplateTags.js +1 -2
- package/es/domain/entities/UserPreference/UserPreference.js +26 -0
- package/es/domain/entities/UserPreference/index.js +2 -0
- package/es/domain/entities/index.js +1 -0
- package/es/domain/enum/index.js +2 -1
- package/es/domain/enum/session/AssigneeFilter.js +6 -0
- package/es/domain/enum/session/SessionStatus.js +2 -1
- package/es/domain/enum/session/index.js +2 -1
- package/es/domain/enum/userPreference/CollapseSidePanel.js +5 -0
- package/es/domain/enum/userPreference/index.js +2 -0
- package/es/domain/interfaces/repositories/channels/IChannelRepository.js +7 -1
- package/es/domain/interfaces/repositories/index.js +2 -0
- package/es/domain/interfaces/repositories/integrationServices/IIntegrationServiceRepository.js +17 -0
- package/es/domain/interfaces/repositories/integrationServices/index.js +2 -0
- package/es/domain/interfaces/repositories/sessions/ISessionRepository.js +6 -1
- package/es/domain/interfaces/repositories/userPreferences/IUserPreferenceRepository.js +23 -0
- package/es/domain/interfaces/repositories/userPreferences/index.js +2 -0
- package/es/domain/schema/cannedMessage/TranslationsSchema.js +1 -1
- package/es/domain/schema/channel/ChannelSchema.js +39 -5
- package/es/domain/schema/index.js +1 -0
- package/es/domain/schema/integrationService/IntegrationServiceSchema.js +12 -0
- package/es/domain/schema/session/SessionMetrics/AssigneeSchema.js +20 -0
- package/es/domain/schema/session/SessionMetrics/SessionMetricsForAssigneeSchema.js +32 -0
- package/es/domain/schema/session/SessionMetrics/index.js +2 -0
- package/es/domain/schema/session/SessionMetricsSchema.js +9 -0
- package/es/domain/schema/session/index.js +2 -1
- package/es/domain/schema/userPreference/UserPreferenceSchema.js +9 -0
- package/es/domain/schema/userPreference/index.js +2 -0
- package/es/frameworks/managers/ModuleFactory.js +23 -1
- package/es/frameworks/managers/ModuleManager.js +1 -1
- package/es/frameworks/sdk/IMSDK.js +10 -0
- package/es/frameworks/sdk/integrationServices/IntegrationServiceSDK.js +30 -0
- package/es/frameworks/sdk/integrationServices/index.js +2 -0
- package/es/frameworks/sdk/userPreferences/UserPreferencesSDK.js +30 -0
- package/es/frameworks/sdk/userPreferences/index.js +2 -0
- package/es/infrastructure/adapters/cannedMessages/CannedMessageAdapter.js +3 -1
- package/es/infrastructure/adapters/channels/ChannelAdapter.js +16 -2
- package/es/infrastructure/adapters/index.js +2 -0
- package/es/infrastructure/adapters/integrationServices/IntegrationServiceAdapter.js +25 -0
- package/es/infrastructure/adapters/integrationServices/index.js +2 -0
- package/es/infrastructure/adapters/sessions/SessionMetricsAdapter.js +19 -0
- package/es/infrastructure/adapters/sessions/index.js +2 -1
- package/es/infrastructure/adapters/templateMessages/TemplateTagsAdapter.js +1 -3
- package/es/infrastructure/adapters/userPreferences/UserPreferenceAdapter.js +19 -0
- package/es/infrastructure/adapters/userPreferences/index.js +2 -0
- package/es/infrastructure/api/index.js +2 -0
- package/es/infrastructure/api/integrationServices/IntegrationServiceAPI.js +14 -0
- package/es/infrastructure/api/integrationServices/index.js +2 -0
- package/es/infrastructure/api/registry/getRegistryConfig.js +4 -0
- package/es/infrastructure/api/registry/integrationServices/constructIntegrationServiceEndPoint.js +10 -0
- package/es/infrastructure/api/registry/integrationServices/index.js +2 -0
- package/es/infrastructure/api/registry/integrationServices/integrationServiceAPIRegistry.js +12 -0
- package/es/infrastructure/api/registry/sessions/sessionAPIRegistry.js +8 -2
- package/es/infrastructure/api/registry/userPreferences/constructUserPreferencesEndPoint.js +10 -0
- package/es/infrastructure/api/registry/userPreferences/index.js +2 -0
- package/es/infrastructure/api/registry/userPreferences/userPreferenceAPIRegistry.js +17 -0
- package/es/infrastructure/api/sessions/SessionAPI.js +11 -1
- package/es/infrastructure/api/userPreferences/UserPreferenceAPI.js +24 -0
- package/es/infrastructure/api/userPreferences/index.js +2 -0
- package/es/infrastructure/repositories/channels/ChannelRepository.js +10 -1
- package/es/infrastructure/repositories/index.js +2 -0
- package/es/infrastructure/repositories/integrationServices/IntegrationServiceRepository.js +49 -0
- package/es/infrastructure/repositories/integrationServices/index.js +2 -0
- package/es/infrastructure/repositories/sessions/SessionRepository.js +14 -3
- package/es/infrastructure/repositories/templateMessages/TemplateMessageRepository.js +1 -1
- package/es/infrastructure/repositories/userPreferences/UserPreferenceRepository.js +58 -0
- package/es/infrastructure/repositories/userPreferences/index.js +2 -0
- package/package.json +1 -1
|
@@ -26,6 +26,18 @@ const IntegrationServiceSchema = {
|
|
|
26
26
|
logoURL: {
|
|
27
27
|
type: 'string',
|
|
28
28
|
required: false
|
|
29
|
+
},
|
|
30
|
+
domain: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
required: false
|
|
33
|
+
},
|
|
34
|
+
channelAlias: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
required: false
|
|
37
|
+
},
|
|
38
|
+
isParentAccountNeeded: {
|
|
39
|
+
type: 'boolean',
|
|
40
|
+
required: false
|
|
29
41
|
}
|
|
30
42
|
};
|
|
31
43
|
export default IntegrationServiceSchema;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AssigneeFilter } from '../../../enum';
|
|
2
|
+
import SessionMetricsForAssigneeSchema from './SessionMetricsForAssigneeSchema';
|
|
3
|
+
const AssigneeSchema = {
|
|
4
|
+
[AssigneeFilter.NONE]: {
|
|
5
|
+
type: 'object',
|
|
6
|
+
required: true,
|
|
7
|
+
schema: SessionMetricsForAssigneeSchema
|
|
8
|
+
},
|
|
9
|
+
[AssigneeFilter.MINE]: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
required: true,
|
|
12
|
+
schema: SessionMetricsForAssigneeSchema
|
|
13
|
+
},
|
|
14
|
+
[AssigneeFilter.UNASSIGNED]: {
|
|
15
|
+
type: 'object',
|
|
16
|
+
required: true,
|
|
17
|
+
schema: SessionMetricsForAssigneeSchema
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export default AssigneeSchema;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SessionStatus } from '../../../enum';
|
|
2
|
+
const SessionMetricsForAssigneeSchema = {
|
|
3
|
+
[SessionStatus.CREATED]: {
|
|
4
|
+
type: 'string',
|
|
5
|
+
required: true
|
|
6
|
+
},
|
|
7
|
+
[SessionStatus.OPEN]: {
|
|
8
|
+
type: 'string',
|
|
9
|
+
required: true
|
|
10
|
+
},
|
|
11
|
+
[SessionStatus.ON_PROGRESS]: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
[SessionStatus.ON_HOLD]: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
[SessionStatus.ENDED]: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
required: true
|
|
22
|
+
},
|
|
23
|
+
[SessionStatus.BLOCKED]: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
required: true
|
|
26
|
+
},
|
|
27
|
+
[SessionStatus.MISSED]: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
required: true
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export default SessionMetricsForAssigneeSchema;
|
|
@@ -8,6 +8,8 @@ import { ContactSDK } from '../sdk/contacts';
|
|
|
8
8
|
import { CannedMessageSDK } from '../sdk/cannedMessages';
|
|
9
9
|
import { TemplateMessageSDK } from '../sdk/templateMessages';
|
|
10
10
|
import { WhatsAppPricingSDK } from '../sdk/whatsAppPricing';
|
|
11
|
+
import { IntegrationServiceSDK } from '../sdk/integrationServices';
|
|
12
|
+
import { UserPreferencesSDK } from '../sdk/userPreferences';
|
|
11
13
|
const ModuleFactory = {
|
|
12
14
|
[ModuleNames.CHANNELS]: _ref => {
|
|
13
15
|
let {
|
|
@@ -89,10 +91,30 @@ const ModuleFactory = {
|
|
|
89
91
|
}).toJSON()
|
|
90
92
|
};
|
|
91
93
|
},
|
|
92
|
-
[ModuleNames.
|
|
94
|
+
[ModuleNames.INTEGRATION_SERVICES]: _ref9 => {
|
|
93
95
|
let {
|
|
94
96
|
config
|
|
95
97
|
} = _ref9;
|
|
98
|
+
return {
|
|
99
|
+
[ModuleTypes.AUTHENTICATED]: new IntegrationServiceSDK({
|
|
100
|
+
config
|
|
101
|
+
}).toJSON()
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
[ModuleNames.USER_PREFERENCES]: _ref10 => {
|
|
105
|
+
let {
|
|
106
|
+
config
|
|
107
|
+
} = _ref10;
|
|
108
|
+
return {
|
|
109
|
+
[ModuleTypes.AUTHENTICATED]: new UserPreferencesSDK({
|
|
110
|
+
config
|
|
111
|
+
}).toJSON()
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
[ModuleNames.WHATSAPP_PRICING]: _ref11 => {
|
|
115
|
+
let {
|
|
116
|
+
config
|
|
117
|
+
} = _ref11;
|
|
96
118
|
return {
|
|
97
119
|
[ModuleTypes.PUBLIC]: new WhatsAppPricingSDK({
|
|
98
120
|
config
|
|
@@ -3,7 +3,7 @@ import ModuleFactory from './ModuleFactory';
|
|
|
3
3
|
export default class ModuleManager {
|
|
4
4
|
constructor() {
|
|
5
5
|
this._modules = new Map();
|
|
6
|
-
this.supportedModules = [ModuleNames.CHANNELS, ModuleNames.SESSIONS, ModuleNames.BOTS, ModuleNames.MESSAGES, ModuleNames.AGENTS, ModuleNames.CONTACTS, ModuleNames.CANNED_MESSAGES, ModuleNames.TEMPLATE_MESSAGES, ModuleNames.WHATSAPP_PRICING];
|
|
6
|
+
this.supportedModules = [ModuleNames.CHANNELS, ModuleNames.SESSIONS, ModuleNames.BOTS, ModuleNames.MESSAGES, ModuleNames.AGENTS, ModuleNames.CONTACTS, ModuleNames.CANNED_MESSAGES, ModuleNames.TEMPLATE_MESSAGES, ModuleNames.INTEGRATION_SERVICES, ModuleNames.USER_PREFERENCES, ModuleNames.WHATSAPP_PRICING];
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
initialize(_ref) {
|
|
@@ -57,6 +57,14 @@ export default class IMSDK {
|
|
|
57
57
|
return this._moduleManager.getModulesByType(ModuleTypes.PUBLIC);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
get integrationServices() {
|
|
61
|
+
return this._moduleManager.getModuleByType(ModuleNames.INTEGRATION_SERVICES);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get userPreferences() {
|
|
65
|
+
return this._moduleManager.getModuleByType(ModuleNames.USER_PREFERENCES);
|
|
66
|
+
}
|
|
67
|
+
|
|
60
68
|
hasModule(moduleName) {
|
|
61
69
|
return this._moduleManager.hasModule(moduleName);
|
|
62
70
|
}
|
|
@@ -71,6 +79,8 @@ export default class IMSDK {
|
|
|
71
79
|
contacts: this.contacts,
|
|
72
80
|
cannedMessages: this.cannedMessages,
|
|
73
81
|
templateMessages: this.templateMessages,
|
|
82
|
+
integrationServices: this.integrationServices,
|
|
83
|
+
userPreferences: this.userPreferences,
|
|
74
84
|
public: this.public,
|
|
75
85
|
hasModule: this.hasModule.bind(this)
|
|
76
86
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IntegrationService } from '../../../application/services';
|
|
2
|
+
import { IntegrationServiceRepository } from '../../../infrastructure/repositories';
|
|
3
|
+
|
|
4
|
+
class IntegrationServiceSDK {
|
|
5
|
+
constructor(_ref) {
|
|
6
|
+
let {
|
|
7
|
+
config
|
|
8
|
+
} = _ref;
|
|
9
|
+
const {
|
|
10
|
+
integrationServiceAPI,
|
|
11
|
+
integrationServiceAdapter
|
|
12
|
+
} = config;
|
|
13
|
+
const integrationServiceRepository = new IntegrationServiceRepository({
|
|
14
|
+
integrationServiceAPI,
|
|
15
|
+
integrationServiceAdapter
|
|
16
|
+
}).toJSON();
|
|
17
|
+
const integrationService = new IntegrationService({
|
|
18
|
+
integrationServiceRepository
|
|
19
|
+
}).toJSON();
|
|
20
|
+
this.services = { ...integrationService
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
toJSON() {
|
|
25
|
+
return this.services;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default IntegrationServiceSDK;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { UserPreferenceService } from '../../../application/services';
|
|
2
|
+
import { UserPreferenceRepository } from '../../../infrastructure/repositories';
|
|
3
|
+
|
|
4
|
+
class UserPreferencesSDK {
|
|
5
|
+
constructor(_ref) {
|
|
6
|
+
let {
|
|
7
|
+
config
|
|
8
|
+
} = _ref;
|
|
9
|
+
const {
|
|
10
|
+
userPreferenceAPI,
|
|
11
|
+
userPreferenceAdapter
|
|
12
|
+
} = config;
|
|
13
|
+
const userPreferenceRepository = new UserPreferenceRepository({
|
|
14
|
+
userPreferenceAPI,
|
|
15
|
+
userPreferenceAdapter
|
|
16
|
+
}).toJSON();
|
|
17
|
+
const userPreferenceService = new UserPreferenceService({
|
|
18
|
+
userPreferenceRepository
|
|
19
|
+
}).toJSON();
|
|
20
|
+
this.services = { ...userPreferenceService
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
toJSON() {
|
|
25
|
+
return this.services;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default UserPreferencesSDK;
|
|
@@ -20,11 +20,13 @@ export default class CannedMessageAdapter extends IAdapter {
|
|
|
20
20
|
isActive: cannedMessageData.isActive,
|
|
21
21
|
isPrivate: cannedMessageData.isPrivate,
|
|
22
22
|
translations: cannedMessageData.translations,
|
|
23
|
+
primaryLanguage: cannedMessageData.primaryLanguage,
|
|
23
24
|
uuid: cannedMessageData.uuid,
|
|
24
25
|
meta: cannedMessageData.meta,
|
|
25
26
|
rejectedReason: cannedMessageData.rejectedReason,
|
|
26
27
|
modifiedTime: cannedMessageData.modifiedTime,
|
|
27
|
-
parameters: cannedMessageData.parameters || null
|
|
28
|
+
parameters: cannedMessageData.parameters || null,
|
|
29
|
+
wabaId: cannedMessageData.wabaId
|
|
28
30
|
}).toJSON();
|
|
29
31
|
} catch (error) {
|
|
30
32
|
throw new AdapterError(`Failed to adapt canned message: ${error.message}`);
|
|
@@ -8,18 +8,32 @@ export default class ChannelAdapter extends IAdapter {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
try {
|
|
11
|
+
const {
|
|
12
|
+
integrationServiceId = '',
|
|
13
|
+
integrationService = {}
|
|
14
|
+
} = rawChannel;
|
|
15
|
+
const updatedIntegrationServiceId = integrationServiceId || integrationService.id;
|
|
11
16
|
return new Channel({
|
|
12
17
|
id: rawChannel.id,
|
|
13
|
-
|
|
18
|
+
integrationServiceType: updatedIntegrationServiceId,
|
|
19
|
+
integrationServiceId: updatedIntegrationServiceId,
|
|
14
20
|
name: rawChannel.name,
|
|
15
21
|
defaultBotId: rawChannel.defaultBotId,
|
|
16
22
|
isActive: rawChannel.isActive,
|
|
23
|
+
isDeleted: rawChannel.isDeleted,
|
|
24
|
+
isSandBox: rawChannel.isSandBox,
|
|
17
25
|
createdTime: rawChannel.createdTime,
|
|
18
26
|
accountName: rawChannel.accountName,
|
|
27
|
+
universalLink: rawChannel.universalLink,
|
|
19
28
|
isSubscribed: rawChannel.isSubscribed,
|
|
20
29
|
createdBy: rawChannel.createdBy,
|
|
21
30
|
isOwner: rawChannel.isOwner,
|
|
22
|
-
photoURL: rawChannel.
|
|
31
|
+
photoURL: rawChannel.photoURL,
|
|
32
|
+
configParams: rawChannel.configParams,
|
|
33
|
+
authorizationPending: rawChannel.authorizationPending,
|
|
34
|
+
meta: rawChannel.meta,
|
|
35
|
+
logoURL: rawChannel.logoURL,
|
|
36
|
+
workspaceId: rawChannel.workspaceId
|
|
23
37
|
}).toJSON();
|
|
24
38
|
} catch (error) {
|
|
25
39
|
throw new AdapterError(`Failed to adapt channel: ${error.message}`);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AdapterError } from '../../../core/errors';
|
|
2
|
+
import { IntegrationService } from '../../../domain/entities';
|
|
3
|
+
import { IAdapter } from '../../../domain/interfaces';
|
|
4
|
+
export default class IntegrationServiceAdapter extends IAdapter {
|
|
5
|
+
adapt(integrationServiceData) {
|
|
6
|
+
if (!integrationServiceData) {
|
|
7
|
+
throw new AdapterError('IntegrationService data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new IntegrationService({
|
|
12
|
+
id: integrationServiceData.id,
|
|
13
|
+
label: integrationServiceData.label,
|
|
14
|
+
provider: integrationServiceData.provider,
|
|
15
|
+
domain: integrationServiceData.domain,
|
|
16
|
+
channelAlias: integrationServiceData.channelAlias,
|
|
17
|
+
logoURL: integrationServiceData.logoURL,
|
|
18
|
+
isParentAccountNeeded: integrationServiceData.isParentAccountNeeded
|
|
19
|
+
}).toJSON();
|
|
20
|
+
} catch (error) {
|
|
21
|
+
throw new AdapterError(`Failed to adapt integrationService: ${error.message}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AdapterError } from '../../../core/errors';
|
|
2
|
+
import { SessionMetrics } from '../../../domain/entities';
|
|
3
|
+
import { IAdapter } from '../../../domain/interfaces';
|
|
4
|
+
export default class SessionMetricsAdapter extends IAdapter {
|
|
5
|
+
adapt(sessionMetricsData) {
|
|
6
|
+
if (!sessionMetricsData) {
|
|
7
|
+
throw new AdapterError('Session metrics data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new SessionMetrics({
|
|
12
|
+
assignee: sessionMetricsData.assignee
|
|
13
|
+
}).toJSON();
|
|
14
|
+
} catch (error) {
|
|
15
|
+
throw new AdapterError(`Failed to adapt session Metrics Data: ${error.message}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
@@ -8,9 +8,7 @@ export default class TemplateTagsAdapter extends IAdapter {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
try {
|
|
11
|
-
return new TemplateTags(
|
|
12
|
-
tags: templateTagsData.tags
|
|
13
|
-
}).toJSON();
|
|
11
|
+
return new TemplateTags(templateTagsData.data).toJSON();
|
|
14
12
|
} catch (error) {
|
|
15
13
|
throw new AdapterError(`Failed to adapt TemplateTags: ${error.message}`);
|
|
16
14
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AdapterError } from '../../../core/errors';
|
|
2
|
+
import { UserPreference } from '../../../domain/entities';
|
|
3
|
+
import { IAdapter } from '../../../domain/interfaces';
|
|
4
|
+
export default class UserPreferencesAdapter extends IAdapter {
|
|
5
|
+
adapt(preferenceData) {
|
|
6
|
+
if (!preferenceData) {
|
|
7
|
+
throw new AdapterError('UserPreference data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new UserPreference({
|
|
12
|
+
collapseSidePanel: preferenceData.collapseSidePanel
|
|
13
|
+
}).toJSON();
|
|
14
|
+
} catch (error) {
|
|
15
|
+
throw new AdapterError(`Failed to adapt user preference: ${error.message}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getIntegrationsRequest } from '../../../domain/dto';
|
|
2
|
+
import { IIntegrationServiceRepository } from '../../../domain/interfaces/repositories';
|
|
3
|
+
export default class IntegrationServiceAPI extends IIntegrationServiceRepository {
|
|
4
|
+
async getIntegrations() {
|
|
5
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getIntegrationsRequest();
|
|
6
|
+
const operation = 'getIntegrations';
|
|
7
|
+
const httpRequest = await this.request({
|
|
8
|
+
request,
|
|
9
|
+
operation
|
|
10
|
+
});
|
|
11
|
+
return httpRequest;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
@@ -7,8 +7,10 @@ import { agentAPIRegistry } from './agents';
|
|
|
7
7
|
import { contactAPIRegistry } from './contacts';
|
|
8
8
|
import { cannedMessageAPIRegistry } from './cannedMessages';
|
|
9
9
|
import { templateMessageAPIRegistry } from './templateMessages';
|
|
10
|
+
import { integrationServiceAPIRegistry } from './integrationServices';
|
|
10
11
|
import { whatsAppPricingAPIRegistry } from './whatsAppPricing';
|
|
11
12
|
import { ModuleNames } from '../../../core/constants';
|
|
13
|
+
import { userPreferenceAPIRegistry } from './userPreferences';
|
|
12
14
|
const APIRegistry = {
|
|
13
15
|
[ModuleNames.CHANNELS]: channelAPIRegistry,
|
|
14
16
|
[ModuleNames.SESSIONS]: sessionAPIRegistry,
|
|
@@ -18,6 +20,8 @@ const APIRegistry = {
|
|
|
18
20
|
[ModuleNames.CONTACTS]: contactAPIRegistry,
|
|
19
21
|
[ModuleNames.CANNED_MESSAGES]: cannedMessageAPIRegistry,
|
|
20
22
|
[ModuleNames.TEMPLATE_MESSAGES]: templateMessageAPIRegistry,
|
|
23
|
+
[ModuleNames.INTEGRATION_SERVICES]: integrationServiceAPIRegistry,
|
|
24
|
+
[ModuleNames.USER_PREFERENCES]: userPreferenceAPIRegistry,
|
|
21
25
|
[ModuleNames.WHATSAPP_PRICING]: whatsAppPricingAPIRegistry
|
|
22
26
|
};
|
|
23
27
|
export default function getRegistryConfig(module, operation) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HTTP_METHODS } from '../../../../core/constants';
|
|
2
|
+
import { getIntegrationsRequest } from '../../../../domain/dto';
|
|
3
|
+
import createAPIRegistry from '../createAPIRegistry';
|
|
4
|
+
import constructIntegrationServiceEndPoint from './constructIntegrationServiceEndPoint';
|
|
5
|
+
|
|
6
|
+
function getIntegrations() {
|
|
7
|
+
return createAPIRegistry(constructIntegrationServiceEndPoint(), HTTP_METHODS.GET, getIntegrationsRequest());
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
getIntegrations
|
|
12
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HTTP_METHODS } from '../../../../core/constants';
|
|
2
|
-
import { updateSessionAssigneeRequest, getSessionAttachmentsRequest, getSessionLastMessagesRequest, getSessionRequest, getSessionsRequest, markSessionAsReadRequest, updateSessionStatusRequest, pickupSessionRequest } from '../../../../domain/dto';
|
|
2
|
+
import { updateSessionAssigneeRequest, getSessionAttachmentsRequest, getSessionLastMessagesRequest, getSessionRequest, getSessionsRequest, markSessionAsReadRequest, updateSessionStatusRequest, pickupSessionRequest, getSessionMetricsRequest } from '../../../../domain/dto';
|
|
3
3
|
import createAPIRegistry from '../createAPIRegistry';
|
|
4
4
|
import constructSessionEndPoint from './constructSessionEndPoint';
|
|
5
5
|
const SINGLE_SESSION_URL = '/:sessionId';
|
|
@@ -7,6 +7,7 @@ const SESSION_ATTACHMENTS_URL = `${SINGLE_SESSION_URL}/attachments`;
|
|
|
7
7
|
const SESSION_LAST_MESSAGE = '/lastMessages';
|
|
8
8
|
const MARK_AS_READ = `${SINGLE_SESSION_URL}/markAsRead`;
|
|
9
9
|
const PICKUP_SESSION = `${SINGLE_SESSION_URL}/pickup`;
|
|
10
|
+
const SESSION_METRICS = '/metrics';
|
|
10
11
|
|
|
11
12
|
function pickupSession() {
|
|
12
13
|
return createAPIRegistry(constructSessionEndPoint(PICKUP_SESSION), HTTP_METHODS.PATCH, pickupSessionRequest());
|
|
@@ -40,6 +41,10 @@ function updateSessionStatus() {
|
|
|
40
41
|
return createAPIRegistry(constructSessionEndPoint(SINGLE_SESSION_URL), HTTP_METHODS.PATCH, updateSessionStatusRequest());
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
function getSessionMetrics() {
|
|
45
|
+
return createAPIRegistry(constructSessionEndPoint(SESSION_METRICS), HTTP_METHODS.GET, getSessionMetricsRequest());
|
|
46
|
+
}
|
|
47
|
+
|
|
43
48
|
export default {
|
|
44
49
|
updateAssignee,
|
|
45
50
|
getSessions,
|
|
@@ -48,5 +53,6 @@ export default {
|
|
|
48
53
|
getSessionLastMessages,
|
|
49
54
|
markSessionAsRead,
|
|
50
55
|
updateSessionStatus,
|
|
51
|
-
pickupSession
|
|
56
|
+
pickupSession,
|
|
57
|
+
getSessionMetrics
|
|
52
58
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HTTP_METHODS } from '../../../../core/constants';
|
|
2
|
+
import { getPreferencesRequest, updatePreferencesRequest } from '../../../../domain/dto';
|
|
3
|
+
import createAPIRegistry from '../createAPIRegistry';
|
|
4
|
+
import constructUserPreferencesEndPoint from './constructUserPreferencesEndPoint';
|
|
5
|
+
|
|
6
|
+
function getPreferences() {
|
|
7
|
+
return createAPIRegistry(constructUserPreferencesEndPoint(), HTTP_METHODS.GET, getPreferencesRequest());
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function updatePreferences() {
|
|
11
|
+
return createAPIRegistry(constructUserPreferencesEndPoint(), HTTP_METHODS.PUT, updatePreferencesRequest());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
getPreferences,
|
|
16
|
+
updatePreferences
|
|
17
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { updateSessionAssigneeRequest, getSessionsRequest, getSessionRequest, getSessionAttachmentsRequest, getSessionLastMessagesRequest, markSessionAsReadRequest, updateSessionStatusRequest, pickupSessionRequest } from '../../../domain/dto';
|
|
1
|
+
import { updateSessionAssigneeRequest, getSessionsRequest, getSessionRequest, getSessionAttachmentsRequest, getSessionLastMessagesRequest, markSessionAsReadRequest, updateSessionStatusRequest, pickupSessionRequest, getSessionMetricsRequest } from '../../../domain/dto';
|
|
2
2
|
import { ISessionRepository } from '../../../domain/interfaces/repositories';
|
|
3
3
|
export default class SessionAPI extends ISessionRepository {
|
|
4
4
|
async pickupSession() {
|
|
@@ -81,4 +81,14 @@ export default class SessionAPI extends ISessionRepository {
|
|
|
81
81
|
return httpRequest;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
async getSessionMetrics() {
|
|
85
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getSessionMetricsRequest();
|
|
86
|
+
const operation = 'getSessionMetrics';
|
|
87
|
+
const httpRequest = await this.request({
|
|
88
|
+
request,
|
|
89
|
+
operation
|
|
90
|
+
});
|
|
91
|
+
return httpRequest;
|
|
92
|
+
}
|
|
93
|
+
|
|
84
94
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getPreferencesRequest, updatePreferencesRequest } from '../../../domain/dto';
|
|
2
|
+
import { IUserPreferenceRepository } from '../../../domain/interfaces/repositories';
|
|
3
|
+
export default class UserPreferenceAPI extends IUserPreferenceRepository {
|
|
4
|
+
async getPreferences() {
|
|
5
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getPreferencesRequest();
|
|
6
|
+
const operation = 'getPreferences';
|
|
7
|
+
const httpRequest = await this.request({
|
|
8
|
+
request,
|
|
9
|
+
operation
|
|
10
|
+
});
|
|
11
|
+
return httpRequest;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async updatePreferences() {
|
|
15
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : updatePreferencesRequest();
|
|
16
|
+
const operation = 'updatePreferences';
|
|
17
|
+
const httpRequest = await this.request({
|
|
18
|
+
request,
|
|
19
|
+
operation
|
|
20
|
+
});
|
|
21
|
+
return httpRequest;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
@@ -40,9 +40,18 @@ export default class ChannelRepository extends IChannelRepository {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
async getChannel(request) {
|
|
44
|
+
return this.invokeAPI({
|
|
45
|
+
operation: 'getChannel',
|
|
46
|
+
request,
|
|
47
|
+
responseType: ResponseTypes.SINGLE
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
43
51
|
toJSON() {
|
|
44
52
|
return {
|
|
45
|
-
getChannels: this.getChannels.bind(this)
|
|
53
|
+
getChannels: this.getChannels.bind(this),
|
|
54
|
+
getChannel: this.getChannel.bind(this)
|
|
46
55
|
};
|
|
47
56
|
}
|
|
48
57
|
|