@zohoim/client-sdk 1.0.0-whatsAppPricing.3 → 1.1.0-attachmentsList
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 +1 -3
- package/es/core/constants/ModuleNames.js +1 -3
- package/es/core/constants/index.js +1 -2
- package/es/domain/dto/index.js +1 -3
- package/es/domain/dto/sessions/getSessionAttachmentsRequest.js +2 -0
- package/es/domain/entities/index.js +1 -4
- package/es/domain/enum/index.js +1 -2
- package/es/domain/interfaces/repositories/index.js +1 -3
- package/es/domain/schema/index.js +1 -3
- package/es/frameworks/managers/ModuleFactory.js +24 -62
- package/es/frameworks/managers/ModuleManager.js +4 -20
- package/es/frameworks/sdk/IMSDK.js +11 -23
- package/es/infrastructure/adapters/index.js +1 -3
- package/es/infrastructure/api/BaseAPI.js +4 -5
- package/es/infrastructure/api/index.js +1 -3
- package/es/infrastructure/api/registry/getRegistryConfig.js +1 -5
- package/es/infrastructure/config/configRegistry.js +1 -8
- package/es/infrastructure/repositories/index.js +1 -3
- package/package.json +1 -1
- package/es/application/services/subscription/SubscriptionService.js +0 -36
- package/es/application/services/subscription/index.js +0 -2
- package/es/application/services/whatsAppPricing/WhatsAppPricingService.js +0 -21
- package/es/application/services/whatsAppPricing/index.js +0 -2
- package/es/core/constants/ModuleTypes.js +0 -5
- package/es/domain/dto/subscription/buyAddOnPackageRequest.js +0 -18
- package/es/domain/dto/subscription/getAddOnPackagesRequest.js +0 -15
- package/es/domain/dto/subscription/getLicenseDetailsRequest.js +0 -7
- package/es/domain/dto/subscription/index.js +0 -5
- package/es/domain/dto/subscription/modifyAddOnPackageRequest.js +0 -18
- package/es/domain/dto/whatsAppPricing/calculatePricingRequest.js +0 -14
- package/es/domain/dto/whatsAppPricing/index.js +0 -2
- package/es/domain/entities/AddOnPackage/AddOnPackage.js +0 -34
- package/es/domain/entities/AddOnPackage/index.js +0 -2
- package/es/domain/entities/LicenseDetails/LicenseDetails.js +0 -23
- package/es/domain/entities/LicenseDetails/index.js +0 -2
- package/es/domain/entities/WhatsAppPricingResult/WhatsAppPricingResult.js +0 -24
- package/es/domain/entities/WhatsAppPricingResult/index.js +0 -2
- package/es/domain/enum/subscription/AddOnSubscriptionStatus.js +0 -7
- package/es/domain/enum/subscription/index.js +0 -2
- package/es/domain/interfaces/repositories/subscription/ISubscriptionRepository.js +0 -35
- package/es/domain/interfaces/repositories/subscription/index.js +0 -2
- package/es/domain/interfaces/repositories/whatsAppPricing/IWhatsAppPricingRepository.js +0 -18
- package/es/domain/interfaces/repositories/whatsAppPricing/index.js +0 -2
- package/es/domain/schema/subscription/AddOnPackageSchema.js +0 -33
- package/es/domain/schema/subscription/AddOnSubscriptionSchema.js +0 -29
- package/es/domain/schema/subscription/LicenseDetailsSchema.js +0 -11
- package/es/domain/schema/subscription/index.js +0 -4
- package/es/domain/schema/whatsAppPricing/PricingCategorySchema.js +0 -11
- package/es/domain/schema/whatsAppPricing/WhatsAppPricingResultSchema.js +0 -21
- package/es/domain/schema/whatsAppPricing/index.js +0 -3
- package/es/frameworks/sdk/subscription/SubscriptionSDK.js +0 -29
- package/es/frameworks/sdk/subscription/index.js +0 -2
- package/es/frameworks/sdk/whatsAppPricing/WhatsAppPricingSDK.js +0 -27
- package/es/frameworks/sdk/whatsAppPricing/index.js +0 -2
- package/es/infrastructure/adapters/subscription/AddOnPackageAdapter.js +0 -25
- package/es/infrastructure/adapters/subscription/LicenseDetailsAdapter.js +0 -20
- package/es/infrastructure/adapters/subscription/index.js +0 -3
- package/es/infrastructure/adapters/whatsAppPricing/WhatsAppPricingResultAdapter.js +0 -22
- package/es/infrastructure/adapters/whatsAppPricing/index.js +0 -2
- package/es/infrastructure/api/registry/createPublicBaseUrl.js +0 -4
- package/es/infrastructure/api/registry/subscription/constructSubscriptionEndPoint.js +0 -10
- package/es/infrastructure/api/registry/subscription/index.js +0 -3
- package/es/infrastructure/api/registry/subscription/subscriptionAPIRegistry.js +0 -28
- package/es/infrastructure/api/registry/whatsAppPricing/constructWhatsAppPricingEndPoint.js +0 -5
- package/es/infrastructure/api/registry/whatsAppPricing/index.js +0 -2
- package/es/infrastructure/api/registry/whatsAppPricing/whatsAppPricingAPIRegistry.js +0 -13
- package/es/infrastructure/api/subscription/SubscriptionAPI.js +0 -44
- package/es/infrastructure/api/subscription/index.js +0 -2
- package/es/infrastructure/api/whatsAppPricing/WhatsAppPricingAPI.js +0 -14
- package/es/infrastructure/api/whatsAppPricing/index.js +0 -2
- package/es/infrastructure/repositories/subscription/SubscriptionRepository.js +0 -82
- package/es/infrastructure/repositories/subscription/index.js +0 -2
- package/es/infrastructure/repositories/whatsAppPricing/WhatsAppPricingRepository.js +0 -50
- package/es/infrastructure/repositories/whatsAppPricing/index.js +0 -2
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { validateSchema } from '../../../core/utils';
|
|
2
|
-
import { LicenseDetailsSchema } from '../../schema';
|
|
3
|
-
export default class LicenseDetails {
|
|
4
|
-
constructor() {
|
|
5
|
-
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
6
|
-
const validatedData = validateSchema({
|
|
7
|
-
schema: LicenseDetailsSchema,
|
|
8
|
-
data,
|
|
9
|
-
entityName: 'LicenseDetails'
|
|
10
|
-
}); // Set optional properties from schema
|
|
11
|
-
|
|
12
|
-
this.paymentSource = validatedData.paymentSource || false;
|
|
13
|
-
this.data = validatedData.data || null;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
toJSON() {
|
|
17
|
-
return {
|
|
18
|
-
paymentSource: this.paymentSource,
|
|
19
|
-
data: this.data
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { validateSchema } from '../../../core/utils';
|
|
2
|
-
import { WhatsAppPricingResultSchema } from '../../schema';
|
|
3
|
-
export default class WhatsAppPricingResult {
|
|
4
|
-
constructor() {
|
|
5
|
-
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
6
|
-
const validatedData = validateSchema({
|
|
7
|
-
schema: WhatsAppPricingResultSchema,
|
|
8
|
-
data,
|
|
9
|
-
entityName: 'WhatsAppPricingResult'
|
|
10
|
-
});
|
|
11
|
-
this.data = {
|
|
12
|
-
total: validatedData.total,
|
|
13
|
-
creditsCount: validatedData.creditsCount,
|
|
14
|
-
category: validatedData.category,
|
|
15
|
-
actualCreditsAmount: validatedData.actualCreditsAmount
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
toJSON() {
|
|
20
|
-
return { ...this.data
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ModuleNames } from '../../../../core/constants';
|
|
2
|
-
import BaseAPI from '../../../../infrastructure/api/BaseAPI';
|
|
3
|
-
import { getAddOnPackagesRequest, getLicenseDetailsRequest, buyAddOnPackageRequest, modifyAddOnPackageRequest } from '../../../dto';
|
|
4
|
-
export default class ISubscriptionRepository extends BaseAPI {
|
|
5
|
-
constructor() {
|
|
6
|
-
super({
|
|
7
|
-
module: ModuleNames.SUBSCRIPTION
|
|
8
|
-
});
|
|
9
|
-
} // eslint-disable-next-line no-unused-vars
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
getAddOnPackages() {
|
|
13
|
-
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getAddOnPackagesRequest();
|
|
14
|
-
throw new Error('Method not implemented.');
|
|
15
|
-
} // eslint-disable-next-line no-unused-vars
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
getLicenseDetails() {
|
|
19
|
-
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLicenseDetailsRequest();
|
|
20
|
-
throw new Error('Method not implemented.');
|
|
21
|
-
} // eslint-disable-next-line no-unused-vars
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
buyAddOnPackage() {
|
|
25
|
-
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : buyAddOnPackageRequest();
|
|
26
|
-
throw new Error('Method not implemented.');
|
|
27
|
-
} // eslint-disable-next-line no-unused-vars
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
modifyAddOnPackage() {
|
|
31
|
-
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : modifyAddOnPackageRequest();
|
|
32
|
-
throw new Error('Method not implemented.');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ModuleNames, ModuleTypes } from '../../../../core/constants';
|
|
2
|
-
import BaseAPI from '../../../../infrastructure/api/BaseAPI';
|
|
3
|
-
import { calculatePricingRequest } from '../../../dto';
|
|
4
|
-
export default class IWhatsAppPricingRepository extends BaseAPI {
|
|
5
|
-
constructor() {
|
|
6
|
-
super({
|
|
7
|
-
module: ModuleNames.WHATSAPP_PRICING,
|
|
8
|
-
moduleType: ModuleTypes.PUBLIC
|
|
9
|
-
});
|
|
10
|
-
} // eslint-disable-next-line no-unused-vars
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
calculatePricing() {
|
|
14
|
-
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : calculatePricingRequest();
|
|
15
|
-
throw new Error('Method not implemented.');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import AddOnSubscriptionSchema from './AddOnSubscriptionSchema';
|
|
2
|
-
const AddOnPackageSchema = {
|
|
3
|
-
name: {
|
|
4
|
-
type: 'string',
|
|
5
|
-
required: true
|
|
6
|
-
},
|
|
7
|
-
type: {
|
|
8
|
-
type: 'string',
|
|
9
|
-
required: false
|
|
10
|
-
},
|
|
11
|
-
module: {
|
|
12
|
-
type: 'string',
|
|
13
|
-
required: false
|
|
14
|
-
},
|
|
15
|
-
cost: {
|
|
16
|
-
type: 'string',
|
|
17
|
-
required: false
|
|
18
|
-
},
|
|
19
|
-
integrationService: {
|
|
20
|
-
type: 'string',
|
|
21
|
-
required: false
|
|
22
|
-
},
|
|
23
|
-
subscriptionInfo: {
|
|
24
|
-
type: 'object',
|
|
25
|
-
required: false,
|
|
26
|
-
schema: AddOnSubscriptionSchema
|
|
27
|
-
},
|
|
28
|
-
metaInfo: {
|
|
29
|
-
type: 'object',
|
|
30
|
-
required: false
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
export default AddOnPackageSchema;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { AddOnSubscriptionStatus } from '../../enum/subscription';
|
|
2
|
-
const AddOnSubscriptionSchema = {
|
|
3
|
-
count: {
|
|
4
|
-
type: 'number',
|
|
5
|
-
required: false
|
|
6
|
-
},
|
|
7
|
-
available: {
|
|
8
|
-
type: 'string',
|
|
9
|
-
required: false
|
|
10
|
-
},
|
|
11
|
-
renewalCount: {
|
|
12
|
-
type: 'number',
|
|
13
|
-
required: false
|
|
14
|
-
},
|
|
15
|
-
renewalThreshold: {
|
|
16
|
-
type: 'number',
|
|
17
|
-
required: false
|
|
18
|
-
},
|
|
19
|
-
status: {
|
|
20
|
-
type: 'string',
|
|
21
|
-
required: false,
|
|
22
|
-
enum: Object.values(AddOnSubscriptionStatus)
|
|
23
|
-
},
|
|
24
|
-
reserved: {
|
|
25
|
-
type: 'string',
|
|
26
|
-
required: false
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
export default AddOnSubscriptionSchema;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import PricingCategorySchema from './PricingCategorySchema';
|
|
2
|
-
const WhatsAppPricingResultSchema = {
|
|
3
|
-
total: {
|
|
4
|
-
type: 'number',
|
|
5
|
-
required: true
|
|
6
|
-
},
|
|
7
|
-
creditsCount: {
|
|
8
|
-
type: 'number',
|
|
9
|
-
required: true
|
|
10
|
-
},
|
|
11
|
-
category: {
|
|
12
|
-
type: 'array',
|
|
13
|
-
required: true,
|
|
14
|
-
schema: PricingCategorySchema
|
|
15
|
-
},
|
|
16
|
-
actualCreditsAmount: {
|
|
17
|
-
type: 'number',
|
|
18
|
-
required: false
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
export default WhatsAppPricingResultSchema;
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
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;
|
|
@@ -1,13 +0,0 @@
|
|
|
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;
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { ISubscriptionRepository } from '../../../domain/interfaces/repositories';
|
|
2
|
-
import { AddOnPackageAdapter, LicenseDetailsAdapter } from '../../adapters';
|
|
3
|
-
import { SubscriptionAPI } from '../../api';
|
|
4
|
-
import { ResponseTypes } from '../../../core/constants';
|
|
5
|
-
export default class SubscriptionRepository extends ISubscriptionRepository {
|
|
6
|
-
constructor() {
|
|
7
|
-
let {
|
|
8
|
-
subscriptionAPI,
|
|
9
|
-
addOnPackageAdapter,
|
|
10
|
-
licenseDetailsAdapter
|
|
11
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
12
|
-
super();
|
|
13
|
-
this.defaultAPI = new SubscriptionAPI();
|
|
14
|
-
this.customAPI = subscriptionAPI;
|
|
15
|
-
this.subscriptionAPI = this.createAPIProxy(this.customAPI, this.defaultAPI);
|
|
16
|
-
this.addOnPackageAdapter = addOnPackageAdapter || new AddOnPackageAdapter();
|
|
17
|
-
this.licenseDetailsAdapter = licenseDetailsAdapter || new LicenseDetailsAdapter();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async invokeAPI(_ref) {
|
|
21
|
-
let {
|
|
22
|
-
operation,
|
|
23
|
-
request,
|
|
24
|
-
adapter,
|
|
25
|
-
responseType
|
|
26
|
-
} = _ref;
|
|
27
|
-
return this.executeAPICall({
|
|
28
|
-
operation,
|
|
29
|
-
request,
|
|
30
|
-
apiProxy: this.subscriptionAPI,
|
|
31
|
-
customAPI: this.customAPI,
|
|
32
|
-
adapter,
|
|
33
|
-
responseType
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async getAddOnPackages(request) {
|
|
38
|
-
return this.invokeAPI({
|
|
39
|
-
operation: 'getAddOnPackages',
|
|
40
|
-
request,
|
|
41
|
-
adapter: this.addOnPackageAdapter,
|
|
42
|
-
responseType: ResponseTypes.LIST
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async getLicenseDetails(request) {
|
|
47
|
-
return this.invokeAPI({
|
|
48
|
-
operation: 'getLicenseDetails',
|
|
49
|
-
request,
|
|
50
|
-
adapter: this.licenseDetailsAdapter,
|
|
51
|
-
responseType: ResponseTypes.SINGLE
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async buyAddOnPackage(request) {
|
|
56
|
-
return this.invokeAPI({
|
|
57
|
-
operation: 'buyAddOnPackage',
|
|
58
|
-
request,
|
|
59
|
-
adapter: this.addOnPackageAdapter,
|
|
60
|
-
responseType: ResponseTypes.SINGLE
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async modifyAddOnPackage(request) {
|
|
65
|
-
return this.invokeAPI({
|
|
66
|
-
operation: 'modifyAddOnPackage',
|
|
67
|
-
request,
|
|
68
|
-
adapter: this.addOnPackageAdapter,
|
|
69
|
-
responseType: ResponseTypes.SINGLE
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
toJSON() {
|
|
74
|
-
return {
|
|
75
|
-
getAddOnPackages: this.getAddOnPackages.bind(this),
|
|
76
|
-
getLicenseDetails: this.getLicenseDetails.bind(this),
|
|
77
|
-
buyAddOnPackage: this.buyAddOnPackage.bind(this),
|
|
78
|
-
modifyAddOnPackage: this.modifyAddOnPackage.bind(this)
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
}
|