@gofynd/fdk-client-javascript 0.1.35
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/.github/workflows/on_create_release.yml +23 -0
- package/.github/workflows/on_merge_main.yml +38 -0
- package/.github/workflows/on_pull_request.yml +35 -0
- package/.prettierrc +5 -0
- package/LICENSE +21 -0
- package/README.md +118 -0
- package/application.d.ts +3 -0
- package/application.js +6 -0
- package/common.d.ts +4 -0
- package/common.js +9 -0
- package/documentation/application/CART.md +7290 -0
- package/documentation/application/CATALOG.md +9570 -0
- package/documentation/application/COMMON.md +448 -0
- package/documentation/application/COMMUNICATION.md +463 -0
- package/documentation/application/CONFIGURATION.md +2902 -0
- package/documentation/application/CONTENT.md +3350 -0
- package/documentation/application/FILESTORAGE.md +491 -0
- package/documentation/application/LEAD.md +1891 -0
- package/documentation/application/LOGISTIC.md +439 -0
- package/documentation/application/ORDER.md +3428 -0
- package/documentation/application/PAYMENT.md +5035 -0
- package/documentation/application/POSCART.md +7889 -0
- package/documentation/application/README.md +21 -0
- package/documentation/application/REWARDS.md +714 -0
- package/documentation/application/SHARE.md +729 -0
- package/documentation/application/THEME.md +5796 -0
- package/documentation/application/USER.md +4326 -0
- package/documentation/platform/ANALYTICS.md +1150 -0
- package/documentation/platform/AUDITTRAIL.md +572 -0
- package/documentation/platform/BILLING.md +2396 -0
- package/documentation/platform/CART.md +5539 -0
- package/documentation/platform/CATALOG.md +21624 -0
- package/documentation/platform/COMMON.md +448 -0
- package/documentation/platform/COMMUNICATION.md +5714 -0
- package/documentation/platform/COMPANYPROFILE.md +2141 -0
- package/documentation/platform/CONFIGURATION.md +7335 -0
- package/documentation/platform/CONTENT.md +8989 -0
- package/documentation/platform/DISCOUNT.md +773 -0
- package/documentation/platform/FILESTORAGE.md +994 -0
- package/documentation/platform/INVENTORY.md +1775 -0
- package/documentation/platform/LEAD.md +4736 -0
- package/documentation/platform/ORDER.md +3764 -0
- package/documentation/platform/PARTNER.md +216 -0
- package/documentation/platform/PAYMENT.md +3444 -0
- package/documentation/platform/README.md +27 -0
- package/documentation/platform/REWARDS.md +871 -0
- package/documentation/platform/SHARE.md +602 -0
- package/documentation/platform/THEME.md +35725 -0
- package/documentation/platform/USER.md +2305 -0
- package/documentation/platform/WEBHOOK.md +587 -0
- package/documentation/public/CONFIGURATION.md +448 -0
- package/documentation/public/INVENTORY.md +686 -0
- package/documentation/public/WEBHOOK.md +348 -0
- package/index.d.ts +10 -0
- package/index.js +18 -0
- package/jest.config.d.ts +4 -0
- package/jest.config.js +6 -0
- package/package.json +35 -0
- package/platform.d.ts +3 -0
- package/platform.js +6 -0
- package/public.d.ts +3 -0
- package/public.js +6 -0
- package/sdk/application/ApplicationAPIClient.d.ts +11 -0
- package/sdk/application/ApplicationAPIClient.js +44 -0
- package/sdk/application/ApplicationClient.d.ts +40 -0
- package/sdk/application/ApplicationClient.js +84 -0
- package/sdk/application/ApplicationConfig.d.ts +19 -0
- package/sdk/application/ApplicationConfig.js +55 -0
- package/sdk/application/ApplicationModels.d.ts +826 -0
- package/sdk/application/ApplicationModels.js +10474 -0
- package/sdk/application/client/CartApplicationClient.d.ts +432 -0
- package/sdk/application/client/CartApplicationClient.js +1066 -0
- package/sdk/application/client/CatalogApplicationClient.d.ts +694 -0
- package/sdk/application/client/CatalogApplicationClient.js +1629 -0
- package/sdk/application/client/CommonApplicationClient.d.ts +38 -0
- package/sdk/application/client/CommonApplicationClient.js +105 -0
- package/sdk/application/client/CommunicationApplicationClient.d.ts +39 -0
- package/sdk/application/client/CommunicationApplicationClient.js +131 -0
- package/sdk/application/client/ConfigurationApplicationClient.d.ts +210 -0
- package/sdk/application/client/ConfigurationApplicationClient.js +649 -0
- package/sdk/application/client/ContentApplicationClient.d.ts +256 -0
- package/sdk/application/client/ContentApplicationClient.js +785 -0
- package/sdk/application/client/FileStorageApplicationClient.d.ts +88 -0
- package/sdk/application/client/FileStorageApplicationClient.js +214 -0
- package/sdk/application/client/LeadApplicationClient.d.ts +90 -0
- package/sdk/application/client/LeadApplicationClient.js +264 -0
- package/sdk/application/client/LogisticApplicationClient.d.ts +42 -0
- package/sdk/application/client/LogisticApplicationClient.js +128 -0
- package/sdk/application/client/OrderApplicationClient.d.ts +190 -0
- package/sdk/application/client/OrderApplicationClient.js +479 -0
- package/sdk/application/client/PaymentApplicationClient.d.ts +454 -0
- package/sdk/application/client/PaymentApplicationClient.js +1378 -0
- package/sdk/application/client/PosCartApplicationClient.d.ts +449 -0
- package/sdk/application/client/PosCartApplicationClient.js +1123 -0
- package/sdk/application/client/RewardsApplicationClient.d.ts +93 -0
- package/sdk/application/client/RewardsApplicationClient.js +293 -0
- package/sdk/application/client/ShareApplicationClient.d.ts +87 -0
- package/sdk/application/client/ShareApplicationClient.js +268 -0
- package/sdk/application/client/ThemeApplicationClient.d.ts +52 -0
- package/sdk/application/client/ThemeApplicationClient.js +161 -0
- package/sdk/application/client/UserApplicationClient.d.ts +446 -0
- package/sdk/application/client/UserApplicationClient.js +1275 -0
- package/sdk/application/constructUrl.d.ts +5 -0
- package/sdk/application/constructUrl.js +13 -0
- package/sdk/application/index.d.ts +2 -0
- package/sdk/application/index.js +4 -0
- package/sdk/application/models/CartValidator.d.ts +29 -0
- package/sdk/application/models/CartValidator.js +223 -0
- package/sdk/application/models/CatalogValidator.d.ts +33 -0
- package/sdk/application/models/CatalogValidator.js +233 -0
- package/sdk/application/models/CommonValidator.d.ts +5 -0
- package/sdk/application/models/CommonValidator.js +18 -0
- package/sdk/application/models/CommunicationValidator.d.ts +6 -0
- package/sdk/application/models/CommunicationValidator.js +20 -0
- package/sdk/application/models/ConfigurationValidator.d.ts +19 -0
- package/sdk/application/models/ConfigurationValidator.js +88 -0
- package/sdk/application/models/ContentValidator.d.ts +22 -0
- package/sdk/application/models/ContentValidator.js +106 -0
- package/sdk/application/models/FileStorageValidator.d.ts +6 -0
- package/sdk/application/models/FileStorageValidator.js +24 -0
- package/sdk/application/models/LeadValidator.d.ts +10 -0
- package/sdk/application/models/LeadValidator.js +48 -0
- package/sdk/application/models/LogisticValidator.d.ts +6 -0
- package/sdk/application/models/LogisticValidator.js +22 -0
- package/sdk/application/models/OrderValidator.d.ts +15 -0
- package/sdk/application/models/OrderValidator.js +87 -0
- package/sdk/application/models/PaymentValidator.d.ts +40 -0
- package/sdk/application/models/PaymentValidator.js +235 -0
- package/sdk/application/models/PosCartValidator.d.ts +30 -0
- package/sdk/application/models/PosCartValidator.js +232 -0
- package/sdk/application/models/RewardsValidator.d.ts +10 -0
- package/sdk/application/models/RewardsValidator.js +43 -0
- package/sdk/application/models/ShareValidator.d.ts +10 -0
- package/sdk/application/models/ShareValidator.js +44 -0
- package/sdk/application/models/ThemeValidator.d.ts +7 -0
- package/sdk/application/models/ThemeValidator.js +27 -0
- package/sdk/application/models/UserValidator.d.ts +38 -0
- package/sdk/application/models/UserValidator.js +233 -0
- package/sdk/common/AxiosHelper.d.ts +1 -0
- package/sdk/common/AxiosHelper.js +141 -0
- package/sdk/common/Constant.d.ts +294 -0
- package/sdk/common/Constant.js +332 -0
- package/sdk/common/FDKError.d.ts +26 -0
- package/sdk/common/FDKError.js +51 -0
- package/sdk/common/Logger.d.ts +2 -0
- package/sdk/common/Logger.js +85 -0
- package/sdk/common/Paginator.d.ts +16 -0
- package/sdk/common/Paginator.js +26 -0
- package/sdk/common/RequestSigner.d.ts +1 -0
- package/sdk/common/RequestSigner.js +306 -0
- package/sdk/common/Utility.d.ts +9 -0
- package/sdk/common/Utility.js +86 -0
- package/sdk/common/utils.d.ts +14 -0
- package/sdk/common/utils.js +165 -0
- package/sdk/platform/OAuthClient.d.ts +26 -0
- package/sdk/platform/OAuthClient.js +221 -0
- package/sdk/platform/PlatformAPIClient.d.ts +12 -0
- package/sdk/platform/PlatformAPIClient.js +43 -0
- package/sdk/platform/PlatformApplicationClient.d.ts +24398 -0
- package/sdk/platform/PlatformApplicationClient.js +23185 -0
- package/sdk/platform/PlatformApplicationModels.d.ts +333 -0
- package/sdk/platform/PlatformApplicationModels.js +21262 -0
- package/sdk/platform/PlatformClient.d.ts +9535 -0
- package/sdk/platform/PlatformClient.js +12336 -0
- package/sdk/platform/PlatformConfig.d.ts +29 -0
- package/sdk/platform/PlatformConfig.js +36 -0
- package/sdk/platform/PlatformModels.d.ts +1396 -0
- package/sdk/platform/PlatformModels.js +19222 -0
- package/sdk/platform/client/AnalyticsPlatformClient.d.ts +84 -0
- package/sdk/platform/client/AnalyticsPlatformClient.js +215 -0
- package/sdk/platform/client/AuditTrailPlatformClient.d.ts +38 -0
- package/sdk/platform/client/AuditTrailPlatformClient.js +133 -0
- package/sdk/platform/client/BillingPlatformClient.d.ts +109 -0
- package/sdk/platform/client/BillingPlatformClient.js +381 -0
- package/sdk/platform/client/CatalogPlatformClient.d.ts +806 -0
- package/sdk/platform/client/CatalogPlatformClient.js +2462 -0
- package/sdk/platform/client/CommonPlatformClient.d.ts +30 -0
- package/sdk/platform/client/CommonPlatformClient.js +84 -0
- package/sdk/platform/client/CommunicationPlatformClient.d.ts +26 -0
- package/sdk/platform/client/CommunicationPlatformClient.js +72 -0
- package/sdk/platform/client/CompanyProfilePlatformClient.d.ts +182 -0
- package/sdk/platform/client/CompanyProfilePlatformClient.js +540 -0
- package/sdk/platform/client/ConfigurationPlatformClient.d.ts +277 -0
- package/sdk/platform/client/ConfigurationPlatformClient.js +806 -0
- package/sdk/platform/client/DiscountPlatformClient.d.ts +118 -0
- package/sdk/platform/client/DiscountPlatformClient.js +364 -0
- package/sdk/platform/client/FileStoragePlatformClient.d.ts +111 -0
- package/sdk/platform/client/FileStoragePlatformClient.js +268 -0
- package/sdk/platform/client/InventoryPlatformClient.d.ts +125 -0
- package/sdk/platform/client/InventoryPlatformClient.js +409 -0
- package/sdk/platform/client/LeadPlatformClient.d.ts +150 -0
- package/sdk/platform/client/LeadPlatformClient.js +439 -0
- package/sdk/platform/client/OrderPlatformClient.d.ts +190 -0
- package/sdk/platform/client/OrderPlatformClient.js +521 -0
- package/sdk/platform/client/PaymentPlatformClient.d.ts +98 -0
- package/sdk/platform/client/PaymentPlatformClient.js +331 -0
- package/sdk/platform/client/WebhookPlatformClient.d.ts +64 -0
- package/sdk/platform/client/WebhookPlatformClient.js +207 -0
- package/sdk/platform/index.d.ts +2 -0
- package/sdk/platform/index.js +4 -0
- package/sdk/platform/models/AnalyticsValidator.d.ts +7 -0
- package/sdk/platform/models/AnalyticsValidator.js +36 -0
- package/sdk/platform/models/AuditTrailValidator.d.ts +7 -0
- package/sdk/platform/models/AuditTrailValidator.js +26 -0
- package/sdk/platform/models/BillingValidator.d.ts +15 -0
- package/sdk/platform/models/BillingValidator.js +72 -0
- package/sdk/platform/models/CartValidator.d.ts +0 -0
- package/sdk/platform/models/CartValidator.js +0 -0
- package/sdk/platform/models/CatalogValidator.d.ts +74 -0
- package/sdk/platform/models/CatalogValidator.js +484 -0
- package/sdk/platform/models/CommonValidator.d.ts +5 -0
- package/sdk/platform/models/CommonValidator.js +18 -0
- package/sdk/platform/models/CommunicationValidator.d.ts +4 -0
- package/sdk/platform/models/CommunicationValidator.js +11 -0
- package/sdk/platform/models/CompanyProfileValidator.d.ts +17 -0
- package/sdk/platform/models/CompanyProfileValidator.js +93 -0
- package/sdk/platform/models/ConfigurationValidator.d.ts +21 -0
- package/sdk/platform/models/ConfigurationValidator.js +134 -0
- package/sdk/platform/models/ContentValidator.d.ts +0 -0
- package/sdk/platform/models/ContentValidator.js +0 -0
- package/sdk/platform/models/DiscountValidator.d.ts +13 -0
- package/sdk/platform/models/DiscountValidator.js +75 -0
- package/sdk/platform/models/FileStorageValidator.d.ts +9 -0
- package/sdk/platform/models/FileStorageValidator.js +44 -0
- package/sdk/platform/models/InventoryValidator.d.ts +15 -0
- package/sdk/platform/models/InventoryValidator.js +81 -0
- package/sdk/platform/models/LeadValidator.d.ts +14 -0
- package/sdk/platform/models/LeadValidator.js +78 -0
- package/sdk/platform/models/OrderValidator.d.ts +14 -0
- package/sdk/platform/models/OrderValidator.js +110 -0
- package/sdk/platform/models/PartnerValidator.d.ts +0 -0
- package/sdk/platform/models/PartnerValidator.js +0 -0
- package/sdk/platform/models/PaymentValidator.d.ts +13 -0
- package/sdk/platform/models/PaymentValidator.js +65 -0
- package/sdk/platform/models/RewardsValidator.d.ts +0 -0
- package/sdk/platform/models/RewardsValidator.js +0 -0
- package/sdk/platform/models/ShareValidator.d.ts +0 -0
- package/sdk/platform/models/ShareValidator.js +0 -0
- package/sdk/platform/models/ThemeValidator.d.ts +0 -0
- package/sdk/platform/models/ThemeValidator.js +0 -0
- package/sdk/platform/models/UserValidator.d.ts +0 -0
- package/sdk/platform/models/UserValidator.js +0 -0
- package/sdk/platform/models/WebhookValidator.d.ts +9 -0
- package/sdk/platform/models/WebhookValidator.js +42 -0
- package/sdk/public/PublicAPIClient.d.ts +11 -0
- package/sdk/public/PublicAPIClient.js +38 -0
- package/sdk/public/PublicClient.d.ts +12 -0
- package/sdk/public/PublicClient.js +24 -0
- package/sdk/public/PublicConfig.d.ts +10 -0
- package/sdk/public/PublicConfig.js +12 -0
- package/sdk/public/PublicModels.d.ts +50 -0
- package/sdk/public/PublicModels.js +712 -0
- package/sdk/public/client/ConfigurationPublicClient.d.ts +38 -0
- package/sdk/public/client/ConfigurationPublicClient.js +102 -0
- package/sdk/public/client/InventoryPublicClient.d.ts +81 -0
- package/sdk/public/client/InventoryPublicClient.js +239 -0
- package/sdk/public/client/WebhookPublicClient.d.ts +28 -0
- package/sdk/public/client/WebhookPublicClient.js +92 -0
- package/sdk/public/constructUrl.d.ts +5 -0
- package/sdk/public/constructUrl.js +13 -0
- package/sdk/public/index.d.ts +2 -0
- package/sdk/public/index.js +4 -0
- package/sdk/public/models/ConfigurationValidator.d.ts +5 -0
- package/sdk/public/models/ConfigurationValidator.js +18 -0
- package/sdk/public/models/InventoryValidator.d.ts +9 -0
- package/sdk/public/models/InventoryValidator.js +43 -0
- package/sdk/public/models/WebhookValidator.d.ts +5 -0
- package/sdk/public/models/WebhookValidator.js +14 -0
- package/tests/application/catalog.spec.js +47 -0
- package/tests/common/action-url.spec.js +35 -0
- package/tests/common/schema/action-url.json +163 -0
- package/tests/common/schema/url-action.json +667 -0
- package/tests/common/url-action.spec.js +48 -0
- package/tests/helpers/cookie.helper.js +31 -0
- package/tests/helpers/oauth.helper.js +43 -0
- package/tests/platform/catalog.spec.js +49 -0
- package/tests/public/location.spec.js +39 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
const Paginator = require("../../common/Paginator");
|
|
2
|
+
const PlatformAPIClient = require("../PlatformAPIClient");
|
|
3
|
+
const { FDKClientValidationError } = require("../../common/FDKError");
|
|
4
|
+
const BillingValidator = require("../models/BillingValidator");
|
|
5
|
+
class Billing {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {Object} arg - Arg object.
|
|
12
|
+
* @param {string} arg.plan - ID of the plan.
|
|
13
|
+
* @param {string} arg.couponCode - Coupon code.
|
|
14
|
+
* @summary: Check coupon validity
|
|
15
|
+
* @description: Check coupon validity.
|
|
16
|
+
*/
|
|
17
|
+
checkCouponValidity({ plan, couponCode } = {}) {
|
|
18
|
+
const { error } = BillingValidator.checkCouponValidity().validate(
|
|
19
|
+
{
|
|
20
|
+
plan,
|
|
21
|
+
couponCode,
|
|
22
|
+
},
|
|
23
|
+
{ abortEarly: false, allowUnknown: true }
|
|
24
|
+
);
|
|
25
|
+
if (error) {
|
|
26
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const query_params = {};
|
|
30
|
+
query_params["plan"] = plan;
|
|
31
|
+
query_params["coupon_code"] = couponCode;
|
|
32
|
+
|
|
33
|
+
const xHeaders = {};
|
|
34
|
+
|
|
35
|
+
return PlatformAPIClient.execute(
|
|
36
|
+
this.config,
|
|
37
|
+
"get",
|
|
38
|
+
`/service/platform/billing/v1.0/company/${this.config.companyId}/coupon/check-validity`,
|
|
39
|
+
query_params,
|
|
40
|
+
undefined,
|
|
41
|
+
xHeaders
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @param {Object} arg - Arg object.
|
|
47
|
+
* @param {string} arg.extensionId - Extension _id
|
|
48
|
+
* @param {CreateSubscriptionCharge} arg.body
|
|
49
|
+
* @summary: Create subscription charge
|
|
50
|
+
* @description: Register subscription charge for a seller of your extension.
|
|
51
|
+
*/
|
|
52
|
+
createSubscriptionCharge({ extensionId, body } = {}) {
|
|
53
|
+
const { error } = BillingValidator.createSubscriptionCharge().validate(
|
|
54
|
+
{
|
|
55
|
+
extensionId,
|
|
56
|
+
body,
|
|
57
|
+
},
|
|
58
|
+
{ abortEarly: false, allowUnknown: true }
|
|
59
|
+
);
|
|
60
|
+
if (error) {
|
|
61
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const query_params = {};
|
|
65
|
+
|
|
66
|
+
const xHeaders = {};
|
|
67
|
+
|
|
68
|
+
return PlatformAPIClient.execute(
|
|
69
|
+
this.config,
|
|
70
|
+
"post",
|
|
71
|
+
`/service/platform/billing/v1.0/company/${this.config.companyId}/extension/${extensionId}/subscription`,
|
|
72
|
+
query_params,
|
|
73
|
+
body,
|
|
74
|
+
xHeaders
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param {Object} arg - Arg object.
|
|
80
|
+
* @param {string} arg.extensionId - Extension _id
|
|
81
|
+
* @param {string} arg.subscriptionId - Subscription charge _id
|
|
82
|
+
* @summary: Get subscription charge details
|
|
83
|
+
* @description: Get created subscription charge details
|
|
84
|
+
*/
|
|
85
|
+
getSubscriptionCharge({ extensionId, subscriptionId } = {}) {
|
|
86
|
+
const { error } = BillingValidator.getSubscriptionCharge().validate(
|
|
87
|
+
{
|
|
88
|
+
extensionId,
|
|
89
|
+
subscriptionId,
|
|
90
|
+
},
|
|
91
|
+
{ abortEarly: false, allowUnknown: true }
|
|
92
|
+
);
|
|
93
|
+
if (error) {
|
|
94
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const query_params = {};
|
|
98
|
+
|
|
99
|
+
const xHeaders = {};
|
|
100
|
+
|
|
101
|
+
return PlatformAPIClient.execute(
|
|
102
|
+
this.config,
|
|
103
|
+
"get",
|
|
104
|
+
`/service/platform/billing/v1.0/company/${this.config.companyId}/extension/${extensionId}/subscription/${subscriptionId}`,
|
|
105
|
+
query_params,
|
|
106
|
+
undefined,
|
|
107
|
+
xHeaders
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @param {Object} arg - Arg object.
|
|
113
|
+
* @param {string} arg.extensionId - Extension _id
|
|
114
|
+
* @param {string} arg.subscriptionId - Subscription charge _id
|
|
115
|
+
* @summary: Cancel subscription charge
|
|
116
|
+
* @description: Cancel subscription and attached charges.
|
|
117
|
+
*/
|
|
118
|
+
cancelSubscriptionCharge({ extensionId, subscriptionId } = {}) {
|
|
119
|
+
const { error } = BillingValidator.cancelSubscriptionCharge().validate(
|
|
120
|
+
{
|
|
121
|
+
extensionId,
|
|
122
|
+
subscriptionId,
|
|
123
|
+
},
|
|
124
|
+
{ abortEarly: false, allowUnknown: true }
|
|
125
|
+
);
|
|
126
|
+
if (error) {
|
|
127
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const query_params = {};
|
|
131
|
+
|
|
132
|
+
const xHeaders = {};
|
|
133
|
+
|
|
134
|
+
return PlatformAPIClient.execute(
|
|
135
|
+
this.config,
|
|
136
|
+
"post",
|
|
137
|
+
`/service/platform/billing/v1.0/company/${this.config.companyId}/extension/${extensionId}/subscription/${subscriptionId}/cancel`,
|
|
138
|
+
query_params,
|
|
139
|
+
undefined,
|
|
140
|
+
xHeaders
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @param {Object} arg - Arg object.
|
|
146
|
+
* @summary: Get invoices
|
|
147
|
+
* @description: Get invoices.
|
|
148
|
+
*/
|
|
149
|
+
getInvoices({} = {}) {
|
|
150
|
+
const { error } = BillingValidator.getInvoices().validate(
|
|
151
|
+
{},
|
|
152
|
+
{ abortEarly: false, allowUnknown: true }
|
|
153
|
+
);
|
|
154
|
+
if (error) {
|
|
155
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const query_params = {};
|
|
159
|
+
|
|
160
|
+
const xHeaders = {};
|
|
161
|
+
|
|
162
|
+
return PlatformAPIClient.execute(
|
|
163
|
+
this.config,
|
|
164
|
+
"get",
|
|
165
|
+
`/service/platform/billing/v1.0/company/${this.config.companyId}/invoice/list`,
|
|
166
|
+
query_params,
|
|
167
|
+
undefined,
|
|
168
|
+
xHeaders
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @param {Object} arg - Arg object.
|
|
174
|
+
* @param {string} arg.invoiceId - Invoice id
|
|
175
|
+
* @summary: Get invoice by id
|
|
176
|
+
* @description: Get invoice by id.
|
|
177
|
+
*/
|
|
178
|
+
getInvoiceById({ invoiceId } = {}) {
|
|
179
|
+
const { error } = BillingValidator.getInvoiceById().validate(
|
|
180
|
+
{
|
|
181
|
+
invoiceId,
|
|
182
|
+
},
|
|
183
|
+
{ abortEarly: false, allowUnknown: true }
|
|
184
|
+
);
|
|
185
|
+
if (error) {
|
|
186
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const query_params = {};
|
|
190
|
+
|
|
191
|
+
const xHeaders = {};
|
|
192
|
+
|
|
193
|
+
return PlatformAPIClient.execute(
|
|
194
|
+
this.config,
|
|
195
|
+
"get",
|
|
196
|
+
`/service/platform/billing/v1.0/company/${this.config.companyId}/invoice/${invoiceId}`,
|
|
197
|
+
query_params,
|
|
198
|
+
undefined,
|
|
199
|
+
xHeaders
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* @param {Object} arg - Arg object.
|
|
205
|
+
* @summary: Get subscription customer detail
|
|
206
|
+
* @description: Get subscription customer detail.
|
|
207
|
+
*/
|
|
208
|
+
getCustomerDetail({} = {}) {
|
|
209
|
+
const { error } = BillingValidator.getCustomerDetail().validate(
|
|
210
|
+
{},
|
|
211
|
+
{ abortEarly: false, allowUnknown: true }
|
|
212
|
+
);
|
|
213
|
+
if (error) {
|
|
214
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const query_params = {};
|
|
218
|
+
|
|
219
|
+
const xHeaders = {};
|
|
220
|
+
|
|
221
|
+
return PlatformAPIClient.execute(
|
|
222
|
+
this.config,
|
|
223
|
+
"get",
|
|
224
|
+
`/service/platform/billing/v1.0/company/${this.config.companyId}/subscription/customer-detail`,
|
|
225
|
+
query_params,
|
|
226
|
+
undefined,
|
|
227
|
+
xHeaders
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @param {Object} arg - Arg object.
|
|
233
|
+
* @param {SubscriptionCustomerCreate} arg.body
|
|
234
|
+
* @summary: Upsert subscription customer detail
|
|
235
|
+
* @description: Upsert subscription customer detail.
|
|
236
|
+
*/
|
|
237
|
+
upsertCustomerDetail({ body } = {}) {
|
|
238
|
+
const { error } = BillingValidator.upsertCustomerDetail().validate(
|
|
239
|
+
{
|
|
240
|
+
body,
|
|
241
|
+
},
|
|
242
|
+
{ abortEarly: false, allowUnknown: true }
|
|
243
|
+
);
|
|
244
|
+
if (error) {
|
|
245
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const query_params = {};
|
|
249
|
+
|
|
250
|
+
const xHeaders = {};
|
|
251
|
+
|
|
252
|
+
return PlatformAPIClient.execute(
|
|
253
|
+
this.config,
|
|
254
|
+
"post",
|
|
255
|
+
`/service/platform/billing/v1.0/company/${this.config.companyId}/subscription/customer-detail`,
|
|
256
|
+
query_params,
|
|
257
|
+
body,
|
|
258
|
+
xHeaders
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* @param {Object} arg - Arg object.
|
|
264
|
+
* @summary: Get current subscription detail
|
|
265
|
+
* @description: If subscription is active then it will return is_enabled true and return subscription object. If subscription is not active then is_enabled false and message.
|
|
266
|
+
*/
|
|
267
|
+
getSubscription({} = {}) {
|
|
268
|
+
const { error } = BillingValidator.getSubscription().validate(
|
|
269
|
+
{},
|
|
270
|
+
{ abortEarly: false, allowUnknown: true }
|
|
271
|
+
);
|
|
272
|
+
if (error) {
|
|
273
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const query_params = {};
|
|
277
|
+
|
|
278
|
+
const xHeaders = {};
|
|
279
|
+
|
|
280
|
+
return PlatformAPIClient.execute(
|
|
281
|
+
this.config,
|
|
282
|
+
"get",
|
|
283
|
+
`/service/platform/billing/v1.0/company/${this.config.companyId}/subscription/current`,
|
|
284
|
+
query_params,
|
|
285
|
+
undefined,
|
|
286
|
+
xHeaders
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* @param {Object} arg - Arg object.
|
|
292
|
+
* @summary: Get subscription subscription limits
|
|
293
|
+
* @description: Get subscription subscription limits.
|
|
294
|
+
*/
|
|
295
|
+
getFeatureLimitConfig({} = {}) {
|
|
296
|
+
const { error } = BillingValidator.getFeatureLimitConfig().validate(
|
|
297
|
+
{},
|
|
298
|
+
{ abortEarly: false, allowUnknown: true }
|
|
299
|
+
);
|
|
300
|
+
if (error) {
|
|
301
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const query_params = {};
|
|
305
|
+
|
|
306
|
+
const xHeaders = {};
|
|
307
|
+
|
|
308
|
+
return PlatformAPIClient.execute(
|
|
309
|
+
this.config,
|
|
310
|
+
"get",
|
|
311
|
+
`/service/platform/billing/v1.0/company/${this.config.companyId}/subscription/current-limit`,
|
|
312
|
+
query_params,
|
|
313
|
+
undefined,
|
|
314
|
+
xHeaders
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @param {Object} arg - Arg object.
|
|
320
|
+
* @param {SubscriptionActivateReq} arg.body
|
|
321
|
+
* @summary: Activate subscription
|
|
322
|
+
* @description: It will activate subscription plan for customer
|
|
323
|
+
*/
|
|
324
|
+
activateSubscriptionPlan({ body } = {}) {
|
|
325
|
+
const { error } = BillingValidator.activateSubscriptionPlan().validate(
|
|
326
|
+
{
|
|
327
|
+
body,
|
|
328
|
+
},
|
|
329
|
+
{ abortEarly: false, allowUnknown: true }
|
|
330
|
+
);
|
|
331
|
+
if (error) {
|
|
332
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const query_params = {};
|
|
336
|
+
|
|
337
|
+
const xHeaders = {};
|
|
338
|
+
|
|
339
|
+
return PlatformAPIClient.execute(
|
|
340
|
+
this.config,
|
|
341
|
+
"post",
|
|
342
|
+
`/service/platform/billing/v1.0/company/${this.config.companyId}/subscription/activate`,
|
|
343
|
+
query_params,
|
|
344
|
+
body,
|
|
345
|
+
xHeaders
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* @param {Object} arg - Arg object.
|
|
351
|
+
* @param {CancelSubscriptionReq} arg.body
|
|
352
|
+
* @summary: Cancel subscription
|
|
353
|
+
* @description: It will cancel current active subscription.
|
|
354
|
+
*/
|
|
355
|
+
cancelSubscriptionPlan({ body } = {}) {
|
|
356
|
+
const { error } = BillingValidator.cancelSubscriptionPlan().validate(
|
|
357
|
+
{
|
|
358
|
+
body,
|
|
359
|
+
},
|
|
360
|
+
{ abortEarly: false, allowUnknown: true }
|
|
361
|
+
);
|
|
362
|
+
if (error) {
|
|
363
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const query_params = {};
|
|
367
|
+
|
|
368
|
+
const xHeaders = {};
|
|
369
|
+
|
|
370
|
+
return PlatformAPIClient.execute(
|
|
371
|
+
this.config,
|
|
372
|
+
"post",
|
|
373
|
+
`/service/platform/billing/v1.0/company/${this.config.companyId}/subscription/cancel`,
|
|
374
|
+
query_params,
|
|
375
|
+
body,
|
|
376
|
+
xHeaders
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
module.exports = Billing;
|