@zohoim/client-sdk 1.1.0-calls → 1.1.0-calls1
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 +22 -9
- 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/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 +1 -0
- 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/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 +25 -3
- 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/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/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/userPreferences/UserPreferenceRepository.js +58 -0
- package/es/infrastructure/repositories/userPreferences/index.js +2 -0
- package/package.json +1 -1
|
@@ -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
|
import { CallSDK } from '../sdk/calls';
|
|
12
14
|
const ModuleFactory = {
|
|
13
15
|
[ModuleNames.CHANNELS]: _ref => {
|
|
@@ -90,20 +92,40 @@ const ModuleFactory = {
|
|
|
90
92
|
}).toJSON()
|
|
91
93
|
};
|
|
92
94
|
},
|
|
93
|
-
[ModuleNames.
|
|
95
|
+
[ModuleNames.INTEGRATION_SERVICES]: _ref9 => {
|
|
94
96
|
let {
|
|
95
97
|
config
|
|
96
98
|
} = _ref9;
|
|
97
99
|
return {
|
|
98
|
-
[ModuleTypes.
|
|
100
|
+
[ModuleTypes.AUTHENTICATED]: new IntegrationServiceSDK({
|
|
99
101
|
config
|
|
100
102
|
}).toJSON()
|
|
101
103
|
};
|
|
102
104
|
},
|
|
103
|
-
[ModuleNames.
|
|
105
|
+
[ModuleNames.USER_PREFERENCES]: _ref10 => {
|
|
104
106
|
let {
|
|
105
107
|
config
|
|
106
108
|
} = _ref10;
|
|
109
|
+
return {
|
|
110
|
+
[ModuleTypes.AUTHENTICATED]: new UserPreferencesSDK({
|
|
111
|
+
config
|
|
112
|
+
}).toJSON()
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
[ModuleNames.WHATSAPP_PRICING]: _ref11 => {
|
|
116
|
+
let {
|
|
117
|
+
config
|
|
118
|
+
} = _ref11;
|
|
119
|
+
return {
|
|
120
|
+
[ModuleTypes.PUBLIC]: new WhatsAppPricingSDK({
|
|
121
|
+
config
|
|
122
|
+
}).toJSON()
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
[ModuleNames.CALLS]: _ref12 => {
|
|
126
|
+
let {
|
|
127
|
+
config
|
|
128
|
+
} = _ref12;
|
|
107
129
|
return new CallSDK({
|
|
108
130
|
config
|
|
109
131
|
}).toJSON();
|
|
@@ -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, ModuleNames.CALLS];
|
|
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, ModuleNames.CALLS];
|
|
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
|
get calls() {
|
|
61
69
|
return this._moduleManager.getModule(ModuleNames.CALLS);
|
|
62
70
|
}
|
|
@@ -75,6 +83,8 @@ export default class IMSDK {
|
|
|
75
83
|
contacts: this.contacts,
|
|
76
84
|
cannedMessages: this.cannedMessages,
|
|
77
85
|
templateMessages: this.templateMessages,
|
|
86
|
+
integrationServices: this.integrationServices,
|
|
87
|
+
userPreferences: this.userPreferences,
|
|
78
88
|
public: this.public,
|
|
79
89
|
calls: this.calls,
|
|
80
90
|
hasModule: this.hasModule.bind(this)
|
|
@@ -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;
|
|
@@ -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}`);
|
|
@@ -8,5 +8,7 @@ export * from './contacts';
|
|
|
8
8
|
export * from './cannedMessages';
|
|
9
9
|
export * from './templateMessages';
|
|
10
10
|
export * from './customReplyExtension';
|
|
11
|
+
export * from './integrationServices';
|
|
12
|
+
export * from './userPreferences';
|
|
11
13
|
export * from './whatsAppPricing';
|
|
12
14
|
export * from './calls';
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -6,5 +6,7 @@ export * from './agents';
|
|
|
6
6
|
export * from './contacts';
|
|
7
7
|
export * from './cannedMessages';
|
|
8
8
|
export * from './templateMessages';
|
|
9
|
+
export * from './integrationServices';
|
|
10
|
+
export * from './userPreferences';
|
|
9
11
|
export * from './whatsAppPricing';
|
|
10
12
|
export * from './calls';
|
|
@@ -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,9 +7,11 @@ 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 { callAPIRegistry } from './calls';
|
|
12
13
|
import { ModuleNames } from '../../../core/constants';
|
|
14
|
+
import { userPreferenceAPIRegistry } from './userPreferences';
|
|
13
15
|
const APIRegistry = {
|
|
14
16
|
[ModuleNames.CHANNELS]: channelAPIRegistry,
|
|
15
17
|
[ModuleNames.SESSIONS]: sessionAPIRegistry,
|
|
@@ -19,6 +21,8 @@ const APIRegistry = {
|
|
|
19
21
|
[ModuleNames.CONTACTS]: contactAPIRegistry,
|
|
20
22
|
[ModuleNames.CANNED_MESSAGES]: cannedMessageAPIRegistry,
|
|
21
23
|
[ModuleNames.TEMPLATE_MESSAGES]: templateMessageAPIRegistry,
|
|
24
|
+
[ModuleNames.INTEGRATION_SERVICES]: integrationServiceAPIRegistry,
|
|
25
|
+
[ModuleNames.USER_PREFERENCES]: userPreferenceAPIRegistry,
|
|
22
26
|
[ModuleNames.WHATSAPP_PRICING]: whatsAppPricingAPIRegistry,
|
|
23
27
|
[ModuleNames.CALLS]: callAPIRegistry
|
|
24
28
|
};
|
|
@@ -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.POST, 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
|
|
|
@@ -6,5 +6,7 @@ export * from './agents';
|
|
|
6
6
|
export * from './contacts';
|
|
7
7
|
export * from './cannedMessages';
|
|
8
8
|
export * from './templateMessages';
|
|
9
|
+
export * from './integrationServices';
|
|
10
|
+
export * from './userPreferences';
|
|
9
11
|
export * from './whatsAppPricing';
|
|
10
12
|
export * from './calls';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { IIntegrationServiceRepository } from '../../../domain/interfaces/repositories';
|
|
2
|
+
import { IntegrationServiceAdapter } from '../../adapters';
|
|
3
|
+
import { IntegrationServiceAPI } from '../../api';
|
|
4
|
+
import { ResponseTypes } from '../../../core/constants';
|
|
5
|
+
export default class IntegrationServiceRepository extends IIntegrationServiceRepository {
|
|
6
|
+
constructor(_ref) {
|
|
7
|
+
let {
|
|
8
|
+
integrationServiceAPI,
|
|
9
|
+
integrationServiceAdapter
|
|
10
|
+
} = _ref;
|
|
11
|
+
super();
|
|
12
|
+
this.defaultAPI = new IntegrationServiceAPI();
|
|
13
|
+
this.customAPI = integrationServiceAPI;
|
|
14
|
+
this.integrationServiceAPI = this.createAPIProxy(this.customAPI, this.defaultAPI);
|
|
15
|
+
this.integrationServiceAdapter = integrationServiceAdapter || new IntegrationServiceAdapter();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async invokeAPI(_ref2) {
|
|
19
|
+
let {
|
|
20
|
+
operation,
|
|
21
|
+
request,
|
|
22
|
+
adapter = this.integrationServiceAdapter,
|
|
23
|
+
responseType
|
|
24
|
+
} = _ref2;
|
|
25
|
+
return this.executeAPICall({
|
|
26
|
+
operation,
|
|
27
|
+
request,
|
|
28
|
+
apiProxy: this.integrationServiceAPI,
|
|
29
|
+
customAPI: this.customAPI,
|
|
30
|
+
adapter,
|
|
31
|
+
responseType
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async getIntegrations(request) {
|
|
36
|
+
return this.invokeAPI({
|
|
37
|
+
operation: 'getIntegrations',
|
|
38
|
+
request,
|
|
39
|
+
responseType: ResponseTypes.LIST
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
toJSON() {
|
|
44
|
+
return {
|
|
45
|
+
getIntegrations: this.getIntegrations.bind(this)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|