@zohoim/client-sdk 1.0.0-replyAreaPoc9 → 1.0.0-whatsAppPricing.2
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/index.js +3 -1
- package/es/application/services/subscription/SubscriptionService.js +36 -0
- package/es/application/services/subscription/index.js +2 -0
- package/es/application/services/whatsAppPricing/WhatsAppPricingService.js +21 -0
- package/es/application/services/whatsAppPricing/index.js +2 -0
- package/es/core/constants/ModuleNames.js +3 -1
- package/es/core/constants/ModuleTypes.js +5 -0
- package/es/core/constants/index.js +2 -1
- package/es/domain/dto/index.js +3 -1
- package/es/domain/dto/subscription/buyAddOnPackageRequest.js +18 -0
- package/es/domain/dto/subscription/getAddOnPackagesRequest.js +15 -0
- package/es/domain/dto/subscription/getLicenseDetailsRequest.js +7 -0
- package/es/domain/dto/subscription/index.js +5 -0
- package/es/domain/dto/subscription/modifyAddOnPackageRequest.js +18 -0
- package/es/domain/dto/whatsAppPricing/calculatePricingRequest.js +14 -0
- package/es/domain/dto/whatsAppPricing/index.js +2 -0
- package/es/domain/entities/AddOnPackage/AddOnPackage.js +34 -0
- package/es/domain/entities/AddOnPackage/index.js +2 -0
- package/es/domain/entities/LicenseDetails/LicenseDetails.js +23 -0
- package/es/domain/entities/LicenseDetails/index.js +2 -0
- package/es/domain/entities/WhatsAppPricingResult/WhatsAppPricingResult.js +24 -0
- package/es/domain/entities/WhatsAppPricingResult/index.js +2 -0
- package/es/domain/entities/index.js +4 -1
- package/es/domain/enum/index.js +2 -1
- package/es/domain/enum/session/SessionReplyStatus.js +4 -1
- package/es/domain/enum/subscription/AddOnSubscriptionStatus.js +7 -0
- package/es/domain/enum/subscription/index.js +2 -0
- package/es/domain/interfaces/repositories/index.js +3 -1
- package/es/domain/interfaces/repositories/subscription/ISubscriptionRepository.js +35 -0
- package/es/domain/interfaces/repositories/subscription/index.js +2 -0
- package/es/domain/interfaces/repositories/whatsAppPricing/IWhatsAppPricingRepository.js +17 -0
- package/es/domain/interfaces/repositories/whatsAppPricing/index.js +2 -0
- package/es/domain/schema/index.js +3 -1
- package/es/domain/schema/subscription/AddOnPackageSchema.js +33 -0
- package/es/domain/schema/subscription/AddOnSubscriptionSchema.js +29 -0
- package/es/domain/schema/subscription/LicenseDetailsSchema.js +11 -0
- package/es/domain/schema/subscription/index.js +4 -0
- package/es/domain/schema/whatsAppPricing/PricingCategorySchema.js +11 -0
- package/es/domain/schema/whatsAppPricing/WhatsAppPricingResultSchema.js +21 -0
- package/es/domain/schema/whatsAppPricing/index.js +3 -0
- package/es/frameworks/managers/ModuleFactory.js +62 -24
- package/es/frameworks/managers/ModuleManager.js +20 -4
- package/es/frameworks/sdk/IMSDK.js +19 -9
- package/es/frameworks/sdk/subscription/SubscriptionSDK.js +29 -0
- package/es/frameworks/sdk/subscription/index.js +2 -0
- package/es/frameworks/sdk/whatsAppPricing/WhatsAppPricingSDK.js +27 -0
- package/es/frameworks/sdk/whatsAppPricing/index.js +2 -0
- package/es/infrastructure/adapters/index.js +3 -1
- package/es/infrastructure/adapters/subscription/AddOnPackageAdapter.js +25 -0
- package/es/infrastructure/adapters/subscription/LicenseDetailsAdapter.js +20 -0
- package/es/infrastructure/adapters/subscription/index.js +3 -0
- package/es/infrastructure/adapters/whatsAppPricing/WhatsAppPricingResultAdapter.js +22 -0
- package/es/infrastructure/adapters/whatsAppPricing/index.js +2 -0
- package/es/infrastructure/api/BaseAPI.js +2 -2
- package/es/infrastructure/api/index.js +3 -1
- package/es/infrastructure/api/registry/createPublicBaseUrl.js +4 -0
- package/es/infrastructure/api/registry/getRegistryConfig.js +5 -1
- package/es/infrastructure/api/registry/subscription/constructSubscriptionEndPoint.js +10 -0
- package/es/infrastructure/api/registry/subscription/index.js +3 -0
- package/es/infrastructure/api/registry/subscription/subscriptionAPIRegistry.js +28 -0
- package/es/infrastructure/api/registry/whatsAppPricing/constructWhatsAppPricingEndPoint.js +5 -0
- package/es/infrastructure/api/registry/whatsAppPricing/index.js +2 -0
- package/es/infrastructure/api/registry/whatsAppPricing/whatsAppPricingAPIRegistry.js +13 -0
- package/es/infrastructure/api/subscription/SubscriptionAPI.js +44 -0
- package/es/infrastructure/api/subscription/index.js +2 -0
- package/es/infrastructure/api/whatsAppPricing/WhatsAppPricingAPI.js +14 -0
- package/es/infrastructure/api/whatsAppPricing/index.js +2 -0
- package/es/infrastructure/repositories/index.js +3 -1
- package/es/infrastructure/repositories/subscription/SubscriptionRepository.js +82 -0
- package/es/infrastructure/repositories/subscription/index.js +2 -0
- package/es/infrastructure/repositories/whatsAppPricing/WhatsAppPricingRepository.js +50 -0
- package/es/infrastructure/repositories/whatsAppPricing/index.js +2 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModuleNames } from '../../core/constants';
|
|
1
|
+
import { ModuleNames, ModuleTypes } from '../../core/constants';
|
|
2
2
|
import { BotSDK } from '../sdk/bots';
|
|
3
3
|
import { ChannelSDK } from '../sdk/channels';
|
|
4
4
|
import { SessionSDK } from '../sdk/sessions';
|
|
@@ -7,70 +7,108 @@ import { AgentSDK } from '../sdk/agents';
|
|
|
7
7
|
import { ContactSDK } from '../sdk/contacts';
|
|
8
8
|
import { CannedMessageSDK } from '../sdk/cannedMessages';
|
|
9
9
|
import { TemplateMessageSDK } from '../sdk/templateMessages';
|
|
10
|
+
import { SubscriptionSDK } from '../sdk/subscription';
|
|
11
|
+
import { WhatsAppPricingSDK } from '../sdk/whatsAppPricing';
|
|
10
12
|
const ModuleFactory = {
|
|
11
13
|
[ModuleNames.CHANNELS]: _ref => {
|
|
12
14
|
let {
|
|
13
15
|
config
|
|
14
16
|
} = _ref;
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
return {
|
|
18
|
+
[ModuleTypes.AUTHENTICATED]: new ChannelSDK({
|
|
19
|
+
config
|
|
20
|
+
}).toJSON()
|
|
21
|
+
};
|
|
18
22
|
},
|
|
19
23
|
[ModuleNames.SESSIONS]: _ref2 => {
|
|
20
24
|
let {
|
|
21
25
|
config
|
|
22
26
|
} = _ref2;
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
return {
|
|
28
|
+
[ModuleTypes.AUTHENTICATED]: new SessionSDK({
|
|
29
|
+
config
|
|
30
|
+
}).toJSON()
|
|
31
|
+
};
|
|
26
32
|
},
|
|
27
33
|
[ModuleNames.BOTS]: _ref3 => {
|
|
28
34
|
let {
|
|
29
35
|
config
|
|
30
36
|
} = _ref3;
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
return {
|
|
38
|
+
[ModuleTypes.AUTHENTICATED]: new BotSDK({
|
|
39
|
+
config
|
|
40
|
+
}).toJSON()
|
|
41
|
+
};
|
|
34
42
|
},
|
|
35
43
|
[ModuleNames.AGENTS]: _ref4 => {
|
|
36
44
|
let {
|
|
37
45
|
config
|
|
38
46
|
} = _ref4;
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
return {
|
|
48
|
+
[ModuleTypes.AUTHENTICATED]: new AgentSDK({
|
|
49
|
+
config
|
|
50
|
+
}).toJSON()
|
|
51
|
+
};
|
|
42
52
|
},
|
|
43
53
|
[ModuleNames.CONTACTS]: _ref5 => {
|
|
44
54
|
let {
|
|
45
55
|
config
|
|
46
56
|
} = _ref5;
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
return {
|
|
58
|
+
[ModuleTypes.AUTHENTICATED]: new ContactSDK({
|
|
59
|
+
config
|
|
60
|
+
}).toJSON()
|
|
61
|
+
};
|
|
50
62
|
},
|
|
51
63
|
[ModuleNames.MESSAGES]: _ref6 => {
|
|
52
64
|
let {
|
|
53
65
|
config
|
|
54
66
|
} = _ref6;
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
|
|
67
|
+
return {
|
|
68
|
+
[ModuleTypes.AUTHENTICATED]: new MessageSDK({
|
|
69
|
+
config
|
|
70
|
+
}).toJSON()
|
|
71
|
+
};
|
|
58
72
|
},
|
|
59
73
|
[ModuleNames.CANNED_MESSAGES]: _ref7 => {
|
|
60
74
|
let {
|
|
61
75
|
config
|
|
62
76
|
} = _ref7;
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
|
|
77
|
+
return {
|
|
78
|
+
[ModuleTypes.AUTHENTICATED]: new CannedMessageSDK({
|
|
79
|
+
config
|
|
80
|
+
}).toJSON()
|
|
81
|
+
};
|
|
66
82
|
},
|
|
67
83
|
[ModuleNames.TEMPLATE_MESSAGES]: _ref8 => {
|
|
68
84
|
let {
|
|
69
85
|
config
|
|
70
86
|
} = _ref8;
|
|
71
|
-
return
|
|
87
|
+
return {
|
|
88
|
+
[ModuleTypes.AUTHENTICATED]: new TemplateMessageSDK({
|
|
89
|
+
config
|
|
90
|
+
}).toJSON()
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
[ModuleNames.SUBSCRIPTION]: _ref9 => {
|
|
94
|
+
let {
|
|
95
|
+
config
|
|
96
|
+
} = _ref9;
|
|
97
|
+
return {
|
|
98
|
+
[ModuleTypes.AUTHENTICATED]: new SubscriptionSDK({
|
|
99
|
+
config
|
|
100
|
+
}).toJSON()
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
[ModuleNames.WHATSAPP_PRICING]: _ref10 => {
|
|
104
|
+
let {
|
|
72
105
|
config
|
|
73
|
-
}
|
|
106
|
+
} = _ref10;
|
|
107
|
+
return {
|
|
108
|
+
[ModuleTypes.PUBLIC]: new WhatsAppPricingSDK({
|
|
109
|
+
config
|
|
110
|
+
}).toJSON()
|
|
111
|
+
};
|
|
74
112
|
}
|
|
75
113
|
};
|
|
76
114
|
export default ModuleFactory;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleTypes } from '../../core/constants';
|
|
2
2
|
import ModuleFactory from './ModuleFactory';
|
|
3
3
|
export default class ModuleManager {
|
|
4
4
|
constructor() {
|
|
5
5
|
this._modules = new Map();
|
|
6
|
-
this.supportedModules =
|
|
6
|
+
this.supportedModules = Object.keys(ModuleFactory);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
initialize(_ref) {
|
|
@@ -33,12 +33,28 @@ export default class ModuleManager {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
getModuleByType(moduleName) {
|
|
37
|
+
let moduleType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ModuleTypes.AUTHENTICATED;
|
|
38
|
+
|
|
39
|
+
const module = this._modules.get(moduleName);
|
|
40
|
+
|
|
41
|
+
return module ? module[moduleType] : undefined;
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
hasModule(moduleName) {
|
|
41
45
|
return this._modules.has(moduleName);
|
|
42
46
|
}
|
|
43
47
|
|
|
48
|
+
getModulesByType(moduleType) {
|
|
49
|
+
const result = {};
|
|
50
|
+
|
|
51
|
+
this._modules.forEach((module, moduleName) => {
|
|
52
|
+
if (module[moduleType]) {
|
|
53
|
+
result[moduleName] = module[moduleType];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
|
|
44
60
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModuleNames } from '../../core/constants';
|
|
1
|
+
import { ModuleNames, ModuleTypes } from '../../core/constants';
|
|
2
2
|
import configRegistry from '../../infrastructure/config/configRegistry';
|
|
3
3
|
import { ModuleManager } from '../managers';
|
|
4
4
|
export default class IMSDK {
|
|
@@ -20,35 +20,43 @@ export default class IMSDK {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
get channels() {
|
|
23
|
-
return this._moduleManager.
|
|
23
|
+
return this._moduleManager.getModuleByType(ModuleNames.CHANNELS);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
get sessions() {
|
|
27
|
-
return this._moduleManager.
|
|
27
|
+
return this._moduleManager.getModuleByType(ModuleNames.SESSIONS);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
get bots() {
|
|
31
|
-
return this._moduleManager.
|
|
31
|
+
return this._moduleManager.getModuleByType(ModuleNames.BOTS);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
get messages() {
|
|
35
|
-
return this._moduleManager.
|
|
35
|
+
return this._moduleManager.getModuleByType(ModuleNames.MESSAGES);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
get agents() {
|
|
39
|
-
return this._moduleManager.
|
|
39
|
+
return this._moduleManager.getModuleByType(ModuleNames.AGENTS);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
get contacts() {
|
|
43
|
-
return this._moduleManager.
|
|
43
|
+
return this._moduleManager.getModuleByType(ModuleNames.CONTACTS);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
get cannedMessages() {
|
|
47
|
-
return this._moduleManager.
|
|
47
|
+
return this._moduleManager.getModuleByType(ModuleNames.CANNED_MESSAGES);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
get templateMessages() {
|
|
51
|
-
return this._moduleManager.
|
|
51
|
+
return this._moduleManager.getModuleByType(ModuleNames.TEMPLATE_MESSAGES);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get subscription() {
|
|
55
|
+
return this._moduleManager.getModuleByType(ModuleNames.SUBSCRIPTION);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get public() {
|
|
59
|
+
return this._moduleManager.getModulesByType(ModuleTypes.PUBLIC);
|
|
52
60
|
}
|
|
53
61
|
|
|
54
62
|
hasModule(moduleName) {
|
|
@@ -65,6 +73,8 @@ export default class IMSDK {
|
|
|
65
73
|
contacts: this.contacts,
|
|
66
74
|
cannedMessages: this.cannedMessages,
|
|
67
75
|
templateMessages: this.templateMessages,
|
|
76
|
+
subscription: this.subscription,
|
|
77
|
+
public: this.public,
|
|
68
78
|
hasModule: this.hasModule.bind(this)
|
|
69
79
|
};
|
|
70
80
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SubscriptionService } from '../../../application/services';
|
|
2
|
+
import { SubscriptionRepository } from '../../../infrastructure/repositories';
|
|
3
|
+
export default class SubscriptionSDK {
|
|
4
|
+
constructor(_ref) {
|
|
5
|
+
let {
|
|
6
|
+
config
|
|
7
|
+
} = _ref;
|
|
8
|
+
const {
|
|
9
|
+
subscriptionAPI,
|
|
10
|
+
addOnPackageAdapter,
|
|
11
|
+
licenseDetailsAdapter
|
|
12
|
+
} = config;
|
|
13
|
+
const subscriptionRepository = new SubscriptionRepository({
|
|
14
|
+
subscriptionAPI,
|
|
15
|
+
addOnPackageAdapter,
|
|
16
|
+
licenseDetailsAdapter
|
|
17
|
+
}).toJSON();
|
|
18
|
+
const subscriptionService = new SubscriptionService({
|
|
19
|
+
subscriptionRepository
|
|
20
|
+
}).toJSON();
|
|
21
|
+
this.services = { ...subscriptionService
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
toJSON() {
|
|
26
|
+
return this.services;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { WhatsAppPricingService } from '../../../application/services';
|
|
2
|
+
import { WhatsAppPricingRepository } from '../../../infrastructure/repositories';
|
|
3
|
+
export default class WhatsAppPricingSDK {
|
|
4
|
+
constructor(_ref) {
|
|
5
|
+
let {
|
|
6
|
+
config
|
|
7
|
+
} = _ref;
|
|
8
|
+
const {
|
|
9
|
+
whatsAppPricingAPI,
|
|
10
|
+
whatsAppPricingResultAdapter
|
|
11
|
+
} = config;
|
|
12
|
+
const whatsAppPricingRepository = new WhatsAppPricingRepository({
|
|
13
|
+
whatsAppPricingAPI,
|
|
14
|
+
whatsAppPricingResultAdapter
|
|
15
|
+
}).toJSON();
|
|
16
|
+
const whatsAppPricingService = new WhatsAppPricingService({
|
|
17
|
+
whatsAppPricingRepository
|
|
18
|
+
}).toJSON();
|
|
19
|
+
this.services = { ...whatsAppPricingService
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
toJSON() {
|
|
24
|
+
return this.services;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
@@ -7,4 +7,6 @@ export * from './agents';
|
|
|
7
7
|
export * from './contacts';
|
|
8
8
|
export * from './cannedMessages';
|
|
9
9
|
export * from './templateMessages';
|
|
10
|
-
export * from './customReplyExtension';
|
|
10
|
+
export * from './customReplyExtension';
|
|
11
|
+
export * from './subscription';
|
|
12
|
+
export * from './whatsAppPricing';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AdapterError } from '../../../core/errors';
|
|
2
|
+
import { AddOnPackage } from '../../../domain/entities';
|
|
3
|
+
import { IAdapter } from '../../../domain/interfaces';
|
|
4
|
+
export default class AddOnPackageAdapter extends IAdapter {
|
|
5
|
+
adapt(rawAddOnPackage) {
|
|
6
|
+
if (!rawAddOnPackage) {
|
|
7
|
+
throw new AdapterError('AddOnPackage data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new AddOnPackage({
|
|
12
|
+
name: rawAddOnPackage.name,
|
|
13
|
+
type: rawAddOnPackage.type,
|
|
14
|
+
module: rawAddOnPackage.module,
|
|
15
|
+
cost: rawAddOnPackage.cost,
|
|
16
|
+
integrationService: rawAddOnPackage.integrationService,
|
|
17
|
+
subscriptionInfo: rawAddOnPackage.subscriptionInfo,
|
|
18
|
+
metaInfo: rawAddOnPackage.metaInfo
|
|
19
|
+
}).toJSON();
|
|
20
|
+
} catch (error) {
|
|
21
|
+
throw new AdapterError(`Failed to adapt AddOnPackage: ${error.message}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AdapterError } from '../../../core/errors';
|
|
2
|
+
import { LicenseDetails } from '../../../domain/entities';
|
|
3
|
+
import { IAdapter } from '../../../domain/interfaces';
|
|
4
|
+
export default class LicenseDetailsAdapter extends IAdapter {
|
|
5
|
+
adapt(rawLicenseDetails) {
|
|
6
|
+
if (!rawLicenseDetails) {
|
|
7
|
+
throw new AdapterError('LicenseDetails data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new LicenseDetails({
|
|
12
|
+
paymentSource: rawLicenseDetails.paymentSource,
|
|
13
|
+
data: rawLicenseDetails.data
|
|
14
|
+
}).toJSON();
|
|
15
|
+
} catch (error) {
|
|
16
|
+
throw new AdapterError(`Failed to adapt LicenseDetails: ${error.message}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AdapterError } from '../../../core/errors';
|
|
2
|
+
import { WhatsAppPricingResult } from '../../../domain/entities';
|
|
3
|
+
import { IAdapter } from '../../../domain/interfaces';
|
|
4
|
+
export default class WhatsAppPricingResultAdapter extends IAdapter {
|
|
5
|
+
adapt(rawPricingResult) {
|
|
6
|
+
if (!rawPricingResult) {
|
|
7
|
+
throw new AdapterError('WhatsAppPricingResult data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new WhatsAppPricingResult({
|
|
12
|
+
total: rawPricingResult.total,
|
|
13
|
+
creditsCount: rawPricingResult.creditsCount,
|
|
14
|
+
category: rawPricingResult.category,
|
|
15
|
+
actualCreditsAmount: rawPricingResult.actutalCreditsAmount
|
|
16
|
+
}).toJSON();
|
|
17
|
+
} catch (error) {
|
|
18
|
+
throw new AdapterError(`Failed to adapt WhatsAppPricingResult: ${error.message}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
@@ -11,14 +11,14 @@ export default class BaseAPI {
|
|
|
11
11
|
registryProvider = {
|
|
12
12
|
getRegistryConfig
|
|
13
13
|
},
|
|
14
|
-
urlBuilder
|
|
14
|
+
urlBuilder
|
|
15
15
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
16
16
|
this.configProvider = configProvider;
|
|
17
17
|
this.registryProvider = registryProvider;
|
|
18
18
|
this.httpClient = this.configProvider.getHttpClient();
|
|
19
19
|
this.baseURL = this.configProvider.getBaseURL();
|
|
20
20
|
this.module = module;
|
|
21
|
-
this.urlBuilder = urlBuilder;
|
|
21
|
+
this.urlBuilder = urlBuilder || new UrlBuilder(this.baseURL);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
async request(_ref) {
|
|
@@ -7,6 +7,8 @@ import { agentAPIRegistry } from './agents';
|
|
|
7
7
|
import { contactAPIRegistry } from './contacts';
|
|
8
8
|
import { cannedMessageAPIRegistry } from './cannedMessages';
|
|
9
9
|
import { templateMessageAPIRegistry } from './templateMessages';
|
|
10
|
+
import { subscriptionAPIRegistry } from './subscription';
|
|
11
|
+
import { whatsAppPricingAPIRegistry } from './whatsAppPricing';
|
|
10
12
|
import { ModuleNames } from '../../../core/constants';
|
|
11
13
|
const APIRegistry = {
|
|
12
14
|
[ModuleNames.CHANNELS]: channelAPIRegistry,
|
|
@@ -16,7 +18,9 @@ const APIRegistry = {
|
|
|
16
18
|
[ModuleNames.AGENTS]: agentAPIRegistry,
|
|
17
19
|
[ModuleNames.CONTACTS]: contactAPIRegistry,
|
|
18
20
|
[ModuleNames.CANNED_MESSAGES]: cannedMessageAPIRegistry,
|
|
19
|
-
[ModuleNames.TEMPLATE_MESSAGES]: templateMessageAPIRegistry
|
|
21
|
+
[ModuleNames.TEMPLATE_MESSAGES]: templateMessageAPIRegistry,
|
|
22
|
+
[ModuleNames.SUBSCRIPTION]: subscriptionAPIRegistry,
|
|
23
|
+
[ModuleNames.WHATSAPP_PRICING]: whatsAppPricingAPIRegistry
|
|
20
24
|
};
|
|
21
25
|
export default function getRegistryConfig(module, operation) {
|
|
22
26
|
const moduleConfig = selectn(module, APIRegistry);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { HTTP_METHODS } from '../../../../core/constants';
|
|
2
|
+
import { getAddOnPackagesRequest, getLicenseDetailsRequest, buyAddOnPackageRequest, modifyAddOnPackageRequest } from '../../../../domain/dto';
|
|
3
|
+
import createAPIRegistry from '../createAPIRegistry';
|
|
4
|
+
import constructSubscriptionEndPoint from './constructSubscriptionEndPoint';
|
|
5
|
+
|
|
6
|
+
function getAddOnPackages() {
|
|
7
|
+
return createAPIRegistry(constructSubscriptionEndPoint('/addOn'), HTTP_METHODS.GET, getAddOnPackagesRequest());
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function getLicenseDetails() {
|
|
11
|
+
return createAPIRegistry(constructSubscriptionEndPoint('/license'), HTTP_METHODS.GET, getLicenseDetailsRequest());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function buyAddOnPackage() {
|
|
15
|
+
return createAPIRegistry(constructSubscriptionEndPoint('/addOn'), HTTP_METHODS.POST, buyAddOnPackageRequest());
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function modifyAddOnPackage() {
|
|
19
|
+
return createAPIRegistry(constructSubscriptionEndPoint('/addOn'), HTTP_METHODS.PATCH, modifyAddOnPackageRequest());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const subscriptionAPIRegistry = {
|
|
23
|
+
getAddOnPackages,
|
|
24
|
+
getLicenseDetails,
|
|
25
|
+
buyAddOnPackage,
|
|
26
|
+
modifyAddOnPackage
|
|
27
|
+
};
|
|
28
|
+
export default subscriptionAPIRegistry;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HTTP_METHODS } from '../../../../core/constants';
|
|
2
|
+
import { calculatePricingRequest } from '../../../../domain/dto';
|
|
3
|
+
import createAPIRegistry from '../createAPIRegistry';
|
|
4
|
+
import constructWhatsAppPricingEndPoint from './constructWhatsAppPricingEndPoint';
|
|
5
|
+
|
|
6
|
+
function calculatePricing() {
|
|
7
|
+
return createAPIRegistry(constructWhatsAppPricingEndPoint(), HTTP_METHODS.POST, calculatePricingRequest());
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const whatsAppPricingAPIRegistry = {
|
|
11
|
+
calculatePricing
|
|
12
|
+
};
|
|
13
|
+
export default whatsAppPricingAPIRegistry;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { getAddOnPackagesRequest, getLicenseDetailsRequest, buyAddOnPackageRequest, modifyAddOnPackageRequest } from '../../../domain/dto';
|
|
2
|
+
import { ISubscriptionRepository } from '../../../domain/interfaces/repositories';
|
|
3
|
+
export default class SubscriptionAPI extends ISubscriptionRepository {
|
|
4
|
+
async getAddOnPackages() {
|
|
5
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getAddOnPackagesRequest();
|
|
6
|
+
const operation = 'getAddOnPackages';
|
|
7
|
+
const httpRequest = await this.request({
|
|
8
|
+
request,
|
|
9
|
+
operation
|
|
10
|
+
});
|
|
11
|
+
return httpRequest;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async getLicenseDetails() {
|
|
15
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLicenseDetailsRequest();
|
|
16
|
+
const operation = 'getLicenseDetails';
|
|
17
|
+
const httpRequest = await this.request({
|
|
18
|
+
request,
|
|
19
|
+
operation
|
|
20
|
+
});
|
|
21
|
+
return httpRequest;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async buyAddOnPackage() {
|
|
25
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : buyAddOnPackageRequest();
|
|
26
|
+
const operation = 'buyAddOnPackage';
|
|
27
|
+
const httpRequest = await this.request({
|
|
28
|
+
request,
|
|
29
|
+
operation
|
|
30
|
+
});
|
|
31
|
+
return httpRequest;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async modifyAddOnPackage() {
|
|
35
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : modifyAddOnPackageRequest();
|
|
36
|
+
const operation = 'modifyAddOnPackage';
|
|
37
|
+
const httpRequest = await this.request({
|
|
38
|
+
request,
|
|
39
|
+
operation
|
|
40
|
+
});
|
|
41
|
+
return httpRequest;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { calculatePricingRequest } from '../../../domain/dto';
|
|
2
|
+
import { IWhatsAppPricingRepository } from '../../../domain/interfaces/repositories';
|
|
3
|
+
export default class WhatsAppPricingAPI extends IWhatsAppPricingRepository {
|
|
4
|
+
async calculatePricing() {
|
|
5
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : calculatePricingRequest();
|
|
6
|
+
const operation = 'calculatePricing';
|
|
7
|
+
const httpRequest = await this.request({
|
|
8
|
+
request,
|
|
9
|
+
operation
|
|
10
|
+
});
|
|
11
|
+
return httpRequest;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|