@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
|
@@ -0,0 +1,1296 @@
|
|
|
1
|
+
const PlatformAPIClient = require("../PlatformAPIClient");
|
|
2
|
+
const { FDKClientValidationError } = require("../../common/FDKError");
|
|
3
|
+
const Paginator = require("../../common/Paginator");
|
|
4
|
+
const ServiceabilityValidator = require("./ServiceabilityPlatformValidator");
|
|
5
|
+
const ServiceabilityModel = require("./ServiceabilityPlatformModel");
|
|
6
|
+
const { Logger } = require("./../../common/Logger");
|
|
7
|
+
const Joi = require("joi");
|
|
8
|
+
|
|
9
|
+
class Serviceability {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {Object} arg - Arg object.
|
|
16
|
+
* @param {ZoneRequest} arg.body
|
|
17
|
+
* @returns {Promise<ZoneResponse>} - Success response
|
|
18
|
+
* @summary: Creation of a new zone
|
|
19
|
+
* @description: This API allows you to create a new zone with the specified information. A zone enables serviceability based on given pincodes or regions. By creating a zone and including specific pincodes or regions, you can ensure that the stores associated with the zone are serviceable for those added pincodes or regions. This functionality is particularly useful when you need to ensure serviceability for multiple pincodes or regions by grouping them into a single zone.
|
|
20
|
+
*/
|
|
21
|
+
async createZone({ body } = {}) {
|
|
22
|
+
const { error } = ServiceabilityValidator.createZone().validate(
|
|
23
|
+
{
|
|
24
|
+
body,
|
|
25
|
+
},
|
|
26
|
+
{ abortEarly: false, allowUnknown: true }
|
|
27
|
+
);
|
|
28
|
+
if (error) {
|
|
29
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Showing warrnings if extra unknown parameters are found
|
|
33
|
+
const { error: warrning } = ServiceabilityValidator.createZone().validate(
|
|
34
|
+
{
|
|
35
|
+
body,
|
|
36
|
+
},
|
|
37
|
+
{ abortEarly: false, allowUnknown: false }
|
|
38
|
+
);
|
|
39
|
+
if (warrning) {
|
|
40
|
+
Logger({
|
|
41
|
+
level: "WARN",
|
|
42
|
+
message: "Parameter Validation warrnings for createZone",
|
|
43
|
+
});
|
|
44
|
+
Logger({ level: "WARN", message: warrning });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const query_params = {};
|
|
48
|
+
|
|
49
|
+
const xHeaders = {};
|
|
50
|
+
|
|
51
|
+
const response = await PlatformAPIClient.execute(
|
|
52
|
+
this.config,
|
|
53
|
+
"post",
|
|
54
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/zone`,
|
|
55
|
+
query_params,
|
|
56
|
+
body,
|
|
57
|
+
xHeaders
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const {
|
|
61
|
+
error: res_error,
|
|
62
|
+
} = ServiceabilityModel.ZoneResponse().validate(response, {
|
|
63
|
+
abortEarly: false,
|
|
64
|
+
allowUnknown: false,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (res_error) {
|
|
68
|
+
Logger({
|
|
69
|
+
level: "WARN",
|
|
70
|
+
message: "Response Validation Warnnings for createZone",
|
|
71
|
+
});
|
|
72
|
+
Logger({ level: "WARN", message: res_error });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return response;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param {Object} arg - Arg object.
|
|
80
|
+
* @returns {Promise<GetStoresViewResponse>} - Success response
|
|
81
|
+
* @summary: GET stores data
|
|
82
|
+
* @description: This API returns stores data.
|
|
83
|
+
*/
|
|
84
|
+
async getAllStores({} = {}) {
|
|
85
|
+
const { error } = ServiceabilityValidator.getAllStores().validate(
|
|
86
|
+
{},
|
|
87
|
+
{ abortEarly: false, allowUnknown: true }
|
|
88
|
+
);
|
|
89
|
+
if (error) {
|
|
90
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Showing warrnings if extra unknown parameters are found
|
|
94
|
+
const { error: warrning } = ServiceabilityValidator.getAllStores().validate(
|
|
95
|
+
{},
|
|
96
|
+
{ abortEarly: false, allowUnknown: false }
|
|
97
|
+
);
|
|
98
|
+
if (warrning) {
|
|
99
|
+
Logger({
|
|
100
|
+
level: "WARN",
|
|
101
|
+
message: "Parameter Validation warrnings for getAllStores",
|
|
102
|
+
});
|
|
103
|
+
Logger({ level: "WARN", message: warrning });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const query_params = {};
|
|
107
|
+
|
|
108
|
+
const xHeaders = {};
|
|
109
|
+
|
|
110
|
+
const response = await PlatformAPIClient.execute(
|
|
111
|
+
this.config,
|
|
112
|
+
"get",
|
|
113
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/logistics/stores`,
|
|
114
|
+
query_params,
|
|
115
|
+
undefined,
|
|
116
|
+
xHeaders
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const {
|
|
120
|
+
error: res_error,
|
|
121
|
+
} = ServiceabilityModel.GetStoresViewResponse().validate(response, {
|
|
122
|
+
abortEarly: false,
|
|
123
|
+
allowUnknown: false,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
if (res_error) {
|
|
127
|
+
Logger({
|
|
128
|
+
level: "WARN",
|
|
129
|
+
message: "Response Validation Warnnings for getAllStores",
|
|
130
|
+
});
|
|
131
|
+
Logger({ level: "WARN", message: res_error });
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return response;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @param {Object} arg - Arg object.
|
|
139
|
+
* @param {number} [arg.pageNumber] - Index of the item to start returning with
|
|
140
|
+
* @param {number} [arg.pageSize] - Determines the items to be displayed in a page
|
|
141
|
+
* @returns {Promise<CompanyStoreView_Response>} - Success response
|
|
142
|
+
* @summary: Company Store View of application.
|
|
143
|
+
* @description: This API returns Company Store View of the application.
|
|
144
|
+
*/
|
|
145
|
+
async getCompanyStoreView({ pageNumber, pageSize } = {}) {
|
|
146
|
+
const { error } = ServiceabilityValidator.getCompanyStoreView().validate(
|
|
147
|
+
{
|
|
148
|
+
pageNumber,
|
|
149
|
+
pageSize,
|
|
150
|
+
},
|
|
151
|
+
{ abortEarly: false, allowUnknown: true }
|
|
152
|
+
);
|
|
153
|
+
if (error) {
|
|
154
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Showing warrnings if extra unknown parameters are found
|
|
158
|
+
const {
|
|
159
|
+
error: warrning,
|
|
160
|
+
} = ServiceabilityValidator.getCompanyStoreView().validate(
|
|
161
|
+
{
|
|
162
|
+
pageNumber,
|
|
163
|
+
pageSize,
|
|
164
|
+
},
|
|
165
|
+
{ abortEarly: false, allowUnknown: false }
|
|
166
|
+
);
|
|
167
|
+
if (warrning) {
|
|
168
|
+
Logger({
|
|
169
|
+
level: "WARN",
|
|
170
|
+
message: "Parameter Validation warrnings for getCompanyStoreView",
|
|
171
|
+
});
|
|
172
|
+
Logger({ level: "WARN", message: warrning });
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const query_params = {};
|
|
176
|
+
query_params["page_number"] = pageNumber;
|
|
177
|
+
query_params["page_size"] = pageSize;
|
|
178
|
+
|
|
179
|
+
const xHeaders = {};
|
|
180
|
+
|
|
181
|
+
const response = await PlatformAPIClient.execute(
|
|
182
|
+
this.config,
|
|
183
|
+
"get",
|
|
184
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/all-stores`,
|
|
185
|
+
query_params,
|
|
186
|
+
undefined,
|
|
187
|
+
xHeaders
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
const {
|
|
191
|
+
error: res_error,
|
|
192
|
+
} = ServiceabilityModel.CompanyStoreView_Response().validate(response, {
|
|
193
|
+
abortEarly: false,
|
|
194
|
+
allowUnknown: false,
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
if (res_error) {
|
|
198
|
+
Logger({
|
|
199
|
+
level: "WARN",
|
|
200
|
+
message: "Response Validation Warnnings for getCompanyStoreView",
|
|
201
|
+
});
|
|
202
|
+
Logger({ level: "WARN", message: res_error });
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return response;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @param {Object} arg - Arg object.
|
|
210
|
+
* @param {number} [arg.pageNumber] - Index of the item to start returning with
|
|
211
|
+
* @param {number} [arg.pageSize] - Determines the items to be displayed in a page
|
|
212
|
+
* @param {string} [arg.stage] - Stage of the account. enabled/disabled
|
|
213
|
+
* @param {string} [arg.paymentMode] - Filters dp accounts based on payment mode
|
|
214
|
+
* @param {string} [arg.transportType] - Filters dp accounts based on transport_type
|
|
215
|
+
* @returns {Promise<CompanyDpAccountListResponse>} - Success response
|
|
216
|
+
* @summary: Getting DpAccount of a company from database.
|
|
217
|
+
* @description: This API returns response DpAccount of a company from mongo database.
|
|
218
|
+
*/
|
|
219
|
+
async getDpAccount({
|
|
220
|
+
pageNumber,
|
|
221
|
+
pageSize,
|
|
222
|
+
stage,
|
|
223
|
+
paymentMode,
|
|
224
|
+
transportType,
|
|
225
|
+
} = {}) {
|
|
226
|
+
const { error } = ServiceabilityValidator.getDpAccount().validate(
|
|
227
|
+
{
|
|
228
|
+
pageNumber,
|
|
229
|
+
pageSize,
|
|
230
|
+
stage,
|
|
231
|
+
paymentMode,
|
|
232
|
+
transportType,
|
|
233
|
+
},
|
|
234
|
+
{ abortEarly: false, allowUnknown: true }
|
|
235
|
+
);
|
|
236
|
+
if (error) {
|
|
237
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Showing warrnings if extra unknown parameters are found
|
|
241
|
+
const { error: warrning } = ServiceabilityValidator.getDpAccount().validate(
|
|
242
|
+
{
|
|
243
|
+
pageNumber,
|
|
244
|
+
pageSize,
|
|
245
|
+
stage,
|
|
246
|
+
paymentMode,
|
|
247
|
+
transportType,
|
|
248
|
+
},
|
|
249
|
+
{ abortEarly: false, allowUnknown: false }
|
|
250
|
+
);
|
|
251
|
+
if (warrning) {
|
|
252
|
+
Logger({
|
|
253
|
+
level: "WARN",
|
|
254
|
+
message: "Parameter Validation warrnings for getDpAccount",
|
|
255
|
+
});
|
|
256
|
+
Logger({ level: "WARN", message: warrning });
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const query_params = {};
|
|
260
|
+
query_params["page_number"] = pageNumber;
|
|
261
|
+
query_params["page_size"] = pageSize;
|
|
262
|
+
query_params["stage"] = stage;
|
|
263
|
+
query_params["payment_mode"] = paymentMode;
|
|
264
|
+
query_params["transport_type"] = transportType;
|
|
265
|
+
|
|
266
|
+
const xHeaders = {};
|
|
267
|
+
|
|
268
|
+
const response = await PlatformAPIClient.execute(
|
|
269
|
+
this.config,
|
|
270
|
+
"get",
|
|
271
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/courier/account`,
|
|
272
|
+
query_params,
|
|
273
|
+
undefined,
|
|
274
|
+
xHeaders
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
const {
|
|
278
|
+
error: res_error,
|
|
279
|
+
} = ServiceabilityModel.CompanyDpAccountListResponse().validate(response, {
|
|
280
|
+
abortEarly: false,
|
|
281
|
+
allowUnknown: false,
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
if (res_error) {
|
|
285
|
+
Logger({
|
|
286
|
+
level: "WARN",
|
|
287
|
+
message: "Response Validation Warnnings for getDpAccount",
|
|
288
|
+
});
|
|
289
|
+
Logger({ level: "WARN", message: res_error });
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return response;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* @param {Object} arg - Arg object.
|
|
297
|
+
* @returns {Promise<DPCompanyRuleResponse>} - Success response
|
|
298
|
+
* @summary: Get All DpCompanyRules applied to company from database.
|
|
299
|
+
* @description: This API returns response of all DpCompanyRules from mongo database.
|
|
300
|
+
*/
|
|
301
|
+
async getDpCompanyRules({} = {}) {
|
|
302
|
+
const { error } = ServiceabilityValidator.getDpCompanyRules().validate(
|
|
303
|
+
{},
|
|
304
|
+
{ abortEarly: false, allowUnknown: true }
|
|
305
|
+
);
|
|
306
|
+
if (error) {
|
|
307
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Showing warrnings if extra unknown parameters are found
|
|
311
|
+
const {
|
|
312
|
+
error: warrning,
|
|
313
|
+
} = ServiceabilityValidator.getDpCompanyRules().validate(
|
|
314
|
+
{},
|
|
315
|
+
{ abortEarly: false, allowUnknown: false }
|
|
316
|
+
);
|
|
317
|
+
if (warrning) {
|
|
318
|
+
Logger({
|
|
319
|
+
level: "WARN",
|
|
320
|
+
message: "Parameter Validation warrnings for getDpCompanyRules",
|
|
321
|
+
});
|
|
322
|
+
Logger({ level: "WARN", message: warrning });
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const query_params = {};
|
|
326
|
+
|
|
327
|
+
const xHeaders = {};
|
|
328
|
+
|
|
329
|
+
const response = await PlatformAPIClient.execute(
|
|
330
|
+
this.config,
|
|
331
|
+
"get",
|
|
332
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/courier/priority`,
|
|
333
|
+
query_params,
|
|
334
|
+
undefined,
|
|
335
|
+
xHeaders
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
const {
|
|
339
|
+
error: res_error,
|
|
340
|
+
} = ServiceabilityModel.DPCompanyRuleResponse().validate(response, {
|
|
341
|
+
abortEarly: false,
|
|
342
|
+
allowUnknown: false,
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
if (res_error) {
|
|
346
|
+
Logger({
|
|
347
|
+
level: "WARN",
|
|
348
|
+
message: "Response Validation Warnnings for getDpCompanyRules",
|
|
349
|
+
});
|
|
350
|
+
Logger({ level: "WARN", message: res_error });
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return response;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* @param {Object} arg - Arg object.
|
|
358
|
+
* @param {number} [arg.pageNumber] - Index of the item to start returning with
|
|
359
|
+
* @param {number} [arg.pageSize] - Determines the items to be displayed in a page
|
|
360
|
+
* @returns {Promise<DpMultipleRuleSuccessResponse>} - Success response
|
|
361
|
+
* @summary: Fetching of DpRules from database.
|
|
362
|
+
* @description: This API returns response of DpRules from mongo database.
|
|
363
|
+
*/
|
|
364
|
+
async getDpRuleInsert({ pageNumber, pageSize } = {}) {
|
|
365
|
+
const { error } = ServiceabilityValidator.getDpRuleInsert().validate(
|
|
366
|
+
{
|
|
367
|
+
pageNumber,
|
|
368
|
+
pageSize,
|
|
369
|
+
},
|
|
370
|
+
{ abortEarly: false, allowUnknown: true }
|
|
371
|
+
);
|
|
372
|
+
if (error) {
|
|
373
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// Showing warrnings if extra unknown parameters are found
|
|
377
|
+
const {
|
|
378
|
+
error: warrning,
|
|
379
|
+
} = ServiceabilityValidator.getDpRuleInsert().validate(
|
|
380
|
+
{
|
|
381
|
+
pageNumber,
|
|
382
|
+
pageSize,
|
|
383
|
+
},
|
|
384
|
+
{ abortEarly: false, allowUnknown: false }
|
|
385
|
+
);
|
|
386
|
+
if (warrning) {
|
|
387
|
+
Logger({
|
|
388
|
+
level: "WARN",
|
|
389
|
+
message: "Parameter Validation warrnings for getDpRuleInsert",
|
|
390
|
+
});
|
|
391
|
+
Logger({ level: "WARN", message: warrning });
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
const query_params = {};
|
|
395
|
+
query_params["page_number"] = pageNumber;
|
|
396
|
+
query_params["page_size"] = pageSize;
|
|
397
|
+
|
|
398
|
+
const xHeaders = {};
|
|
399
|
+
|
|
400
|
+
const response = await PlatformAPIClient.execute(
|
|
401
|
+
this.config,
|
|
402
|
+
"get",
|
|
403
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/courier/rules`,
|
|
404
|
+
query_params,
|
|
405
|
+
undefined,
|
|
406
|
+
xHeaders
|
|
407
|
+
);
|
|
408
|
+
|
|
409
|
+
const {
|
|
410
|
+
error: res_error,
|
|
411
|
+
} = ServiceabilityModel.DpMultipleRuleSuccessResponse().validate(response, {
|
|
412
|
+
abortEarly: false,
|
|
413
|
+
allowUnknown: false,
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
if (res_error) {
|
|
417
|
+
Logger({
|
|
418
|
+
level: "WARN",
|
|
419
|
+
message: "Response Validation Warnnings for getDpRuleInsert",
|
|
420
|
+
});
|
|
421
|
+
Logger({ level: "WARN", message: res_error });
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
return response;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* @param {Object} arg - Arg object.
|
|
429
|
+
* @param {string} arg.ruleUid - A `rule_uid` is a unique identifier for a
|
|
430
|
+
* particular Dp.
|
|
431
|
+
* @returns {Promise<DpRuleSuccessResponse>} - Success response
|
|
432
|
+
* @summary: Fetching of DpRules from database.
|
|
433
|
+
* @description: This API returns response of DpRules from mongo database.
|
|
434
|
+
*/
|
|
435
|
+
async getDpRules({ ruleUid } = {}) {
|
|
436
|
+
const { error } = ServiceabilityValidator.getDpRules().validate(
|
|
437
|
+
{
|
|
438
|
+
ruleUid,
|
|
439
|
+
},
|
|
440
|
+
{ abortEarly: false, allowUnknown: true }
|
|
441
|
+
);
|
|
442
|
+
if (error) {
|
|
443
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// Showing warrnings if extra unknown parameters are found
|
|
447
|
+
const { error: warrning } = ServiceabilityValidator.getDpRules().validate(
|
|
448
|
+
{
|
|
449
|
+
ruleUid,
|
|
450
|
+
},
|
|
451
|
+
{ abortEarly: false, allowUnknown: false }
|
|
452
|
+
);
|
|
453
|
+
if (warrning) {
|
|
454
|
+
Logger({
|
|
455
|
+
level: "WARN",
|
|
456
|
+
message: "Parameter Validation warrnings for getDpRules",
|
|
457
|
+
});
|
|
458
|
+
Logger({ level: "WARN", message: warrning });
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const query_params = {};
|
|
462
|
+
|
|
463
|
+
const xHeaders = {};
|
|
464
|
+
|
|
465
|
+
const response = await PlatformAPIClient.execute(
|
|
466
|
+
this.config,
|
|
467
|
+
"get",
|
|
468
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/courier/rules/${ruleUid}`,
|
|
469
|
+
query_params,
|
|
470
|
+
undefined,
|
|
471
|
+
xHeaders
|
|
472
|
+
);
|
|
473
|
+
|
|
474
|
+
const {
|
|
475
|
+
error: res_error,
|
|
476
|
+
} = ServiceabilityModel.DpRuleSuccessResponse().validate(response, {
|
|
477
|
+
abortEarly: false,
|
|
478
|
+
allowUnknown: false,
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
if (res_error) {
|
|
482
|
+
Logger({
|
|
483
|
+
level: "WARN",
|
|
484
|
+
message: "Response Validation Warnnings for getDpRules",
|
|
485
|
+
});
|
|
486
|
+
Logger({ level: "WARN", message: res_error });
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
return response;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* @param {Object} arg - Arg object.
|
|
494
|
+
* @param {EntityRegionView_Request} arg.body
|
|
495
|
+
* @returns {Promise<EntityRegionView_Response>} - Success response
|
|
496
|
+
* @summary: Get country and state list
|
|
497
|
+
* @description: This API returns response for Entity Region View.
|
|
498
|
+
*/
|
|
499
|
+
async getEntityRegionView({ body } = {}) {
|
|
500
|
+
const { error } = ServiceabilityValidator.getEntityRegionView().validate(
|
|
501
|
+
{
|
|
502
|
+
body,
|
|
503
|
+
},
|
|
504
|
+
{ abortEarly: false, allowUnknown: true }
|
|
505
|
+
);
|
|
506
|
+
if (error) {
|
|
507
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// Showing warrnings if extra unknown parameters are found
|
|
511
|
+
const {
|
|
512
|
+
error: warrning,
|
|
513
|
+
} = ServiceabilityValidator.getEntityRegionView().validate(
|
|
514
|
+
{
|
|
515
|
+
body,
|
|
516
|
+
},
|
|
517
|
+
{ abortEarly: false, allowUnknown: false }
|
|
518
|
+
);
|
|
519
|
+
if (warrning) {
|
|
520
|
+
Logger({
|
|
521
|
+
level: "WARN",
|
|
522
|
+
message: "Parameter Validation warrnings for getEntityRegionView",
|
|
523
|
+
});
|
|
524
|
+
Logger({ level: "WARN", message: warrning });
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
const query_params = {};
|
|
528
|
+
|
|
529
|
+
const xHeaders = {};
|
|
530
|
+
|
|
531
|
+
const response = await PlatformAPIClient.execute(
|
|
532
|
+
this.config,
|
|
533
|
+
"post",
|
|
534
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/regions`,
|
|
535
|
+
query_params,
|
|
536
|
+
body,
|
|
537
|
+
xHeaders
|
|
538
|
+
);
|
|
539
|
+
|
|
540
|
+
const {
|
|
541
|
+
error: res_error,
|
|
542
|
+
} = ServiceabilityModel.EntityRegionView_Response().validate(response, {
|
|
543
|
+
abortEarly: false,
|
|
544
|
+
allowUnknown: false,
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
if (res_error) {
|
|
548
|
+
Logger({
|
|
549
|
+
level: "WARN",
|
|
550
|
+
message: "Response Validation Warnnings for getEntityRegionView",
|
|
551
|
+
});
|
|
552
|
+
Logger({ level: "WARN", message: res_error });
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
return response;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* @param {Object} arg - Arg object.
|
|
560
|
+
* @param {number} [arg.pageNumber] - Index of the item to start returning with
|
|
561
|
+
* @param {number} [arg.pageSize] - Determines the items to be displayed in a page
|
|
562
|
+
* @param {string} [arg.name] - Name of particular zone in the seller account
|
|
563
|
+
* @param {boolean} [arg.isActive] - Status of zone whether active or inactive
|
|
564
|
+
* @param {string} [arg.channelIds] - Zones associated with the given channel ids'
|
|
565
|
+
* @param {string} [arg.q] - Search with name as a free text
|
|
566
|
+
* @returns {Promise<ListViewResponse>} - Success response
|
|
567
|
+
* @summary: Zone List of application.
|
|
568
|
+
* @description: This API returns Zone List View of the application.
|
|
569
|
+
*/
|
|
570
|
+
async getListView({
|
|
571
|
+
pageNumber,
|
|
572
|
+
pageSize,
|
|
573
|
+
name,
|
|
574
|
+
isActive,
|
|
575
|
+
channelIds,
|
|
576
|
+
q,
|
|
577
|
+
} = {}) {
|
|
578
|
+
const { error } = ServiceabilityValidator.getListView().validate(
|
|
579
|
+
{
|
|
580
|
+
pageNumber,
|
|
581
|
+
pageSize,
|
|
582
|
+
name,
|
|
583
|
+
isActive,
|
|
584
|
+
channelIds,
|
|
585
|
+
q,
|
|
586
|
+
},
|
|
587
|
+
{ abortEarly: false, allowUnknown: true }
|
|
588
|
+
);
|
|
589
|
+
if (error) {
|
|
590
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// Showing warrnings if extra unknown parameters are found
|
|
594
|
+
const { error: warrning } = ServiceabilityValidator.getListView().validate(
|
|
595
|
+
{
|
|
596
|
+
pageNumber,
|
|
597
|
+
pageSize,
|
|
598
|
+
name,
|
|
599
|
+
isActive,
|
|
600
|
+
channelIds,
|
|
601
|
+
q,
|
|
602
|
+
},
|
|
603
|
+
{ abortEarly: false, allowUnknown: false }
|
|
604
|
+
);
|
|
605
|
+
if (warrning) {
|
|
606
|
+
Logger({
|
|
607
|
+
level: "WARN",
|
|
608
|
+
message: "Parameter Validation warrnings for getListView",
|
|
609
|
+
});
|
|
610
|
+
Logger({ level: "WARN", message: warrning });
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
const query_params = {};
|
|
614
|
+
query_params["page_number"] = pageNumber;
|
|
615
|
+
query_params["page_size"] = pageSize;
|
|
616
|
+
query_params["name"] = name;
|
|
617
|
+
query_params["is_active"] = isActive;
|
|
618
|
+
query_params["channel_ids"] = channelIds;
|
|
619
|
+
query_params["q"] = q;
|
|
620
|
+
|
|
621
|
+
const xHeaders = {};
|
|
622
|
+
|
|
623
|
+
const response = await PlatformAPIClient.execute(
|
|
624
|
+
this.config,
|
|
625
|
+
"get",
|
|
626
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/zones`,
|
|
627
|
+
query_params,
|
|
628
|
+
undefined,
|
|
629
|
+
xHeaders
|
|
630
|
+
);
|
|
631
|
+
|
|
632
|
+
const {
|
|
633
|
+
error: res_error,
|
|
634
|
+
} = ServiceabilityModel.ListViewResponse().validate(response, {
|
|
635
|
+
abortEarly: false,
|
|
636
|
+
allowUnknown: false,
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
if (res_error) {
|
|
640
|
+
Logger({
|
|
641
|
+
level: "WARN",
|
|
642
|
+
message: "Response Validation Warnnings for getListView",
|
|
643
|
+
});
|
|
644
|
+
Logger({ level: "WARN", message: res_error });
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
return response;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* @param {Object} arg - Arg object.
|
|
652
|
+
* @param {ReAssignStoreRequest} arg.body
|
|
653
|
+
* @returns {Promise<ReAssignStoreResponse>} - Success response
|
|
654
|
+
* @summary: Get serviceable store of the item
|
|
655
|
+
* @description: This API returns serviceable store of the item.
|
|
656
|
+
*/
|
|
657
|
+
async getOptimalLocations({ body } = {}) {
|
|
658
|
+
const { error } = ServiceabilityValidator.getOptimalLocations().validate(
|
|
659
|
+
{
|
|
660
|
+
body,
|
|
661
|
+
},
|
|
662
|
+
{ abortEarly: false, allowUnknown: true }
|
|
663
|
+
);
|
|
664
|
+
if (error) {
|
|
665
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// Showing warrnings if extra unknown parameters are found
|
|
669
|
+
const {
|
|
670
|
+
error: warrning,
|
|
671
|
+
} = ServiceabilityValidator.getOptimalLocations().validate(
|
|
672
|
+
{
|
|
673
|
+
body,
|
|
674
|
+
},
|
|
675
|
+
{ abortEarly: false, allowUnknown: false }
|
|
676
|
+
);
|
|
677
|
+
if (warrning) {
|
|
678
|
+
Logger({
|
|
679
|
+
level: "WARN",
|
|
680
|
+
message: "Parameter Validation warrnings for getOptimalLocations",
|
|
681
|
+
});
|
|
682
|
+
Logger({ level: "WARN", message: warrning });
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
const query_params = {};
|
|
686
|
+
|
|
687
|
+
const xHeaders = {};
|
|
688
|
+
|
|
689
|
+
const response = await PlatformAPIClient.execute(
|
|
690
|
+
this.config,
|
|
691
|
+
"post",
|
|
692
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/reassign`,
|
|
693
|
+
query_params,
|
|
694
|
+
body,
|
|
695
|
+
xHeaders
|
|
696
|
+
);
|
|
697
|
+
|
|
698
|
+
const {
|
|
699
|
+
error: res_error,
|
|
700
|
+
} = ServiceabilityModel.ReAssignStoreResponse().validate(response, {
|
|
701
|
+
abortEarly: false,
|
|
702
|
+
allowUnknown: false,
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
if (res_error) {
|
|
706
|
+
Logger({
|
|
707
|
+
level: "WARN",
|
|
708
|
+
message: "Response Validation Warnnings for getOptimalLocations",
|
|
709
|
+
});
|
|
710
|
+
Logger({ level: "WARN", message: res_error });
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
return response;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* @param {Object} arg - Arg object.
|
|
718
|
+
* @param {number} arg.storeUid - A `store_uid` contains a specific ID of a store.
|
|
719
|
+
* @returns {Promise<GetStoresViewResponse>} - Success response
|
|
720
|
+
* @summary: GET stores data
|
|
721
|
+
* @description: This API returns stores data.
|
|
722
|
+
*/
|
|
723
|
+
async getStore({ storeUid } = {}) {
|
|
724
|
+
const { error } = ServiceabilityValidator.getStore().validate(
|
|
725
|
+
{
|
|
726
|
+
storeUid,
|
|
727
|
+
},
|
|
728
|
+
{ abortEarly: false, allowUnknown: true }
|
|
729
|
+
);
|
|
730
|
+
if (error) {
|
|
731
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// Showing warrnings if extra unknown parameters are found
|
|
735
|
+
const { error: warrning } = ServiceabilityValidator.getStore().validate(
|
|
736
|
+
{
|
|
737
|
+
storeUid,
|
|
738
|
+
},
|
|
739
|
+
{ abortEarly: false, allowUnknown: false }
|
|
740
|
+
);
|
|
741
|
+
if (warrning) {
|
|
742
|
+
Logger({
|
|
743
|
+
level: "WARN",
|
|
744
|
+
message: "Parameter Validation warrnings for getStore",
|
|
745
|
+
});
|
|
746
|
+
Logger({ level: "WARN", message: warrning });
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
const query_params = {};
|
|
750
|
+
|
|
751
|
+
const xHeaders = {};
|
|
752
|
+
|
|
753
|
+
const response = await PlatformAPIClient.execute(
|
|
754
|
+
this.config,
|
|
755
|
+
"get",
|
|
756
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/stores/${storeUid}`,
|
|
757
|
+
query_params,
|
|
758
|
+
undefined,
|
|
759
|
+
xHeaders
|
|
760
|
+
);
|
|
761
|
+
|
|
762
|
+
const {
|
|
763
|
+
error: res_error,
|
|
764
|
+
} = ServiceabilityModel.GetStoresViewResponse().validate(response, {
|
|
765
|
+
abortEarly: false,
|
|
766
|
+
allowUnknown: false,
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
if (res_error) {
|
|
770
|
+
Logger({
|
|
771
|
+
level: "WARN",
|
|
772
|
+
message: "Response Validation Warnnings for getStore",
|
|
773
|
+
});
|
|
774
|
+
Logger({ level: "WARN", message: res_error });
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
return response;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* @param {Object} arg - Arg object.
|
|
782
|
+
* @param {string} arg.zoneId - A `zone_id` is a unique identifier for a
|
|
783
|
+
* particular zone.
|
|
784
|
+
* @returns {Promise<GetSingleZoneDataViewResponse>} - Success response
|
|
785
|
+
* @summary: Zone Data View of application.
|
|
786
|
+
* @description: This API returns Zone Data View of the application.
|
|
787
|
+
*/
|
|
788
|
+
async getZoneDataView({ zoneId } = {}) {
|
|
789
|
+
const { error } = ServiceabilityValidator.getZoneDataView().validate(
|
|
790
|
+
{
|
|
791
|
+
zoneId,
|
|
792
|
+
},
|
|
793
|
+
{ abortEarly: false, allowUnknown: true }
|
|
794
|
+
);
|
|
795
|
+
if (error) {
|
|
796
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// Showing warrnings if extra unknown parameters are found
|
|
800
|
+
const {
|
|
801
|
+
error: warrning,
|
|
802
|
+
} = ServiceabilityValidator.getZoneDataView().validate(
|
|
803
|
+
{
|
|
804
|
+
zoneId,
|
|
805
|
+
},
|
|
806
|
+
{ abortEarly: false, allowUnknown: false }
|
|
807
|
+
);
|
|
808
|
+
if (warrning) {
|
|
809
|
+
Logger({
|
|
810
|
+
level: "WARN",
|
|
811
|
+
message: "Parameter Validation warrnings for getZoneDataView",
|
|
812
|
+
});
|
|
813
|
+
Logger({ level: "WARN", message: warrning });
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
const query_params = {};
|
|
817
|
+
|
|
818
|
+
const xHeaders = {};
|
|
819
|
+
|
|
820
|
+
const response = await PlatformAPIClient.execute(
|
|
821
|
+
this.config,
|
|
822
|
+
"get",
|
|
823
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/zone/${zoneId}`,
|
|
824
|
+
query_params,
|
|
825
|
+
undefined,
|
|
826
|
+
xHeaders
|
|
827
|
+
);
|
|
828
|
+
|
|
829
|
+
const {
|
|
830
|
+
error: res_error,
|
|
831
|
+
} = ServiceabilityModel.GetSingleZoneDataViewResponse().validate(response, {
|
|
832
|
+
abortEarly: false,
|
|
833
|
+
allowUnknown: false,
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
if (res_error) {
|
|
837
|
+
Logger({
|
|
838
|
+
level: "WARN",
|
|
839
|
+
message: "Response Validation Warnnings for getZoneDataView",
|
|
840
|
+
});
|
|
841
|
+
Logger({ level: "WARN", message: res_error });
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
return response;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* @param {Object} arg - Arg object.
|
|
849
|
+
* @param {number} [arg.pageNumber] - Index of the item to start returning with
|
|
850
|
+
* @param {number} [arg.pageNo] - Index of the item to start returning with
|
|
851
|
+
* @param {number} [arg.pageSize] - Determines the items to be displayed in a page
|
|
852
|
+
* @param {string} [arg.name] - Name of particular zone in the seller account
|
|
853
|
+
* @param {boolean} [arg.isActive] - Status of zone whether active or inactive
|
|
854
|
+
* @param {string} [arg.channelIds] - Zones associated with the given channel ids'
|
|
855
|
+
* @param {string} [arg.q] - Search with name as a free text
|
|
856
|
+
* @param {string[]} [arg.zoneId] - List of zones to query for
|
|
857
|
+
* @returns {Promise<ListViewResponse>} - Success response
|
|
858
|
+
* @summary: Zone List of application.
|
|
859
|
+
* @description: This API returns Zone List View of the application.
|
|
860
|
+
*/
|
|
861
|
+
async getZoneListView({
|
|
862
|
+
pageNumber,
|
|
863
|
+
pageNo,
|
|
864
|
+
pageSize,
|
|
865
|
+
name,
|
|
866
|
+
isActive,
|
|
867
|
+
channelIds,
|
|
868
|
+
q,
|
|
869
|
+
zoneId,
|
|
870
|
+
} = {}) {
|
|
871
|
+
const { error } = ServiceabilityValidator.getZoneListView().validate(
|
|
872
|
+
{
|
|
873
|
+
pageNumber,
|
|
874
|
+
pageNo,
|
|
875
|
+
pageSize,
|
|
876
|
+
name,
|
|
877
|
+
isActive,
|
|
878
|
+
channelIds,
|
|
879
|
+
q,
|
|
880
|
+
zoneId,
|
|
881
|
+
},
|
|
882
|
+
{ abortEarly: false, allowUnknown: true }
|
|
883
|
+
);
|
|
884
|
+
if (error) {
|
|
885
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// Showing warrnings if extra unknown parameters are found
|
|
889
|
+
const {
|
|
890
|
+
error: warrning,
|
|
891
|
+
} = ServiceabilityValidator.getZoneListView().validate(
|
|
892
|
+
{
|
|
893
|
+
pageNumber,
|
|
894
|
+
pageNo,
|
|
895
|
+
pageSize,
|
|
896
|
+
name,
|
|
897
|
+
isActive,
|
|
898
|
+
channelIds,
|
|
899
|
+
q,
|
|
900
|
+
zoneId,
|
|
901
|
+
},
|
|
902
|
+
{ abortEarly: false, allowUnknown: false }
|
|
903
|
+
);
|
|
904
|
+
if (warrning) {
|
|
905
|
+
Logger({
|
|
906
|
+
level: "WARN",
|
|
907
|
+
message: "Parameter Validation warrnings for getZoneListView",
|
|
908
|
+
});
|
|
909
|
+
Logger({ level: "WARN", message: warrning });
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
const query_params = {};
|
|
913
|
+
query_params["page_number"] = pageNumber;
|
|
914
|
+
query_params["page_no"] = pageNo;
|
|
915
|
+
query_params["page_size"] = pageSize;
|
|
916
|
+
query_params["name"] = name;
|
|
917
|
+
query_params["is_active"] = isActive;
|
|
918
|
+
query_params["channel_ids"] = channelIds;
|
|
919
|
+
query_params["q"] = q;
|
|
920
|
+
query_params["zone_id"] = zoneId;
|
|
921
|
+
|
|
922
|
+
const xHeaders = {};
|
|
923
|
+
|
|
924
|
+
const response = await PlatformAPIClient.execute(
|
|
925
|
+
this.config,
|
|
926
|
+
"get",
|
|
927
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/zones-list`,
|
|
928
|
+
query_params,
|
|
929
|
+
undefined,
|
|
930
|
+
xHeaders
|
|
931
|
+
);
|
|
932
|
+
|
|
933
|
+
const {
|
|
934
|
+
error: res_error,
|
|
935
|
+
} = ServiceabilityModel.ListViewResponse().validate(response, {
|
|
936
|
+
abortEarly: false,
|
|
937
|
+
allowUnknown: false,
|
|
938
|
+
});
|
|
939
|
+
|
|
940
|
+
if (res_error) {
|
|
941
|
+
Logger({
|
|
942
|
+
level: "WARN",
|
|
943
|
+
message: "Response Validation Warnnings for getZoneListView",
|
|
944
|
+
});
|
|
945
|
+
Logger({ level: "WARN", message: res_error });
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
return response;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* @param {Object} arg - Arg object.
|
|
953
|
+
* @param {string} arg.ruleUid - A `rule_uid` is a unique identifier for a
|
|
954
|
+
* particular Dp.
|
|
955
|
+
* @param {DpRulesUpdateRequest} arg.body
|
|
956
|
+
* @returns {Promise<DpRuleUpdateSuccessResponse>} - Success response
|
|
957
|
+
* @summary: Updating of DpRules from database.
|
|
958
|
+
* @description: This API updates and returns response of DpRules from mongo database.
|
|
959
|
+
*/
|
|
960
|
+
async updateDpRule({ ruleUid, body } = {}) {
|
|
961
|
+
const { error } = ServiceabilityValidator.updateDpRule().validate(
|
|
962
|
+
{
|
|
963
|
+
ruleUid,
|
|
964
|
+
body,
|
|
965
|
+
},
|
|
966
|
+
{ abortEarly: false, allowUnknown: true }
|
|
967
|
+
);
|
|
968
|
+
if (error) {
|
|
969
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
// Showing warrnings if extra unknown parameters are found
|
|
973
|
+
const { error: warrning } = ServiceabilityValidator.updateDpRule().validate(
|
|
974
|
+
{
|
|
975
|
+
ruleUid,
|
|
976
|
+
body,
|
|
977
|
+
},
|
|
978
|
+
{ abortEarly: false, allowUnknown: false }
|
|
979
|
+
);
|
|
980
|
+
if (warrning) {
|
|
981
|
+
Logger({
|
|
982
|
+
level: "WARN",
|
|
983
|
+
message: "Parameter Validation warrnings for updateDpRule",
|
|
984
|
+
});
|
|
985
|
+
Logger({ level: "WARN", message: warrning });
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
const query_params = {};
|
|
989
|
+
|
|
990
|
+
const xHeaders = {};
|
|
991
|
+
|
|
992
|
+
const response = await PlatformAPIClient.execute(
|
|
993
|
+
this.config,
|
|
994
|
+
"put",
|
|
995
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/courier/rules/${ruleUid}`,
|
|
996
|
+
query_params,
|
|
997
|
+
body,
|
|
998
|
+
xHeaders
|
|
999
|
+
);
|
|
1000
|
+
|
|
1001
|
+
const {
|
|
1002
|
+
error: res_error,
|
|
1003
|
+
} = ServiceabilityModel.DpRuleUpdateSuccessResponse().validate(response, {
|
|
1004
|
+
abortEarly: false,
|
|
1005
|
+
allowUnknown: false,
|
|
1006
|
+
});
|
|
1007
|
+
|
|
1008
|
+
if (res_error) {
|
|
1009
|
+
Logger({
|
|
1010
|
+
level: "WARN",
|
|
1011
|
+
message: "Response Validation Warnnings for updateDpRule",
|
|
1012
|
+
});
|
|
1013
|
+
Logger({ level: "WARN", message: res_error });
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
return response;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
* @param {Object} arg - Arg object.
|
|
1021
|
+
* @param {string} arg.zoneId - A `zone_id` is a unique identifier for a
|
|
1022
|
+
* particular zone.
|
|
1023
|
+
* @param {ZoneUpdateRequest} arg.body
|
|
1024
|
+
* @returns {Promise<ZoneSuccessResponse>} - Success response
|
|
1025
|
+
* @summary: Updation of zone collections in database.
|
|
1026
|
+
* @description: This API returns response of updation of zone in mongo database.
|
|
1027
|
+
*/
|
|
1028
|
+
async updateZoneControllerView({
|
|
1029
|
+
zoneId,
|
|
1030
|
+
|
|
1031
|
+
body,
|
|
1032
|
+
} = {}) {
|
|
1033
|
+
const {
|
|
1034
|
+
error,
|
|
1035
|
+
} = ServiceabilityValidator.updateZoneControllerView().validate(
|
|
1036
|
+
{
|
|
1037
|
+
zoneId,
|
|
1038
|
+
|
|
1039
|
+
body,
|
|
1040
|
+
},
|
|
1041
|
+
{ abortEarly: false, allowUnknown: true }
|
|
1042
|
+
);
|
|
1043
|
+
if (error) {
|
|
1044
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1048
|
+
const {
|
|
1049
|
+
error: warrning,
|
|
1050
|
+
} = ServiceabilityValidator.updateZoneControllerView().validate(
|
|
1051
|
+
{
|
|
1052
|
+
zoneId,
|
|
1053
|
+
|
|
1054
|
+
body,
|
|
1055
|
+
},
|
|
1056
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1057
|
+
);
|
|
1058
|
+
if (warrning) {
|
|
1059
|
+
Logger({
|
|
1060
|
+
level: "WARN",
|
|
1061
|
+
message: "Parameter Validation warrnings for updateZoneControllerView",
|
|
1062
|
+
});
|
|
1063
|
+
Logger({ level: "WARN", message: warrning });
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
const query_params = {};
|
|
1067
|
+
|
|
1068
|
+
const xHeaders = {};
|
|
1069
|
+
|
|
1070
|
+
const response = await PlatformAPIClient.execute(
|
|
1071
|
+
this.config,
|
|
1072
|
+
"put",
|
|
1073
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/zone/${zoneId}`,
|
|
1074
|
+
query_params,
|
|
1075
|
+
body,
|
|
1076
|
+
xHeaders
|
|
1077
|
+
);
|
|
1078
|
+
|
|
1079
|
+
const {
|
|
1080
|
+
error: res_error,
|
|
1081
|
+
} = ServiceabilityModel.ZoneSuccessResponse().validate(response, {
|
|
1082
|
+
abortEarly: false,
|
|
1083
|
+
allowUnknown: false,
|
|
1084
|
+
});
|
|
1085
|
+
|
|
1086
|
+
if (res_error) {
|
|
1087
|
+
Logger({
|
|
1088
|
+
level: "WARN",
|
|
1089
|
+
message: "Response Validation Warnnings for updateZoneControllerView",
|
|
1090
|
+
});
|
|
1091
|
+
Logger({ level: "WARN", message: res_error });
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
return response;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* @param {Object} arg - Arg object.
|
|
1099
|
+
* @param {CompanyDpAccountRequest} arg.body
|
|
1100
|
+
* @returns {Promise<CompanyDpAccountResponse>} - Success response
|
|
1101
|
+
* @summary: Upsertion of DpAccount in database.
|
|
1102
|
+
* @description: This API returns response of upsertion of DpAccount in mongo database.
|
|
1103
|
+
*/
|
|
1104
|
+
async upsertDpAccount({ body } = {}) {
|
|
1105
|
+
const { error } = ServiceabilityValidator.upsertDpAccount().validate(
|
|
1106
|
+
{
|
|
1107
|
+
body,
|
|
1108
|
+
},
|
|
1109
|
+
{ abortEarly: false, allowUnknown: true }
|
|
1110
|
+
);
|
|
1111
|
+
if (error) {
|
|
1112
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1116
|
+
const {
|
|
1117
|
+
error: warrning,
|
|
1118
|
+
} = ServiceabilityValidator.upsertDpAccount().validate(
|
|
1119
|
+
{
|
|
1120
|
+
body,
|
|
1121
|
+
},
|
|
1122
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1123
|
+
);
|
|
1124
|
+
if (warrning) {
|
|
1125
|
+
Logger({
|
|
1126
|
+
level: "WARN",
|
|
1127
|
+
message: "Parameter Validation warrnings for upsertDpAccount",
|
|
1128
|
+
});
|
|
1129
|
+
Logger({ level: "WARN", message: warrning });
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
const query_params = {};
|
|
1133
|
+
|
|
1134
|
+
const xHeaders = {};
|
|
1135
|
+
|
|
1136
|
+
const response = await PlatformAPIClient.execute(
|
|
1137
|
+
this.config,
|
|
1138
|
+
"post",
|
|
1139
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/courier/account`,
|
|
1140
|
+
query_params,
|
|
1141
|
+
body,
|
|
1142
|
+
xHeaders
|
|
1143
|
+
);
|
|
1144
|
+
|
|
1145
|
+
const {
|
|
1146
|
+
error: res_error,
|
|
1147
|
+
} = ServiceabilityModel.CompanyDpAccountResponse().validate(response, {
|
|
1148
|
+
abortEarly: false,
|
|
1149
|
+
allowUnknown: false,
|
|
1150
|
+
});
|
|
1151
|
+
|
|
1152
|
+
if (res_error) {
|
|
1153
|
+
Logger({
|
|
1154
|
+
level: "WARN",
|
|
1155
|
+
message: "Response Validation Warnnings for upsertDpAccount",
|
|
1156
|
+
});
|
|
1157
|
+
Logger({ level: "WARN", message: res_error });
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
return response;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* @param {Object} arg - Arg object.
|
|
1165
|
+
* @param {DPCompanyRuleRequest} arg.body
|
|
1166
|
+
* @returns {Promise<DPCompanyRuleResponse>} - Success response
|
|
1167
|
+
* @summary: Upsert of DpCompanyRules in database.
|
|
1168
|
+
* @description: This API returns response of upsert of DpCompanyRules in mongo database.
|
|
1169
|
+
*/
|
|
1170
|
+
async upsertDpCompanyRules({ body } = {}) {
|
|
1171
|
+
const { error } = ServiceabilityValidator.upsertDpCompanyRules().validate(
|
|
1172
|
+
{
|
|
1173
|
+
body,
|
|
1174
|
+
},
|
|
1175
|
+
{ abortEarly: false, allowUnknown: true }
|
|
1176
|
+
);
|
|
1177
|
+
if (error) {
|
|
1178
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1182
|
+
const {
|
|
1183
|
+
error: warrning,
|
|
1184
|
+
} = ServiceabilityValidator.upsertDpCompanyRules().validate(
|
|
1185
|
+
{
|
|
1186
|
+
body,
|
|
1187
|
+
},
|
|
1188
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1189
|
+
);
|
|
1190
|
+
if (warrning) {
|
|
1191
|
+
Logger({
|
|
1192
|
+
level: "WARN",
|
|
1193
|
+
message: "Parameter Validation warrnings for upsertDpCompanyRules",
|
|
1194
|
+
});
|
|
1195
|
+
Logger({ level: "WARN", message: warrning });
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
const query_params = {};
|
|
1199
|
+
|
|
1200
|
+
const xHeaders = {};
|
|
1201
|
+
|
|
1202
|
+
const response = await PlatformAPIClient.execute(
|
|
1203
|
+
this.config,
|
|
1204
|
+
"put",
|
|
1205
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/courier/priority`,
|
|
1206
|
+
query_params,
|
|
1207
|
+
body,
|
|
1208
|
+
xHeaders
|
|
1209
|
+
);
|
|
1210
|
+
|
|
1211
|
+
const {
|
|
1212
|
+
error: res_error,
|
|
1213
|
+
} = ServiceabilityModel.DPCompanyRuleResponse().validate(response, {
|
|
1214
|
+
abortEarly: false,
|
|
1215
|
+
allowUnknown: false,
|
|
1216
|
+
});
|
|
1217
|
+
|
|
1218
|
+
if (res_error) {
|
|
1219
|
+
Logger({
|
|
1220
|
+
level: "WARN",
|
|
1221
|
+
message: "Response Validation Warnnings for upsertDpCompanyRules",
|
|
1222
|
+
});
|
|
1223
|
+
Logger({ level: "WARN", message: res_error });
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
return response;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
/**
|
|
1230
|
+
* @param {Object} arg - Arg object.
|
|
1231
|
+
* @param {DpRuleRequest} arg.body
|
|
1232
|
+
* @returns {Promise<DpRuleSuccessResponse>} - Success response
|
|
1233
|
+
* @summary: Upsert of DpRules in database.
|
|
1234
|
+
* @description: This API returns response of upsert of DpRules in mongo database.
|
|
1235
|
+
*/
|
|
1236
|
+
async upsertDpRules({ body } = {}) {
|
|
1237
|
+
const { error } = ServiceabilityValidator.upsertDpRules().validate(
|
|
1238
|
+
{
|
|
1239
|
+
body,
|
|
1240
|
+
},
|
|
1241
|
+
{ abortEarly: false, allowUnknown: true }
|
|
1242
|
+
);
|
|
1243
|
+
if (error) {
|
|
1244
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1248
|
+
const {
|
|
1249
|
+
error: warrning,
|
|
1250
|
+
} = ServiceabilityValidator.upsertDpRules().validate(
|
|
1251
|
+
{
|
|
1252
|
+
body,
|
|
1253
|
+
},
|
|
1254
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1255
|
+
);
|
|
1256
|
+
if (warrning) {
|
|
1257
|
+
Logger({
|
|
1258
|
+
level: "WARN",
|
|
1259
|
+
message: "Parameter Validation warrnings for upsertDpRules",
|
|
1260
|
+
});
|
|
1261
|
+
Logger({ level: "WARN", message: warrning });
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
const query_params = {};
|
|
1265
|
+
|
|
1266
|
+
const xHeaders = {};
|
|
1267
|
+
|
|
1268
|
+
const response = await PlatformAPIClient.execute(
|
|
1269
|
+
this.config,
|
|
1270
|
+
"post",
|
|
1271
|
+
`/service/platform/logistics/v1.0/company/${this.config.companyId}/courier/rules`,
|
|
1272
|
+
query_params,
|
|
1273
|
+
body,
|
|
1274
|
+
xHeaders
|
|
1275
|
+
);
|
|
1276
|
+
|
|
1277
|
+
const {
|
|
1278
|
+
error: res_error,
|
|
1279
|
+
} = ServiceabilityModel.DpRuleSuccessResponse().validate(response, {
|
|
1280
|
+
abortEarly: false,
|
|
1281
|
+
allowUnknown: false,
|
|
1282
|
+
});
|
|
1283
|
+
|
|
1284
|
+
if (res_error) {
|
|
1285
|
+
Logger({
|
|
1286
|
+
level: "WARN",
|
|
1287
|
+
message: "Response Validation Warnnings for upsertDpRules",
|
|
1288
|
+
});
|
|
1289
|
+
Logger({ level: "WARN", message: res_error });
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
return response;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
module.exports = Serviceability;
|