@gofynd/fdk-client-javascript 1.1.3 → 1.1.5
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/README.md +1 -0
- package/index.d.ts +4 -1
- package/index.js +7 -0
- package/package.json +1 -1
- package/partner.d.ts +4 -0
- package/partner.js +7 -0
- package/sdk/application/Common/CommonApplicationModel.js +4 -0
- package/sdk/application/Configuration/ConfigurationApplicationModel.js +5 -5
- package/sdk/application/Lead/LeadApplicationModel.js +4 -1
- package/sdk/partner/OAuthClient.d.ts +14 -0
- package/sdk/partner/OAuthClient.js +112 -0
- package/sdk/partner/PartnerAPIClient.d.ts +12 -0
- package/sdk/partner/PartnerAPIClient.js +42 -0
- package/sdk/partner/PartnerClient.d.ts +6 -0
- package/sdk/partner/PartnerClient.js +17 -0
- package/sdk/partner/PartnerConfig.d.ts +30 -0
- package/sdk/partner/PartnerConfig.js +39 -0
- package/sdk/partner/index.d.ts +3 -0
- package/sdk/partner/index.js +5 -0
- package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +32 -0
- package/sdk/platform/Cart/CartPlatformApplicationClient.js +184 -0
- package/sdk/platform/Cart/CartPlatformApplicationValidator.d.ts +3 -0
- package/sdk/platform/Cart/CartPlatformApplicationValidator.js +19 -0
- package/sdk/platform/Cart/CartPlatformModel.d.ts +6 -0
- package/sdk/platform/Cart/CartPlatformModel.js +72 -1
- package/sdk/platform/Catalog/CatalogPlatformModel.js +2 -2
- package/sdk/platform/Common/CommonPlatformModel.js +4 -0
- package/sdk/platform/Configuration/ConfigurationPlatformModel.js +8 -7
- package/sdk/platform/Order/OrderPlatformClient.d.ts +3 -1
- package/sdk/platform/Order/OrderPlatformClient.js +5 -0
- package/sdk/platform/Order/OrderPlatformModel.js +1 -1
- package/sdk/platform/Order/OrderPlatformValidator.js +1 -0
- package/sdk/platform/Payment/PaymentPlatformModel.d.ts +4 -0
- package/sdk/platform/Payment/PaymentPlatformModel.js +42 -7
- package/sdk/platform/PlatformApplicationClient.d.ts +103 -2
- package/sdk/platform/PlatformApplicationClient.js +109 -0
- package/sdk/platform/PlatformClient.d.ts +642 -36
- package/sdk/platform/PlatformClient.js +773 -18
- package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationClient.d.ts +134 -0
- package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationClient.js +852 -0
- package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationValidator.d.ts +16 -0
- package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationValidator.js +81 -0
- package/sdk/platform/Serviceability/ServiceabilityPlatformClient.d.ts +223 -0
- package/sdk/platform/Serviceability/ServiceabilityPlatformClient.js +1296 -0
- package/sdk/platform/Serviceability/ServiceabilityPlatformModel.d.ts +97 -0
- package/sdk/platform/Serviceability/ServiceabilityPlatformModel.js +776 -0
- package/sdk/platform/Serviceability/ServiceabilityPlatformValidator.d.ts +21 -0
- package/sdk/platform/Serviceability/ServiceabilityPlatformValidator.js +130 -0
- package/sdk/platform/index.d.ts +1 -0
- package/sdk/platform/index.js +2 -0
- package/sdk/public/Configuration/ConfigurationPublicModel.js +5 -0
package/README.md
CHANGED
|
@@ -184,6 +184,7 @@ import { ApplicationConfig, ApplicationClient } from "fdk-client-javascript";
|
|
|
184
184
|
### Documentation
|
|
185
185
|
|
|
186
186
|
- [Application Front](documentation/application/README.md)
|
|
187
|
+
- [Partner Front](documentation/partner/README.md)
|
|
187
188
|
- [Platform Front](documentation/platform/README.md)
|
|
188
189
|
- [Public Front](documentation/public/README.md)
|
|
189
190
|
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ApplicationConfig } from "./sdk/application";
|
|
2
2
|
import { ApplicationClient } from "./sdk/application";
|
|
3
3
|
import { ApplicationModel } from "./sdk/application";
|
|
4
|
+
import { PartnerConfig } from "./sdk/partner";
|
|
5
|
+
import { PartnerClient } from "./sdk/partner";
|
|
6
|
+
import { PartnerModel } from "./sdk/partner";
|
|
4
7
|
import { PlatformConfig } from "./sdk/platform";
|
|
5
8
|
import { PlatformClient } from "./sdk/platform";
|
|
6
9
|
import { PlatformModel } from "./sdk/platform";
|
|
@@ -10,4 +13,4 @@ import { PublicModel } from "./sdk/public";
|
|
|
10
13
|
import { fdkAxios } from "./sdk/common/AxiosHelper";
|
|
11
14
|
import Utility = require("./sdk/common/Utility");
|
|
12
15
|
import Constant = require("./sdk/common/Constant");
|
|
13
|
-
export { ApplicationConfig, ApplicationClient, ApplicationModel, PlatformConfig, PlatformClient, PlatformModel, PublicConfig, PublicClient, PublicModel, fdkAxios as FdkAxios, Utility, Constant };
|
|
16
|
+
export { ApplicationConfig, ApplicationClient, ApplicationModel, PartnerConfig, PartnerClient, PartnerModel, PlatformConfig, PlatformClient, PlatformModel, PublicConfig, PublicClient, PublicModel, fdkAxios as FdkAxios, Utility, Constant };
|
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
const { ApplicationConfig, ApplicationClient, ApplicationModel } = require('./sdk/application');
|
|
4
|
+
const { PartnerConfig, PartnerClient, PartnerModel } = require('./sdk/partner');
|
|
4
5
|
const { PlatformConfig, PlatformClient, PlatformModel } = require('./sdk/platform');
|
|
5
6
|
const { PublicConfig, PublicClient, PublicModel } = require('./sdk/public');
|
|
6
7
|
const {fdkAxios} = require('./sdk/common/AxiosHelper');
|
|
@@ -18,6 +19,12 @@ module.exports = {
|
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
|
|
22
|
+
PartnerConfig,
|
|
23
|
+
PartnerClient,
|
|
24
|
+
PartnerModel,
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
21
28
|
PlatformConfig,
|
|
22
29
|
PlatformClient,
|
|
23
30
|
PlatformModel,
|
package/package.json
CHANGED
package/partner.d.ts
ADDED
package/partner.js
ADDED
|
@@ -96,14 +96,18 @@ class CommonModel {
|
|
|
96
96
|
__v: Joi.number(),
|
|
97
97
|
_id: Joi.string().allow(""),
|
|
98
98
|
capital: Joi.string().allow(""),
|
|
99
|
+
country_code: Joi.string().allow(""),
|
|
99
100
|
currency: Joi.string().allow(""),
|
|
100
101
|
default_currency: CommonModel.LocationDefaultCurrency(),
|
|
101
102
|
default_language: CommonModel.LocationDefaultLanguage(),
|
|
102
103
|
iso2: Joi.string().allow(""),
|
|
103
104
|
iso3: Joi.string().allow(""),
|
|
105
|
+
latitude: Joi.string().allow(""),
|
|
106
|
+
longitude: Joi.string().allow(""),
|
|
104
107
|
name: Joi.string().allow(""),
|
|
105
108
|
parent: Joi.string().allow(""),
|
|
106
109
|
phone_code: Joi.string().allow(""),
|
|
110
|
+
state_code: Joi.string().allow(""),
|
|
107
111
|
type: Joi.string().allow(""),
|
|
108
112
|
uid: Joi.number(),
|
|
109
113
|
});
|
|
@@ -93,13 +93,13 @@ class ConfigurationModel {
|
|
|
93
93
|
static ApplicationDetail() {
|
|
94
94
|
return Joi.object({
|
|
95
95
|
_id: Joi.string().allow(""),
|
|
96
|
-
banner: ConfigurationModel.SecureUrl()
|
|
97
|
-
description: Joi.string().allow("")
|
|
96
|
+
banner: ConfigurationModel.SecureUrl(),
|
|
97
|
+
description: Joi.string().allow(""),
|
|
98
98
|
domain: ConfigurationModel.Domain(),
|
|
99
99
|
domains: Joi.array().items(ConfigurationModel.Domain()),
|
|
100
|
-
favicon: ConfigurationModel.SecureUrl()
|
|
101
|
-
logo: ConfigurationModel.SecureUrl()
|
|
102
|
-
mobile_logo: ConfigurationModel.SecureUrl()
|
|
100
|
+
favicon: ConfigurationModel.SecureUrl(),
|
|
101
|
+
logo: ConfigurationModel.SecureUrl(),
|
|
102
|
+
mobile_logo: ConfigurationModel.SecureUrl(),
|
|
103
103
|
name: Joi.string().allow("").required(),
|
|
104
104
|
});
|
|
105
105
|
}
|
|
@@ -9,6 +9,7 @@ class LeadModel {
|
|
|
9
9
|
created_by: Joi.any(),
|
|
10
10
|
priority: LeadModel.PriorityEnum(),
|
|
11
11
|
status: Joi.string().allow(""),
|
|
12
|
+
subscribers: Joi.array().items(Joi.string().allow("")),
|
|
12
13
|
});
|
|
13
14
|
}
|
|
14
15
|
static AgentChangePayload() {
|
|
@@ -409,7 +410,9 @@ class LeadModel {
|
|
|
409
410
|
|
|
410
411
|
"log",
|
|
411
412
|
|
|
412
|
-
"comment"
|
|
413
|
+
"comment",
|
|
414
|
+
|
|
415
|
+
"thread"
|
|
413
416
|
);
|
|
414
417
|
}
|
|
415
418
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export = OAuthClient;
|
|
2
|
+
declare class OAuthClient extends BaseOAuthClient {
|
|
3
|
+
startAuthorization(options: any): string;
|
|
4
|
+
verifyCallback(query: any): Promise<void>;
|
|
5
|
+
renewAccessToken(isOfflineToken?: boolean): Promise<any>;
|
|
6
|
+
getNewAccessToken(): Promise<any>;
|
|
7
|
+
getAccesstokenObj({ grant_type, client_id, client_secret, scope }: {
|
|
8
|
+
grant_type: any;
|
|
9
|
+
client_id: any;
|
|
10
|
+
client_secret: any;
|
|
11
|
+
scope: any;
|
|
12
|
+
}): Promise<any>;
|
|
13
|
+
}
|
|
14
|
+
import BaseOAuthClient = require("../common/BaseOAuthClient");
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
const { fdkAxios } = require("../common/AxiosHelper");
|
|
2
|
+
const { FDKTokenIssueError } = require("../common/FDKError");
|
|
3
|
+
const { Logger } = require("../common/Logger");
|
|
4
|
+
const BaseOAuthClient = require("../common/BaseOAuthClient");
|
|
5
|
+
const querystring = require("query-string");
|
|
6
|
+
const { sign } = require("../common/RequestSigner");
|
|
7
|
+
|
|
8
|
+
class OAuthClient extends BaseOAuthClient {
|
|
9
|
+
constructor(config) {
|
|
10
|
+
super(config);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
startAuthorization(options) {
|
|
14
|
+
Logger({ type: "DEBUG", message: "Starting Authorization" });
|
|
15
|
+
let query = {
|
|
16
|
+
client_id: this.config.apiKey,
|
|
17
|
+
scope: options.scope.join(","),
|
|
18
|
+
redirect_uri: options.redirectUri,
|
|
19
|
+
state: options.state,
|
|
20
|
+
access_mode: options.access_mode,
|
|
21
|
+
response_type: "code",
|
|
22
|
+
extension_id: this.config.extensionId,
|
|
23
|
+
};
|
|
24
|
+
const queryString = querystring.stringify(query);
|
|
25
|
+
|
|
26
|
+
let reqPath = `/service/panel/authentication/v1.0/organization/${this.config.organizationId}/oauth/authorize?${queryString}`;
|
|
27
|
+
let signingOptions = {
|
|
28
|
+
method: "GET",
|
|
29
|
+
host: new URL(this.config.domain).host,
|
|
30
|
+
path: reqPath,
|
|
31
|
+
body: null,
|
|
32
|
+
headers: {},
|
|
33
|
+
signQuery: true,
|
|
34
|
+
};
|
|
35
|
+
signingOptions = sign(signingOptions);
|
|
36
|
+
Logger({ type: "DEBUG", message: "Authorization successful" });
|
|
37
|
+
|
|
38
|
+
return `${this.config.domain}${signingOptions.path}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async verifyCallback(query) {
|
|
42
|
+
if (query.error) {
|
|
43
|
+
throw new FDKOAuthCodeError(query.error_description, {
|
|
44
|
+
error: query.error,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
let res = await this.getAccesstokenObj({
|
|
50
|
+
grant_type: "authorization_code",
|
|
51
|
+
code: query.code,
|
|
52
|
+
});
|
|
53
|
+
res.expires_at =
|
|
54
|
+
res.expires_at || new Date().getTime() + res.expires_in * 1000;
|
|
55
|
+
this.setToken(res);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (error.isAxiosError) {
|
|
58
|
+
throw new FDKTokenIssueError(error.message);
|
|
59
|
+
}
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async renewAccessToken(isOfflineToken = true) {
|
|
65
|
+
if (isOfflineToken) {
|
|
66
|
+
await this.getNewAccessToken();
|
|
67
|
+
} else {
|
|
68
|
+
res = await this.getAccesstokenObj({
|
|
69
|
+
grant_type: "refresh_token",
|
|
70
|
+
refresh_token: this.refreshToken,
|
|
71
|
+
});
|
|
72
|
+
res.expires_at =
|
|
73
|
+
res.expires_at || new Date().getTime() + res.expires_in * 1000;
|
|
74
|
+
this.setToken(res);
|
|
75
|
+
return res;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async getNewAccessToken() {
|
|
80
|
+
try {
|
|
81
|
+
let res = await this.getAccesstokenObj({
|
|
82
|
+
grant_type: "client_credentials",
|
|
83
|
+
client_id: this.config.apiKey,
|
|
84
|
+
client_secret: this.config.apiSecret,
|
|
85
|
+
scope: this.config.scope,
|
|
86
|
+
});
|
|
87
|
+
res.expires_at =
|
|
88
|
+
res.expires_at || new Date().getTime() + res.expires_in * 1000;
|
|
89
|
+
this.setToken(res);
|
|
90
|
+
return this.token;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (error.isAxiosError) {
|
|
93
|
+
throw new FDKTokenIssueError(error.message);
|
|
94
|
+
}
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async getAccesstokenObj({ grant_type, client_id, client_secret, scope }) {
|
|
100
|
+
Logger({ type: "DEBUG", message: "Processing Access token object..." });
|
|
101
|
+
let reqData = {
|
|
102
|
+
grant_type: grant_type,
|
|
103
|
+
client_id,
|
|
104
|
+
client_secret,
|
|
105
|
+
scope,
|
|
106
|
+
};
|
|
107
|
+
let url = `${this.config.domain}/service/panel/authentication/v1.0/organization/${this.config.organizationId}/oauth/token`;
|
|
108
|
+
return fdkAxios.post(url, reqData);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
module.exports = OAuthClient;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export = APIClient;
|
|
2
|
+
declare class APIClient {
|
|
3
|
+
/**
|
|
4
|
+
* @param {object} conf
|
|
5
|
+
* @param {string} method
|
|
6
|
+
* @param {string} url
|
|
7
|
+
* @param {object} query
|
|
8
|
+
* @param {object} body
|
|
9
|
+
*/
|
|
10
|
+
static execute(conf: object, method: string, url: string, query: object, body: object): Promise<any>;
|
|
11
|
+
get(url: any, config: any): Promise<any>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const { fdkAxios } = require("../common/AxiosHelper");
|
|
2
|
+
|
|
3
|
+
class APIClient {
|
|
4
|
+
/**
|
|
5
|
+
* @param {object} conf
|
|
6
|
+
* @param {string} method
|
|
7
|
+
* @param {string} url
|
|
8
|
+
* @param {object} query
|
|
9
|
+
* @param {object} body
|
|
10
|
+
*/
|
|
11
|
+
static async execute(conf, method, url, query, body) {
|
|
12
|
+
const token = await conf.oauthClient.getNewAccessToken();
|
|
13
|
+
|
|
14
|
+
const extraHeaders = conf.extraHeaders.reduce((acc, curr) => {
|
|
15
|
+
acc = { ...acc, ...curr };
|
|
16
|
+
return acc;
|
|
17
|
+
}, {});
|
|
18
|
+
|
|
19
|
+
const rawRequest = {
|
|
20
|
+
baseURL: conf.domain,
|
|
21
|
+
method: method,
|
|
22
|
+
url: url,
|
|
23
|
+
params: query,
|
|
24
|
+
data: body,
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: "Bearer " + token,
|
|
27
|
+
...extraHeaders,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return fdkAxios.request(rawRequest);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async get(url, config) {
|
|
35
|
+
let access_token = await this.configuration.getAccessToken();
|
|
36
|
+
config = config || {};
|
|
37
|
+
config.headers = config.headers || {};
|
|
38
|
+
config.headers.Authorization = "Bearer " + access_token;
|
|
39
|
+
return axios.get(url);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
module.exports = APIClient;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { FDKClientValidationError } = require("../common/FDKError");
|
|
2
|
+
|
|
3
|
+
class PartnerClient {
|
|
4
|
+
constructor(config) {
|
|
5
|
+
this.config = config;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
setExtraHeaders(header) {
|
|
9
|
+
if (typeof header === "object") {
|
|
10
|
+
this.config.extraHeaders.push(header);
|
|
11
|
+
} else {
|
|
12
|
+
throw new FDKClientValidationError("Context value should be an object");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = PartnerClient;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export = PartnerConfig;
|
|
2
|
+
declare class PartnerConfig {
|
|
3
|
+
/**
|
|
4
|
+
* @param {Object} config
|
|
5
|
+
* @param {string} config.companyId
|
|
6
|
+
* @param {string} config.domain
|
|
7
|
+
* @param {string} config.apiKey
|
|
8
|
+
* @param {string} config.apiSecret
|
|
9
|
+
* @param {boolean} config.useAutoRenewTimer
|
|
10
|
+
*/
|
|
11
|
+
constructor(config: {
|
|
12
|
+
companyId: string;
|
|
13
|
+
domain: string;
|
|
14
|
+
apiKey: string;
|
|
15
|
+
apiSecret: string;
|
|
16
|
+
useAutoRenewTimer: boolean;
|
|
17
|
+
});
|
|
18
|
+
organizationId: any;
|
|
19
|
+
domain: string;
|
|
20
|
+
apiKey: string;
|
|
21
|
+
apiSecret: string;
|
|
22
|
+
scope: any;
|
|
23
|
+
useAutoRenewTimer: boolean;
|
|
24
|
+
oauthClient: OauthClient;
|
|
25
|
+
logLevel: any;
|
|
26
|
+
extraHeaders: any[];
|
|
27
|
+
setLogLevel(level: any): void;
|
|
28
|
+
getAccessToken(): Promise<any>;
|
|
29
|
+
}
|
|
30
|
+
import OauthClient = require("./OAuthClient");
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const OauthClient = require("./OAuthClient");
|
|
2
|
+
const { setLoggerLevel } = require("../common/Logger");
|
|
3
|
+
|
|
4
|
+
class PartnerConfig {
|
|
5
|
+
/**
|
|
6
|
+
* @param {Object} config
|
|
7
|
+
* @param {string} config.companyId
|
|
8
|
+
* @param {string} config.domain
|
|
9
|
+
* @param {string} config.apiKey
|
|
10
|
+
* @param {string} config.apiSecret
|
|
11
|
+
* @param {boolean} config.useAutoRenewTimer
|
|
12
|
+
*/
|
|
13
|
+
constructor(config) {
|
|
14
|
+
this.organizationId = config.organizationId;
|
|
15
|
+
this.domain = config.domain || "https://api.fynd.com";
|
|
16
|
+
this.apiKey = config.apiKey;
|
|
17
|
+
this.apiSecret = config.apiSecret;
|
|
18
|
+
(this.scope = config.scope),
|
|
19
|
+
(this.useAutoRenewTimer =
|
|
20
|
+
config.useAutoRenewTimer !== undefined
|
|
21
|
+
? config.useAutoRenewTimer
|
|
22
|
+
: true);
|
|
23
|
+
this.oauthClient = new OauthClient(this);
|
|
24
|
+
this.logLevel = config.logLevel || "ERROR";
|
|
25
|
+
this.setLogLevel(this.logLevel);
|
|
26
|
+
this.extraHeaders = [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
setLogLevel(level) {
|
|
30
|
+
setLoggerLevel(level);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async getAccessToken() {
|
|
34
|
+
let token = await this.oauthClient.getAccessToken();
|
|
35
|
+
return token.access_token;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = PartnerConfig;
|
|
@@ -27,6 +27,16 @@ declare class Cart {
|
|
|
27
27
|
b?: boolean;
|
|
28
28
|
body: AddCartRequest;
|
|
29
29
|
}): Promise<AddCartDetailResponse>;
|
|
30
|
+
/**
|
|
31
|
+
* @param {Object} arg - Arg object.
|
|
32
|
+
* @param {PriceAdjustmentAdd} arg.body
|
|
33
|
+
* @returns {Promise<PriceAdjustmentResponse>} - Success response
|
|
34
|
+
* @summary: Create new price adjustment
|
|
35
|
+
* @description: Create new price adjustment
|
|
36
|
+
*/
|
|
37
|
+
addPriceAdjustment({ body }?: {
|
|
38
|
+
body: PriceAdjustmentAdd;
|
|
39
|
+
}): Promise<PriceAdjustmentResponse>;
|
|
30
40
|
/**
|
|
31
41
|
* @param {Object} arg - Arg object.
|
|
32
42
|
* @param {boolean} [arg.i] -
|
|
@@ -611,6 +621,16 @@ declare class Cart {
|
|
|
611
621
|
uid?: string;
|
|
612
622
|
buyNow?: boolean;
|
|
613
623
|
}): Promise<CartDetailResponse>;
|
|
624
|
+
/**
|
|
625
|
+
* @param {Object} arg - Arg object.
|
|
626
|
+
* @param {string} arg.id -
|
|
627
|
+
* @returns {Promise<SuccessMessage>} - Success response
|
|
628
|
+
* @summary: Remove price adjustment
|
|
629
|
+
* @description: Remove price adjustment
|
|
630
|
+
*/
|
|
631
|
+
removePriceAdjustment({ id }?: {
|
|
632
|
+
id: string;
|
|
633
|
+
}): Promise<SuccessMessage>;
|
|
614
634
|
/**
|
|
615
635
|
* @param {Object} arg - Arg object.
|
|
616
636
|
* @param {string} [arg.cartId] -
|
|
@@ -768,6 +788,18 @@ declare class Cart {
|
|
|
768
788
|
id: string;
|
|
769
789
|
body: CouponPartialUpdate;
|
|
770
790
|
}): Promise<SuccessMessage>;
|
|
791
|
+
/**
|
|
792
|
+
* @param {Object} arg - Arg object.
|
|
793
|
+
* @param {string} arg.id -
|
|
794
|
+
* @param {PriceAdjustmentUpdate} arg.body
|
|
795
|
+
* @returns {Promise<PriceAdjustmentResponse>} - Success response
|
|
796
|
+
* @summary: Update price adjustment configuration
|
|
797
|
+
* @description: Update price adjustment configuration
|
|
798
|
+
*/
|
|
799
|
+
updatePriceAdjustment({ id, body }?: {
|
|
800
|
+
id: string;
|
|
801
|
+
body: PriceAdjustmentUpdate;
|
|
802
|
+
}): Promise<PriceAdjustmentResponse>;
|
|
771
803
|
/**
|
|
772
804
|
* @param {Object} arg - Arg object.
|
|
773
805
|
* @param {string} arg.id -
|
|
@@ -141,6 +141,67 @@ class Cart {
|
|
|
141
141
|
return response;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
/**
|
|
145
|
+
* @param {Object} arg - Arg object.
|
|
146
|
+
* @param {PriceAdjustmentAdd} arg.body
|
|
147
|
+
* @returns {Promise<PriceAdjustmentResponse>} - Success response
|
|
148
|
+
* @summary: Create new price adjustment
|
|
149
|
+
* @description: Create new price adjustment
|
|
150
|
+
*/
|
|
151
|
+
async addPriceAdjustment({ body } = {}) {
|
|
152
|
+
const { error } = CartValidator.addPriceAdjustment().validate(
|
|
153
|
+
{
|
|
154
|
+
body,
|
|
155
|
+
},
|
|
156
|
+
{ abortEarly: false, allowUnknown: true }
|
|
157
|
+
);
|
|
158
|
+
if (error) {
|
|
159
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Showing warrnings if extra unknown parameters are found
|
|
163
|
+
const { error: warrning } = CartValidator.addPriceAdjustment().validate(
|
|
164
|
+
{
|
|
165
|
+
body,
|
|
166
|
+
},
|
|
167
|
+
{ abortEarly: false, allowUnknown: false }
|
|
168
|
+
);
|
|
169
|
+
if (warrning) {
|
|
170
|
+
Logger({
|
|
171
|
+
level: "WARN",
|
|
172
|
+
message: "Parameter Validation warrnings for addPriceAdjustment",
|
|
173
|
+
});
|
|
174
|
+
Logger({ level: "WARN", message: warrning });
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const query_params = {};
|
|
178
|
+
|
|
179
|
+
const response = await PlatformAPIClient.execute(
|
|
180
|
+
this.config,
|
|
181
|
+
"post",
|
|
182
|
+
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/price-adjustment`,
|
|
183
|
+
query_params,
|
|
184
|
+
body
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
const {
|
|
188
|
+
error: res_error,
|
|
189
|
+
} = CartModel.PriceAdjustmentResponse().validate(response, {
|
|
190
|
+
abortEarly: false,
|
|
191
|
+
allowUnknown: false,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
if (res_error) {
|
|
195
|
+
Logger({
|
|
196
|
+
level: "WARN",
|
|
197
|
+
message: "Response Validation Warnnings for addPriceAdjustment",
|
|
198
|
+
});
|
|
199
|
+
Logger({ level: "WARN", message: res_error });
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return response;
|
|
203
|
+
}
|
|
204
|
+
|
|
144
205
|
/**
|
|
145
206
|
* @param {Object} arg - Arg object.
|
|
146
207
|
* @param {boolean} [arg.i] -
|
|
@@ -2888,6 +2949,65 @@ class Cart {
|
|
|
2888
2949
|
return response;
|
|
2889
2950
|
}
|
|
2890
2951
|
|
|
2952
|
+
/**
|
|
2953
|
+
* @param {Object} arg - Arg object.
|
|
2954
|
+
* @param {string} arg.id -
|
|
2955
|
+
* @returns {Promise<SuccessMessage>} - Success response
|
|
2956
|
+
* @summary: Remove price adjustment
|
|
2957
|
+
* @description: Remove price adjustment
|
|
2958
|
+
*/
|
|
2959
|
+
async removePriceAdjustment({ id } = {}) {
|
|
2960
|
+
const { error } = CartValidator.removePriceAdjustment().validate(
|
|
2961
|
+
{
|
|
2962
|
+
id,
|
|
2963
|
+
},
|
|
2964
|
+
{ abortEarly: false, allowUnknown: true }
|
|
2965
|
+
);
|
|
2966
|
+
if (error) {
|
|
2967
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
2968
|
+
}
|
|
2969
|
+
|
|
2970
|
+
// Showing warrnings if extra unknown parameters are found
|
|
2971
|
+
const { error: warrning } = CartValidator.removePriceAdjustment().validate(
|
|
2972
|
+
{
|
|
2973
|
+
id,
|
|
2974
|
+
},
|
|
2975
|
+
{ abortEarly: false, allowUnknown: false }
|
|
2976
|
+
);
|
|
2977
|
+
if (warrning) {
|
|
2978
|
+
Logger({
|
|
2979
|
+
level: "WARN",
|
|
2980
|
+
message: "Parameter Validation warrnings for removePriceAdjustment",
|
|
2981
|
+
});
|
|
2982
|
+
Logger({ level: "WARN", message: warrning });
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
const query_params = {};
|
|
2986
|
+
|
|
2987
|
+
const response = await PlatformAPIClient.execute(
|
|
2988
|
+
this.config,
|
|
2989
|
+
"delete",
|
|
2990
|
+
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/price-adjustment/${id}`,
|
|
2991
|
+
query_params,
|
|
2992
|
+
undefined
|
|
2993
|
+
);
|
|
2994
|
+
|
|
2995
|
+
const { error: res_error } = CartModel.SuccessMessage().validate(response, {
|
|
2996
|
+
abortEarly: false,
|
|
2997
|
+
allowUnknown: false,
|
|
2998
|
+
});
|
|
2999
|
+
|
|
3000
|
+
if (res_error) {
|
|
3001
|
+
Logger({
|
|
3002
|
+
level: "WARN",
|
|
3003
|
+
message: "Response Validation Warnnings for removePriceAdjustment",
|
|
3004
|
+
});
|
|
3005
|
+
Logger({ level: "WARN", message: res_error });
|
|
3006
|
+
}
|
|
3007
|
+
|
|
3008
|
+
return response;
|
|
3009
|
+
}
|
|
3010
|
+
|
|
2891
3011
|
/**
|
|
2892
3012
|
* @param {Object} arg - Arg object.
|
|
2893
3013
|
* @param {string} [arg.cartId] -
|
|
@@ -3638,6 +3758,70 @@ class Cart {
|
|
|
3638
3758
|
return response;
|
|
3639
3759
|
}
|
|
3640
3760
|
|
|
3761
|
+
/**
|
|
3762
|
+
* @param {Object} arg - Arg object.
|
|
3763
|
+
* @param {string} arg.id -
|
|
3764
|
+
* @param {PriceAdjustmentUpdate} arg.body
|
|
3765
|
+
* @returns {Promise<PriceAdjustmentResponse>} - Success response
|
|
3766
|
+
* @summary: Update price adjustment configuration
|
|
3767
|
+
* @description: Update price adjustment configuration
|
|
3768
|
+
*/
|
|
3769
|
+
async updatePriceAdjustment({ id, body } = {}) {
|
|
3770
|
+
const { error } = CartValidator.updatePriceAdjustment().validate(
|
|
3771
|
+
{
|
|
3772
|
+
id,
|
|
3773
|
+
body,
|
|
3774
|
+
},
|
|
3775
|
+
{ abortEarly: false, allowUnknown: true }
|
|
3776
|
+
);
|
|
3777
|
+
if (error) {
|
|
3778
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
3779
|
+
}
|
|
3780
|
+
|
|
3781
|
+
// Showing warrnings if extra unknown parameters are found
|
|
3782
|
+
const { error: warrning } = CartValidator.updatePriceAdjustment().validate(
|
|
3783
|
+
{
|
|
3784
|
+
id,
|
|
3785
|
+
body,
|
|
3786
|
+
},
|
|
3787
|
+
{ abortEarly: false, allowUnknown: false }
|
|
3788
|
+
);
|
|
3789
|
+
if (warrning) {
|
|
3790
|
+
Logger({
|
|
3791
|
+
level: "WARN",
|
|
3792
|
+
message: "Parameter Validation warrnings for updatePriceAdjustment",
|
|
3793
|
+
});
|
|
3794
|
+
Logger({ level: "WARN", message: warrning });
|
|
3795
|
+
}
|
|
3796
|
+
|
|
3797
|
+
const query_params = {};
|
|
3798
|
+
|
|
3799
|
+
const response = await PlatformAPIClient.execute(
|
|
3800
|
+
this.config,
|
|
3801
|
+
"put",
|
|
3802
|
+
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/price-adjustment/${id}`,
|
|
3803
|
+
query_params,
|
|
3804
|
+
body
|
|
3805
|
+
);
|
|
3806
|
+
|
|
3807
|
+
const {
|
|
3808
|
+
error: res_error,
|
|
3809
|
+
} = CartModel.PriceAdjustmentResponse().validate(response, {
|
|
3810
|
+
abortEarly: false,
|
|
3811
|
+
allowUnknown: false,
|
|
3812
|
+
});
|
|
3813
|
+
|
|
3814
|
+
if (res_error) {
|
|
3815
|
+
Logger({
|
|
3816
|
+
level: "WARN",
|
|
3817
|
+
message: "Response Validation Warnnings for updatePriceAdjustment",
|
|
3818
|
+
});
|
|
3819
|
+
Logger({ level: "WARN", message: res_error });
|
|
3820
|
+
}
|
|
3821
|
+
|
|
3822
|
+
return response;
|
|
3823
|
+
}
|
|
3824
|
+
|
|
3641
3825
|
/**
|
|
3642
3826
|
* @param {Object} arg - Arg object.
|
|
3643
3827
|
* @param {string} arg.id -
|