@gofynd/fdk-client-javascript 1.5.1 → 1.6.0

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.
Files changed (64) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/sdk/application/Cart/CartApplicationClient.js +293 -0
  4. package/sdk/application/Catalog/CatalogApplicationClient.js +408 -0
  5. package/sdk/application/Common/CommonApplicationClient.js +21 -0
  6. package/sdk/application/Communication/CommunicationApplicationClient.js +29 -0
  7. package/sdk/application/Configuration/ConfigurationApplicationClient.js +147 -0
  8. package/sdk/application/Content/ContentApplicationClient.js +226 -0
  9. package/sdk/application/FileStorage/FileStorageApplicationClient.js +43 -0
  10. package/sdk/application/Finance/FinanceApplicationClient.js +21 -0
  11. package/sdk/application/Lead/LeadApplicationClient.js +73 -0
  12. package/sdk/application/Logistic/LogisticApplicationClient.d.ts +1 -1
  13. package/sdk/application/Logistic/LogisticApplicationClient.js +192 -3
  14. package/sdk/application/Order/OrderApplicationClient.js +202 -0
  15. package/sdk/application/Payment/PaymentApplicationClient.js +454 -0
  16. package/sdk/application/Rewards/RewardsApplicationClient.js +68 -0
  17. package/sdk/application/Share/ShareApplicationClient.js +96 -0
  18. package/sdk/application/Theme/ThemeApplicationClient.js +64 -0
  19. package/sdk/application/User/UserApplicationClient.js +412 -0
  20. package/sdk/application/Webhook/WebhookApplicationClient.js +13 -0
  21. package/sdk/partner/FileStorage/FileStoragePartnerClient.d.ts +10 -0
  22. package/sdk/partner/FileStorage/FileStoragePartnerClient.js +75 -0
  23. package/sdk/partner/FileStorage/FileStoragePartnerModel.d.ts +54 -1
  24. package/sdk/partner/FileStorage/FileStoragePartnerModel.js +43 -0
  25. package/sdk/partner/FileStorage/FileStoragePartnerValidator.d.ts +1 -0
  26. package/sdk/partner/FileStorage/FileStoragePartnerValidator.js +6 -0
  27. package/sdk/partner/Webhook/WebhookPartnerModel.d.ts +16 -3
  28. package/sdk/partner/Webhook/WebhookPartnerModel.js +5 -3
  29. package/sdk/platform/Analytics/AnalyticsPlatformApplicationValidator.d.ts +4 -1
  30. package/sdk/platform/Analytics/AnalyticsPlatformApplicationValidator.js +1 -1
  31. package/sdk/platform/AuditTrail/AuditTrailPlatformModel.d.ts +46 -23
  32. package/sdk/platform/AuditTrail/AuditTrailPlatformModel.js +12 -23
  33. package/sdk/platform/Cart/CartPlatformModel.d.ts +59 -1
  34. package/sdk/platform/Cart/CartPlatformModel.js +31 -0
  35. package/sdk/platform/Content/ContentPlatformApplicationClient.d.ts +0 -12
  36. package/sdk/platform/Content/ContentPlatformApplicationClient.js +0 -81
  37. package/sdk/platform/Content/ContentPlatformApplicationValidator.d.ts +1 -10
  38. package/sdk/platform/Content/ContentPlatformApplicationValidator.js +0 -12
  39. package/sdk/platform/Payment/PaymentPlatformApplicationClient.d.ts +13 -0
  40. package/sdk/platform/Payment/PaymentPlatformApplicationClient.js +82 -0
  41. package/sdk/platform/Payment/PaymentPlatformApplicationValidator.d.ts +10 -1
  42. package/sdk/platform/Payment/PaymentPlatformApplicationValidator.js +12 -0
  43. package/sdk/platform/Payment/PaymentPlatformModel.d.ts +129 -1
  44. package/sdk/platform/Payment/PaymentPlatformModel.js +94 -0
  45. package/sdk/platform/User/UserPlatformModel.d.ts +2 -2
  46. package/sdk/platform/User/UserPlatformModel.js +2 -2
  47. package/sdk/platform/Webhook/WebhookPlatformModel.d.ts +58 -14
  48. package/sdk/platform/Webhook/WebhookPlatformModel.js +15 -14
  49. package/sdk/public/Catalog/CatalogPublicClient.d.ts +22 -0
  50. package/sdk/public/Catalog/CatalogPublicClient.js +138 -0
  51. package/sdk/public/Catalog/CatalogPublicModel.d.ts +155 -0
  52. package/sdk/public/Catalog/CatalogPublicModel.js +116 -0
  53. package/sdk/public/Catalog/CatalogPublicValidator.d.ts +55 -0
  54. package/sdk/public/Catalog/CatalogPublicValidator.js +35 -0
  55. package/sdk/public/Configuration/ConfigurationPublicClient.js +16 -0
  56. package/sdk/public/Content/ContentPublicClient.js +116 -0
  57. package/sdk/public/Partner/PartnerPublicClient.js +15 -0
  58. package/sdk/public/PublicClient.d.ts +2 -0
  59. package/sdk/public/PublicClient.js +4 -0
  60. package/sdk/public/Webhook/WebhookPublicClient.js +40 -0
  61. package/sdk/public/Webhook/WebhookPublicModel.d.ts +194 -46
  62. package/sdk/public/Webhook/WebhookPublicModel.js +51 -46
  63. package/sdk/public/index.d.ts +1 -0
  64. package/sdk/public/index.js +2 -0
@@ -1002,6 +1002,13 @@ const Joi = require("joi");
1002
1002
  * @property {Object[]} [tags] - Optional address tag
1003
1003
  */
1004
1004
 
1005
+ /**
1006
+ * @typedef ReasonDetail
1007
+ * @property {string} [code] - The code indicating the type of reason.
1008
+ * @property {string} [description] - A detailed description of the payment
1009
+ * reason or error.
1010
+ */
1011
+
1005
1012
  /**
1006
1013
  * @typedef PaymentSessionDetail
1007
1014
  * @property {string} payment_id - Unique transaction id generated by payment gateway
@@ -1038,6 +1045,7 @@ const Joi = require("joi");
1038
1045
  * merchant account) by payment gateway.
1039
1046
  * @property {Object} [meta] - Extra meta data specific to extension
1040
1047
  * @property {string} status - Status of the payment
1048
+ * @property {ReasonDetail} [reason]
1041
1049
  */
1042
1050
 
1043
1051
  /**
@@ -1361,6 +1369,42 @@ const Joi = require("joi");
1361
1369
  * @property {PaymentModeCustomConfigSchema[]} items
1362
1370
  */
1363
1371
 
1372
+ /**
1373
+ * @typedef CustomerValidationSchema
1374
+ * @property {string} aggregator - Aggregator name of the payment gateway.
1375
+ * @property {number} transaction_amount - Payable amount
1376
+ * @property {string} [cart_id] - Unique identifier for the shopping cart.
1377
+ */
1378
+
1379
+ /**
1380
+ * @typedef UserCreditSchema
1381
+ * @property {number} amount - The monetary value, which can represent available
1382
+ * balance, redeemed balance, or hold amount, depending on the context.
1383
+ * @property {string} currency - The currency code (e.g., INR, USD).
1384
+ * @property {string} [unique_id] - A unique identifier for the payment transaction.
1385
+ */
1386
+
1387
+ /**
1388
+ * @typedef CreditAccountSummary
1389
+ * @property {string} account_id - Unique identifier associated with the
1390
+ * customer's account
1391
+ * @property {string} status - Current state of the account, indicating whether
1392
+ * it is ACTIVE, INACTIVE, or UNREGISTERED.
1393
+ * @property {UserCreditSchema} [redeemable_balance]
1394
+ * @property {UserCreditSchema} [available_balance]
1395
+ * @property {UserCreditSchema} [amount_on_hold]
1396
+ */
1397
+
1398
+ /**
1399
+ * @typedef ValidateCustomerCreditSchema
1400
+ * @property {boolean} success - Successful or failure of API
1401
+ * @property {boolean} is_eligible - The customer is eligible to make a transaction or not
1402
+ * @property {boolean} [is_applied] - Credit is applied to the user's account or not
1403
+ * @property {string} message - Detailed message about the user credt eligibility.
1404
+ * @property {string} [cart_id] - Unique identifier for the shopping cart.
1405
+ * @property {CreditAccountSummary} [account]
1406
+ */
1407
+
1364
1408
  class PaymentPlatformModel {
1365
1409
  /** @returns {PaymentGatewayConfigDetails} */
1366
1410
  static PaymentGatewayConfigDetails() {
@@ -2587,6 +2631,14 @@ class PaymentPlatformModel {
2587
2631
  });
2588
2632
  }
2589
2633
 
2634
+ /** @returns {ReasonDetail} */
2635
+ static ReasonDetail() {
2636
+ return Joi.object({
2637
+ code: Joi.string().allow(""),
2638
+ description: Joi.string().allow(""),
2639
+ });
2640
+ }
2641
+
2590
2642
  /** @returns {PaymentSessionDetail} */
2591
2643
  static PaymentSessionDetail() {
2592
2644
  return Joi.object({
@@ -2612,6 +2664,7 @@ class PaymentPlatformModel {
2612
2664
  captured: Joi.boolean(),
2613
2665
  meta: Joi.object().pattern(/\S/, Joi.any()),
2614
2666
  status: Joi.string().allow("").required(),
2667
+ reason: PaymentPlatformModel.ReasonDetail(),
2615
2668
  });
2616
2669
  }
2617
2670
 
@@ -2990,5 +3043,46 @@ class PaymentPlatformModel {
2990
3043
  .required(),
2991
3044
  });
2992
3045
  }
3046
+
3047
+ /** @returns {CustomerValidationSchema} */
3048
+ static CustomerValidationSchema() {
3049
+ return Joi.object({
3050
+ aggregator: Joi.string().allow("").required(),
3051
+ transaction_amount: Joi.number().required(),
3052
+ cart_id: Joi.string().allow(""),
3053
+ });
3054
+ }
3055
+
3056
+ /** @returns {UserCreditSchema} */
3057
+ static UserCreditSchema() {
3058
+ return Joi.object({
3059
+ amount: Joi.number().required(),
3060
+ currency: Joi.string().allow("").required(),
3061
+ unique_id: Joi.string().allow(""),
3062
+ });
3063
+ }
3064
+
3065
+ /** @returns {CreditAccountSummary} */
3066
+ static CreditAccountSummary() {
3067
+ return Joi.object({
3068
+ account_id: Joi.string().allow("").required(),
3069
+ status: Joi.string().allow("").required(),
3070
+ redeemable_balance: PaymentPlatformModel.UserCreditSchema(),
3071
+ available_balance: PaymentPlatformModel.UserCreditSchema(),
3072
+ amount_on_hold: PaymentPlatformModel.UserCreditSchema(),
3073
+ });
3074
+ }
3075
+
3076
+ /** @returns {ValidateCustomerCreditSchema} */
3077
+ static ValidateCustomerCreditSchema() {
3078
+ return Joi.object({
3079
+ success: Joi.boolean().required(),
3080
+ is_eligible: Joi.boolean().required(),
3081
+ is_applied: Joi.boolean(),
3082
+ message: Joi.string().allow("").required(),
3083
+ cart_id: Joi.string().allow(""),
3084
+ account: PaymentPlatformModel.CreditAccountSummary(),
3085
+ });
3086
+ }
2993
3087
  }
2994
3088
  module.exports = PaymentPlatformModel;
@@ -211,7 +211,7 @@ export = UserPlatformModel;
211
211
  * @property {string} [first_name]
212
212
  * @property {string} [last_name]
213
213
  * @property {string} [gender]
214
- * @property {string} username
214
+ * @property {string} [username]
215
215
  * @property {Object} [meta]
216
216
  * @property {string} [external_id]
217
217
  * @property {string} [rr_id]
@@ -835,7 +835,7 @@ type CreateUserRequestSchema = {
835
835
  first_name?: string;
836
836
  last_name?: string;
837
837
  gender?: string;
838
- username: string;
838
+ username?: string;
839
839
  meta?: any;
840
840
  external_id?: string;
841
841
  rr_id?: string;
@@ -239,7 +239,7 @@ const Joi = require("joi");
239
239
  * @property {string} [first_name]
240
240
  * @property {string} [last_name]
241
241
  * @property {string} [gender]
242
- * @property {string} username
242
+ * @property {string} [username]
243
243
  * @property {Object} [meta]
244
244
  * @property {string} [external_id]
245
245
  * @property {string} [rr_id]
@@ -827,7 +827,7 @@ class UserPlatformModel {
827
827
  first_name: Joi.string().allow(""),
828
828
  last_name: Joi.string().allow(""),
829
829
  gender: Joi.string().allow(""),
830
- username: Joi.string().allow("").required(),
830
+ username: Joi.string().allow(""),
831
831
  meta: Joi.object().pattern(/\S/, Joi.any()),
832
832
  external_id: Joi.string().allow(""),
833
833
  rr_id: Joi.string().allow(""),
@@ -55,7 +55,7 @@ export = WebhookPlatformModel;
55
55
  */
56
56
  /**
57
57
  * @typedef EventConfigResult
58
- * @property {EventConfig[]} [event_configs]
58
+ * @property {EventConfig[]} [event_configs] - List of event configurations.
59
59
  */
60
60
  /**
61
61
  * @typedef Association
@@ -96,7 +96,7 @@ export = WebhookPlatformModel;
96
96
  * @property {string} [created_on] - The date and time when the subscriber was created.
97
97
  * @property {string} [type] - The type of subscriber, which can either be passed as null.
98
98
  * @property {AuthMeta} [auth_meta]
99
- * @property {EventConfig[]} [event_configs]
99
+ * @property {EventConfig[]} [event_configs] - List of event configurations.
100
100
  */
101
101
  /**
102
102
  * @typedef Events
@@ -183,7 +183,7 @@ export = WebhookPlatformModel;
183
183
  */
184
184
  /**
185
185
  * @typedef SubscriberConfigList
186
- * @property {SubscriberDetails[]} [items]
186
+ * @property {SubscriberDetails[]} [items] - List of subscriber details.
187
187
  * @property {Page} [page]
188
188
  */
189
189
  /**
@@ -199,7 +199,7 @@ export = WebhookPlatformModel;
199
199
  * @property {string} type - The type of the configuration.
200
200
  * @property {Object} [custom_headers] - Custom headers for the configuration.
201
201
  * @property {AuthMeta} [auth_meta]
202
- * @property {RestEventData[]} events
202
+ * @property {RestEventData[]} events - List of event data for configuration.
203
203
  */
204
204
  /**
205
205
  * @typedef QueueEventData
@@ -211,13 +211,13 @@ export = WebhookPlatformModel;
211
211
  */
212
212
  /**
213
213
  * @typedef KafkaConfig
214
- * @property {string} [type]
215
- * @property {QueueEventData[]} events
214
+ * @property {string} [type] - Type of Kafka configuration (optional).
215
+ * @property {QueueEventData[]} events - List of event data for configuration.
216
216
  */
217
217
  /**
218
218
  * @typedef PubSubConfig
219
- * @property {string} [type]
220
- * @property {QueueEventData[]} events
219
+ * @property {string} [type] - Type of Pub/Sub configuration (optional).
220
+ * @property {QueueEventData[]} events - List of event data for configuration.
221
221
  */
222
222
  /**
223
223
  * @typedef TemporalEventData
@@ -230,8 +230,8 @@ export = WebhookPlatformModel;
230
230
  */
231
231
  /**
232
232
  * @typedef TemporalConfig
233
- * @property {string} [type]
234
- * @property {TemporalEventData[]} events
233
+ * @property {string} [type] - Type of Temporal configuration (optional).
234
+ * @property {TemporalEventData[]} events - List of event data for configuration.
235
235
  */
236
236
  /**
237
237
  * @typedef SqsEventData
@@ -243,8 +243,8 @@ export = WebhookPlatformModel;
243
243
  */
244
244
  /**
245
245
  * @typedef SqsConfig
246
- * @property {string} [type]
247
- * @property {SqsEventData[]} events
246
+ * @property {string} [type] - Type of SQS configuration (optional).
247
+ * @property {SqsEventData[]} events - List of event data for configuration.
248
248
  */
249
249
  /**
250
250
  * @typedef EventBridgeData
@@ -257,8 +257,9 @@ export = WebhookPlatformModel;
257
257
  */
258
258
  /**
259
259
  * @typedef EventBridgeConfig
260
- * @property {string} [type]
261
- * @property {EventBridgeData[]} events
260
+ * @property {string} [type] - Type of event configuration (optional).
261
+ * @property {EventBridgeData[]} events - List of event data for EventBridge
262
+ * configuration.
262
263
  */
263
264
  /**
264
265
  * @typedef EventMapBody
@@ -445,6 +446,9 @@ type EventConfig = {
445
446
  /** @returns {EventConfigResult} */
446
447
  declare function EventConfigResult(): EventConfigResult;
447
448
  type EventConfigResult = {
449
+ /**
450
+ * - List of event configurations.
451
+ */
448
452
  event_configs?: EventConfig[];
449
453
  };
450
454
  /** @returns {Association} */
@@ -547,6 +551,9 @@ type SubscriberDetails = {
547
551
  */
548
552
  type?: string;
549
553
  auth_meta?: AuthMeta;
554
+ /**
555
+ * - List of event configurations.
556
+ */
550
557
  event_configs?: EventConfig[];
551
558
  };
552
559
  /** @returns {Events} */
@@ -776,6 +783,9 @@ type SubscriberConfigResult = {
776
783
  /** @returns {SubscriberConfigList} */
777
784
  declare function SubscriberConfigList(): SubscriberConfigList;
778
785
  type SubscriberConfigList = {
786
+ /**
787
+ * - List of subscriber details.
788
+ */
779
789
  items?: SubscriberDetails[];
780
790
  page?: Page;
781
791
  };
@@ -815,6 +825,9 @@ type RestConfig = {
815
825
  */
816
826
  custom_headers?: any;
817
827
  auth_meta?: AuthMeta;
828
+ /**
829
+ * - List of event data for configuration.
830
+ */
818
831
  events: RestEventData[];
819
832
  };
820
833
  /** @returns {QueueEventData} */
@@ -844,13 +857,25 @@ type QueueEventData = {
844
857
  /** @returns {KafkaConfig} */
845
858
  declare function KafkaConfig(): KafkaConfig;
846
859
  type KafkaConfig = {
860
+ /**
861
+ * - Type of Kafka configuration (optional).
862
+ */
847
863
  type?: string;
864
+ /**
865
+ * - List of event data for configuration.
866
+ */
848
867
  events: QueueEventData[];
849
868
  };
850
869
  /** @returns {PubSubConfig} */
851
870
  declare function PubSubConfig(): PubSubConfig;
852
871
  type PubSubConfig = {
872
+ /**
873
+ * - Type of Pub/Sub configuration (optional).
874
+ */
853
875
  type?: string;
876
+ /**
877
+ * - List of event data for configuration.
878
+ */
854
879
  events: QueueEventData[];
855
880
  };
856
881
  /** @returns {TemporalEventData} */
@@ -884,7 +909,13 @@ type TemporalEventData = {
884
909
  /** @returns {TemporalConfig} */
885
910
  declare function TemporalConfig(): TemporalConfig;
886
911
  type TemporalConfig = {
912
+ /**
913
+ * - Type of Temporal configuration (optional).
914
+ */
887
915
  type?: string;
916
+ /**
917
+ * - List of event data for configuration.
918
+ */
888
919
  events: TemporalEventData[];
889
920
  };
890
921
  /** @returns {SqsEventData} */
@@ -914,7 +945,13 @@ type SqsEventData = {
914
945
  /** @returns {SqsConfig} */
915
946
  declare function SqsConfig(): SqsConfig;
916
947
  type SqsConfig = {
948
+ /**
949
+ * - Type of SQS configuration (optional).
950
+ */
917
951
  type?: string;
952
+ /**
953
+ * - List of event data for configuration.
954
+ */
918
955
  events: SqsEventData[];
919
956
  };
920
957
  /** @returns {EventBridgeData} */
@@ -945,7 +982,14 @@ type EventBridgeData = {
945
982
  /** @returns {EventBridgeConfig} */
946
983
  declare function EventBridgeConfig(): EventBridgeConfig;
947
984
  type EventBridgeConfig = {
985
+ /**
986
+ * - Type of event configuration (optional).
987
+ */
948
988
  type?: string;
989
+ /**
990
+ * - List of event data for EventBridge
991
+ * configuration.
992
+ */
949
993
  events: EventBridgeData[];
950
994
  };
951
995
  /** @returns {EventMapBody} */
@@ -60,7 +60,7 @@ const Joi = require("joi");
60
60
 
61
61
  /**
62
62
  * @typedef EventConfigResult
63
- * @property {EventConfig[]} [event_configs]
63
+ * @property {EventConfig[]} [event_configs] - List of event configurations.
64
64
  */
65
65
 
66
66
  /**
@@ -105,7 +105,7 @@ const Joi = require("joi");
105
105
  * @property {string} [created_on] - The date and time when the subscriber was created.
106
106
  * @property {string} [type] - The type of subscriber, which can either be passed as null.
107
107
  * @property {AuthMeta} [auth_meta]
108
- * @property {EventConfig[]} [event_configs]
108
+ * @property {EventConfig[]} [event_configs] - List of event configurations.
109
109
  */
110
110
 
111
111
  /**
@@ -199,7 +199,7 @@ const Joi = require("joi");
199
199
 
200
200
  /**
201
201
  * @typedef SubscriberConfigList
202
- * @property {SubscriberDetails[]} [items]
202
+ * @property {SubscriberDetails[]} [items] - List of subscriber details.
203
203
  * @property {Page} [page]
204
204
  */
205
205
 
@@ -217,7 +217,7 @@ const Joi = require("joi");
217
217
  * @property {string} type - The type of the configuration.
218
218
  * @property {Object} [custom_headers] - Custom headers for the configuration.
219
219
  * @property {AuthMeta} [auth_meta]
220
- * @property {RestEventData[]} events
220
+ * @property {RestEventData[]} events - List of event data for configuration.
221
221
  */
222
222
 
223
223
  /**
@@ -231,14 +231,14 @@ const Joi = require("joi");
231
231
 
232
232
  /**
233
233
  * @typedef KafkaConfig
234
- * @property {string} [type]
235
- * @property {QueueEventData[]} events
234
+ * @property {string} [type] - Type of Kafka configuration (optional).
235
+ * @property {QueueEventData[]} events - List of event data for configuration.
236
236
  */
237
237
 
238
238
  /**
239
239
  * @typedef PubSubConfig
240
- * @property {string} [type]
241
- * @property {QueueEventData[]} events
240
+ * @property {string} [type] - Type of Pub/Sub configuration (optional).
241
+ * @property {QueueEventData[]} events - List of event data for configuration.
242
242
  */
243
243
 
244
244
  /**
@@ -253,8 +253,8 @@ const Joi = require("joi");
253
253
 
254
254
  /**
255
255
  * @typedef TemporalConfig
256
- * @property {string} [type]
257
- * @property {TemporalEventData[]} events
256
+ * @property {string} [type] - Type of Temporal configuration (optional).
257
+ * @property {TemporalEventData[]} events - List of event data for configuration.
258
258
  */
259
259
 
260
260
  /**
@@ -268,8 +268,8 @@ const Joi = require("joi");
268
268
 
269
269
  /**
270
270
  * @typedef SqsConfig
271
- * @property {string} [type]
272
- * @property {SqsEventData[]} events
271
+ * @property {string} [type] - Type of SQS configuration (optional).
272
+ * @property {SqsEventData[]} events - List of event data for configuration.
273
273
  */
274
274
 
275
275
  /**
@@ -284,8 +284,9 @@ const Joi = require("joi");
284
284
 
285
285
  /**
286
286
  * @typedef EventBridgeConfig
287
- * @property {string} [type]
288
- * @property {EventBridgeData[]} events
287
+ * @property {string} [type] - Type of event configuration (optional).
288
+ * @property {EventBridgeData[]} events - List of event data for EventBridge
289
+ * configuration.
289
290
  */
290
291
 
291
292
  /**
@@ -0,0 +1,22 @@
1
+ export = Catalog;
2
+ declare class Catalog {
3
+ constructor(_conf: any);
4
+ _conf: any;
5
+ _relativeUrls: {
6
+ getTaxonomyByLevel: string;
7
+ };
8
+ _urls: {};
9
+ updateUrls(urls: any): void;
10
+ /**
11
+ * @param {CatalogPublicValidator.GetTaxonomyByLevelParam} arg - Arg object.
12
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
13
+ * @param {import("../PublicAPIClient").Options} - Options
14
+ * @returns {Promise<CatalogPublicModel.TaxonomyResponseSchema>} - Success response
15
+ * @name getTaxonomyByLevel
16
+ * @summary: Get Taxonomy Information by Level
17
+ * @description: Get Taxonomy Details for a given level - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/public/catalog/getTaxonomyByLevel/).
18
+ */
19
+ getTaxonomyByLevel({ level, l0Slug, l1Slug, l2Slug, l3Slug, limit, requestHeaders }?: CatalogPublicValidator.GetTaxonomyByLevelParam, { responseHeaders }?: object): Promise<CatalogPublicModel.TaxonomyResponseSchema>;
20
+ }
21
+ import CatalogPublicValidator = require("./CatalogPublicValidator");
22
+ import CatalogPublicModel = require("./CatalogPublicModel");
@@ -0,0 +1,138 @@
1
+ const {
2
+ FDKClientValidationError,
3
+ FDKResponseValidationError,
4
+ } = require("../../common/FDKError");
5
+
6
+ const PublicAPIClient = require("../PublicAPIClient");
7
+ const constructUrl = require("../constructUrl");
8
+ const Paginator = require("../../common/Paginator");
9
+
10
+ const CatalogPublicValidator = require("./CatalogPublicValidator");
11
+ const CatalogPublicModel = require("./CatalogPublicModel");
12
+ const Joi = require("joi");
13
+ const { Logger } = require("./../../common/Logger");
14
+
15
+ class Catalog {
16
+ constructor(_conf) {
17
+ this._conf = _conf;
18
+ this._relativeUrls = {
19
+ getTaxonomyByLevel: "/service/public/catalog/v1.0/taxonomy/level/{level}",
20
+ };
21
+ this._urls = Object.entries(this._relativeUrls).reduce(
22
+ (urls, [method, relativeUrl]) => {
23
+ urls[method] = `${_conf.domain}${relativeUrl}`;
24
+ return urls;
25
+ },
26
+ {}
27
+ );
28
+ }
29
+
30
+ updateUrls(urls) {
31
+ this._urls = {
32
+ ...this._urls,
33
+ ...urls,
34
+ };
35
+ }
36
+
37
+ /**
38
+ * @param {CatalogPublicValidator.GetTaxonomyByLevelParam} arg - Arg object.
39
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
40
+ * @param {import("../PublicAPIClient").Options} - Options
41
+ * @returns {Promise<CatalogPublicModel.TaxonomyResponseSchema>} - Success response
42
+ * @name getTaxonomyByLevel
43
+ * @summary: Get Taxonomy Information by Level
44
+ * @description: Get Taxonomy Details for a given level - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/public/catalog/getTaxonomyByLevel/).
45
+ */
46
+ async getTaxonomyByLevel(
47
+ { level, l0Slug, l1Slug, l2Slug, l3Slug, limit, requestHeaders } = {
48
+ requestHeaders: {},
49
+ },
50
+ { responseHeaders } = { responseHeaders: false }
51
+ ) {
52
+ let invalidInput = [];
53
+
54
+ if (!level) {
55
+ invalidInput.push({
56
+ message: `The 'level' field is required.`,
57
+ path: ["level"],
58
+ });
59
+ }
60
+ if (invalidInput.length) {
61
+ const error = new Error();
62
+ error.message = "Missing required field";
63
+ error.details = invalidInput;
64
+ return Promise.reject(new FDKClientValidationError(error));
65
+ }
66
+
67
+ const { error } = CatalogPublicValidator.getTaxonomyByLevel().validate(
68
+ { level, l0Slug, l1Slug, l2Slug, l3Slug, limit },
69
+ { abortEarly: false, allowUnknown: true }
70
+ );
71
+ if (error) {
72
+ return Promise.reject(new FDKClientValidationError(error));
73
+ }
74
+
75
+ // Showing warrnings if extra unknown parameters are found
76
+ const {
77
+ error: warrning,
78
+ } = CatalogPublicValidator.getTaxonomyByLevel().validate(
79
+ { level, l0Slug, l1Slug, l2Slug, l3Slug, limit },
80
+ { abortEarly: false, allowUnknown: false }
81
+ );
82
+ if (warrning) {
83
+ Logger({
84
+ level: "WARN",
85
+ message: `Parameter Validation warrnings for public > Catalog > getTaxonomyByLevel \n ${warrning}`,
86
+ });
87
+ }
88
+
89
+ const query_params = {};
90
+ query_params["l0_slug"] = l0Slug;
91
+ query_params["l1_slug"] = l1Slug;
92
+ query_params["l2_slug"] = l2Slug;
93
+ query_params["l3_slug"] = l3Slug;
94
+ query_params["limit"] = limit;
95
+
96
+ const xHeaders = {};
97
+
98
+ const response = await PublicAPIClient.execute(
99
+ this._conf,
100
+ "get",
101
+ constructUrl({
102
+ url: this._urls["getTaxonomyByLevel"],
103
+ params: { level },
104
+ }),
105
+ query_params,
106
+ undefined,
107
+ { ...xHeaders, ...requestHeaders },
108
+ { responseHeaders }
109
+ );
110
+
111
+ let responseData = response;
112
+ if (responseHeaders) {
113
+ responseData = response[0];
114
+ }
115
+
116
+ const {
117
+ error: res_error,
118
+ } = CatalogPublicModel.TaxonomyResponseSchema().validate(responseData, {
119
+ abortEarly: false,
120
+ allowUnknown: true,
121
+ });
122
+
123
+ if (res_error) {
124
+ if (this._conf.options.strictResponseCheck === true) {
125
+ return Promise.reject(new FDKResponseValidationError(res_error));
126
+ } else {
127
+ Logger({
128
+ level: "WARN",
129
+ message: `Response Validation Warnings for public > Catalog > getTaxonomyByLevel \n ${res_error}`,
130
+ });
131
+ }
132
+ }
133
+
134
+ return response;
135
+ }
136
+ }
137
+
138
+ module.exports = Catalog;