@gofynd/fdk-client-javascript 3.11.0 → 3.12.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 (24) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/sdk/application/Catalog/CatalogApplicationClient.d.ts +16 -6
  4. package/sdk/application/Catalog/CatalogApplicationClient.js +71 -12
  5. package/sdk/platform/Cart/CartPlatformApplicationValidator.d.ts +80 -80
  6. package/sdk/platform/Cart/CartPlatformApplicationValidator.js +48 -48
  7. package/sdk/platform/Cart/CartPlatformModel.d.ts +6 -18
  8. package/sdk/platform/Cart/CartPlatformModel.js +2 -36
  9. package/sdk/platform/Catalog/CatalogPlatformClient.d.ts +14 -48
  10. package/sdk/platform/Catalog/CatalogPlatformClient.js +85 -338
  11. package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +207 -763
  12. package/sdk/platform/Catalog/CatalogPlatformModel.js +107 -392
  13. package/sdk/platform/Catalog/CatalogPlatformValidator.d.ts +15 -71
  14. package/sdk/platform/Catalog/CatalogPlatformValidator.js +14 -60
  15. package/sdk/platform/Order/OrderPlatformApplicationClient.d.ts +36 -0
  16. package/sdk/platform/Order/OrderPlatformApplicationClient.js +252 -0
  17. package/sdk/platform/Order/OrderPlatformApplicationValidator.d.ts +34 -1
  18. package/sdk/platform/Order/OrderPlatformApplicationValidator.js +42 -0
  19. package/sdk/platform/Order/OrderPlatformClient.d.ts +69 -7
  20. package/sdk/platform/Order/OrderPlatformClient.js +453 -7
  21. package/sdk/platform/Order/OrderPlatformModel.d.ts +1851 -431
  22. package/sdk/platform/Order/OrderPlatformModel.js +1171 -448
  23. package/sdk/platform/Order/OrderPlatformValidator.d.ts +150 -16
  24. package/sdk/platform/Order/OrderPlatformValidator.js +105 -9
@@ -439,6 +439,83 @@ class Order {
439
439
  return response;
440
440
  }
441
441
 
442
+ /**
443
+ * @param {OrderPlatformValidator.CreateAccountParam} arg - Arg object
444
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
445
+ * @param {import("../PlatformAPIClient").Options} - Options
446
+ * @returns {Promise<OrderPlatformModel.Account>} - Success response
447
+ * @name createAccount
448
+ * @summary: Create channel account
449
+ * @description: Creates a new channel account for the company. Channel accounts represent different sales channels or marketplace integrations (e.g., Shopify, custom marketplaces) through which the company receives and processes orders. Each account is identified by a unique name and can be used to segregate orders from different sources. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/order/createAccount/).
450
+ */
451
+ async createAccount(
452
+ { body, requestHeaders } = { requestHeaders: {} },
453
+ { responseHeaders } = { responseHeaders: false }
454
+ ) {
455
+ const { error } = OrderPlatformValidator.createAccount().validate(
456
+ {
457
+ body,
458
+ },
459
+ { abortEarly: false, allowUnknown: true }
460
+ );
461
+ if (error) {
462
+ return Promise.reject(new FDKClientValidationError(error));
463
+ }
464
+
465
+ // Showing warrnings if extra unknown parameters are found
466
+ const { error: warrning } = OrderPlatformValidator.createAccount().validate(
467
+ {
468
+ body,
469
+ },
470
+ { abortEarly: false, allowUnknown: false }
471
+ );
472
+ if (warrning) {
473
+ Logger({
474
+ level: "WARN",
475
+ message: `Parameter Validation warrnings for platform > Order > createAccount \n ${warrning}`,
476
+ });
477
+ }
478
+
479
+ const query_params = {};
480
+
481
+ const xHeaders = {};
482
+
483
+ const response = await PlatformAPIClient.execute(
484
+ this.config,
485
+ "post",
486
+ `/service/platform/order-manage/v1.0/company/${this.config.companyId}/account`,
487
+ query_params,
488
+ body,
489
+ { ...xHeaders, ...requestHeaders },
490
+ { responseHeaders }
491
+ );
492
+
493
+ let responseData = response;
494
+ if (responseHeaders) {
495
+ responseData = response[0];
496
+ }
497
+
498
+ const {
499
+ error: res_error,
500
+ } = OrderPlatformModel.Account().validate(responseData, {
501
+ abortEarly: false,
502
+ allowUnknown: true,
503
+ });
504
+
505
+ if (res_error) {
506
+ if (this.config.options.strictResponseCheck === true) {
507
+ return Promise.reject(new FDKResponseValidationError(res_error));
508
+ } else {
509
+ Logger({
510
+ level: "WARN",
511
+ message: `Response Validation Warnings for platform > Order > createAccount \n ${res_error}`,
512
+ });
513
+ }
514
+ }
515
+
516
+ return response;
517
+ }
518
+
442
519
  /**
443
520
  * @param {OrderPlatformValidator.CreateChannelConfigParam} arg - Arg object
444
521
  * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
@@ -524,19 +601,23 @@ class Order {
524
601
  * @param {OrderPlatformValidator.CreateOrderParam} arg - Arg object
525
602
  * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
526
603
  * @param {import("../PlatformAPIClient").Options} - Options
527
- * @returns {Promise<OrderPlatformModel.CreateOrderResponseSchema>} - Success response
604
+ * @returns {Promise<Object>} - Success response
528
605
  * @name createOrder
529
- * @summary: Create order
530
- * @description: Creates an order - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/order/createOrder/).
606
+ * @summary: Create Order
607
+ * @description: Creates an order in the OMS. Note: Use the Serviceability API (getShipments) to determine shipments before creating an order. OMS no longer auto-selects fulfillment stores and only creates shipments as provided in the request payload. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/order/createOrder/).
531
608
  */
532
609
  async createOrder(
533
- { body, xOrderingSource, requestHeaders } = { requestHeaders: {} },
610
+ { xOrderingSource, body, xApplicationId, xExtensionId, requestHeaders } = {
611
+ requestHeaders: {},
612
+ },
534
613
  { responseHeaders } = { responseHeaders: false }
535
614
  ) {
536
615
  const { error } = OrderPlatformValidator.createOrder().validate(
537
616
  {
538
- body,
539
617
  xOrderingSource,
618
+ body,
619
+ xApplicationId,
620
+ xExtensionId,
540
621
  },
541
622
  { abortEarly: false, allowUnknown: true }
542
623
  );
@@ -547,8 +628,10 @@ class Order {
547
628
  // Showing warrnings if extra unknown parameters are found
548
629
  const { error: warrning } = OrderPlatformValidator.createOrder().validate(
549
630
  {
550
- body,
551
631
  xOrderingSource,
632
+ body,
633
+ xApplicationId,
634
+ xExtensionId,
552
635
  },
553
636
  { abortEarly: false, allowUnknown: false }
554
637
  );
@@ -563,6 +646,98 @@ class Order {
563
646
 
564
647
  const xHeaders = {};
565
648
  xHeaders["x-ordering-source"] = xOrderingSource;
649
+ xHeaders["x-application-id"] = xApplicationId;
650
+ xHeaders["x-extension-id"] = xExtensionId;
651
+
652
+ const response = await PlatformAPIClient.execute(
653
+ this.config,
654
+ "post",
655
+ `/service/platform/order-manage/v1.0/company/${this.config.companyId}/orders`,
656
+ query_params,
657
+ body,
658
+ { ...xHeaders, ...requestHeaders },
659
+ { responseHeaders }
660
+ );
661
+
662
+ let responseData = response;
663
+ if (responseHeaders) {
664
+ responseData = response[0];
665
+ }
666
+
667
+ const { error: res_error } = Joi.any().validate(responseData, {
668
+ abortEarly: false,
669
+ allowUnknown: true,
670
+ });
671
+
672
+ if (res_error) {
673
+ if (this.config.options.strictResponseCheck === true) {
674
+ return Promise.reject(new FDKResponseValidationError(res_error));
675
+ } else {
676
+ Logger({
677
+ level: "WARN",
678
+ message: `Response Validation Warnings for platform > Order > createOrder \n ${res_error}`,
679
+ });
680
+ }
681
+ }
682
+
683
+ return response;
684
+ }
685
+
686
+ /**
687
+ * @param {OrderPlatformValidator.CreateOrderDeprecatedParam} arg - Arg object
688
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
689
+ * @param {import("../PlatformAPIClient").Options} - Options
690
+ * @returns {Promise<OrderPlatformModel.CreateOrderResponseSchema>} - Success response
691
+ * @name createOrderDeprecated
692
+ * @summary: Create order
693
+ * @description: Creates an order - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/order/createOrderDeprecated/).
694
+ */
695
+ async createOrderDeprecated(
696
+ { xOrderingSource, body, xApplicationId, xExtensionId, requestHeaders } = {
697
+ requestHeaders: {},
698
+ },
699
+ { responseHeaders } = { responseHeaders: false }
700
+ ) {
701
+ const { error } = OrderPlatformValidator.createOrderDeprecated().validate(
702
+ {
703
+ xOrderingSource,
704
+
705
+ body,
706
+ xApplicationId,
707
+ xExtensionId,
708
+ },
709
+ { abortEarly: false, allowUnknown: true }
710
+ );
711
+ if (error) {
712
+ return Promise.reject(new FDKClientValidationError(error));
713
+ }
714
+
715
+ // Showing warrnings if extra unknown parameters are found
716
+ const {
717
+ error: warrning,
718
+ } = OrderPlatformValidator.createOrderDeprecated().validate(
719
+ {
720
+ xOrderingSource,
721
+
722
+ body,
723
+ xApplicationId,
724
+ xExtensionId,
725
+ },
726
+ { abortEarly: false, allowUnknown: false }
727
+ );
728
+ if (warrning) {
729
+ Logger({
730
+ level: "WARN",
731
+ message: `Parameter Validation warrnings for platform > Order > createOrderDeprecated \n ${warrning}`,
732
+ });
733
+ }
734
+
735
+ const query_params = {};
736
+
737
+ const xHeaders = {};
738
+ xHeaders["x-ordering-source"] = xOrderingSource;
739
+ xHeaders["x-application-id"] = xApplicationId;
740
+ xHeaders["x-extension-id"] = xExtensionId;
566
741
 
567
742
  const response = await PlatformAPIClient.execute(
568
743
  this.config,
@@ -592,7 +767,7 @@ class Order {
592
767
  } else {
593
768
  Logger({
594
769
  level: "WARN",
595
- message: `Response Validation Warnings for platform > Order > createOrder \n ${res_error}`,
770
+ message: `Response Validation Warnings for platform > Order > createOrderDeprecated \n ${res_error}`,
596
771
  });
597
772
  }
598
773
  }
@@ -1430,6 +1605,85 @@ class Order {
1430
1605
  return response;
1431
1606
  }
1432
1607
 
1608
+ /**
1609
+ * @param {OrderPlatformValidator.GetAccountByIdParam} arg - Arg object
1610
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
1611
+ * @param {import("../PlatformAPIClient").Options} - Options
1612
+ * @returns {Promise<OrderPlatformModel.Account>} - Success response
1613
+ * @name getAccountById
1614
+ * @summary: Get channel account details
1615
+ * @description: Retrieves detailed information about a specific channel account using its unique identifier. This endpoint returns the complete account details including the account ID, associated company ID, and the channel account name. Use this to fetch information about a particular sales channel or marketplace integration. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/order/getAccountById/).
1616
+ */
1617
+ async getAccountById(
1618
+ { channelAccountId, requestHeaders } = { requestHeaders: {} },
1619
+ { responseHeaders } = { responseHeaders: false }
1620
+ ) {
1621
+ const { error } = OrderPlatformValidator.getAccountById().validate(
1622
+ {
1623
+ channelAccountId,
1624
+ },
1625
+ { abortEarly: false, allowUnknown: true }
1626
+ );
1627
+ if (error) {
1628
+ return Promise.reject(new FDKClientValidationError(error));
1629
+ }
1630
+
1631
+ // Showing warrnings if extra unknown parameters are found
1632
+ const {
1633
+ error: warrning,
1634
+ } = OrderPlatformValidator.getAccountById().validate(
1635
+ {
1636
+ channelAccountId,
1637
+ },
1638
+ { abortEarly: false, allowUnknown: false }
1639
+ );
1640
+ if (warrning) {
1641
+ Logger({
1642
+ level: "WARN",
1643
+ message: `Parameter Validation warrnings for platform > Order > getAccountById \n ${warrning}`,
1644
+ });
1645
+ }
1646
+
1647
+ const query_params = {};
1648
+
1649
+ const xHeaders = {};
1650
+
1651
+ const response = await PlatformAPIClient.execute(
1652
+ this.config,
1653
+ "get",
1654
+ `/service/platform/order-manage/v1.0/company/${this.config.companyId}/account/${channelAccountId}`,
1655
+ query_params,
1656
+ undefined,
1657
+ { ...xHeaders, ...requestHeaders },
1658
+ { responseHeaders }
1659
+ );
1660
+
1661
+ let responseData = response;
1662
+ if (responseHeaders) {
1663
+ responseData = response[0];
1664
+ }
1665
+
1666
+ const {
1667
+ error: res_error,
1668
+ } = OrderPlatformModel.Account().validate(responseData, {
1669
+ abortEarly: false,
1670
+ allowUnknown: true,
1671
+ });
1672
+
1673
+ if (res_error) {
1674
+ if (this.config.options.strictResponseCheck === true) {
1675
+ return Promise.reject(new FDKResponseValidationError(res_error));
1676
+ } else {
1677
+ Logger({
1678
+ level: "WARN",
1679
+ message: `Response Validation Warnings for platform > Order > getAccountById \n ${res_error}`,
1680
+ });
1681
+ }
1682
+ }
1683
+
1684
+ return response;
1685
+ }
1686
+
1433
1687
  /**
1434
1688
  * @param {OrderPlatformValidator.GetAllowedStateTransitionParam} arg - Arg object
1435
1689
  * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
@@ -2945,6 +3199,8 @@ class Order {
2945
3199
  groupEntity,
2946
3200
  enforceDateFilter,
2947
3201
  fulfillmentType,
3202
+ orderingSource,
3203
+ channelAccountId,
2948
3204
  requestHeaders,
2949
3205
  } = { requestHeaders: {} },
2950
3206
  { responseHeaders } = { responseHeaders: false }
@@ -2977,6 +3233,8 @@ class Order {
2977
3233
  groupEntity,
2978
3234
  enforceDateFilter,
2979
3235
  fulfillmentType,
3236
+ orderingSource,
3237
+ channelAccountId,
2980
3238
  },
2981
3239
  { abortEarly: false, allowUnknown: true }
2982
3240
  );
@@ -3013,6 +3271,8 @@ class Order {
3013
3271
  groupEntity,
3014
3272
  enforceDateFilter,
3015
3273
  fulfillmentType,
3274
+ orderingSource,
3275
+ channelAccountId,
3016
3276
  },
3017
3277
  { abortEarly: false, allowUnknown: false }
3018
3278
  );
@@ -3050,6 +3310,8 @@ class Order {
3050
3310
  query_params["group_entity"] = groupEntity;
3051
3311
  query_params["enforce_date_filter"] = enforceDateFilter;
3052
3312
  query_params["fulfillment_type"] = fulfillmentType;
3313
+ query_params["ordering_source"] = orderingSource;
3314
+ query_params["channel_account_id"] = channelAccountId;
3053
3315
 
3054
3316
  const xHeaders = {};
3055
3317
 
@@ -3138,6 +3400,10 @@ class Order {
3138
3400
  * Listing Orders, This is use when we want to get list of shipments or
3139
3401
  * orders by cross store or cross company or fulfilling Store (by
3140
3402
  * default), this is also depends on the login user accessType and store access
3403
+ * @param {string} [arg.orderingSource] - Filter orders by ordering source.
3404
+ * Accepts comma-separated values for multiple sources.
3405
+ * @param {string} [arg.channelAccountId] - Comma-separated channel account
3406
+ * IDs to filter orders by specific channel accounts.
3141
3407
  * @returns {Paginator<OrderPlatformModel.OrderListingResponseSchema>}
3142
3408
  * @summary: List orders
3143
3409
  * @description: Get a list of orders based on the filters provided.
@@ -3168,6 +3434,8 @@ class Order {
3168
3434
  groupEntity,
3169
3435
  enforceDateFilter,
3170
3436
  fulfillmentType,
3437
+ orderingSource,
3438
+ channelAccountId,
3171
3439
  } = {}) {
3172
3440
  const paginator = new Paginator();
3173
3441
  const callback = async () => {
@@ -3201,6 +3469,8 @@ class Order {
3201
3469
  groupEntity: groupEntity,
3202
3470
  enforceDateFilter: enforceDateFilter,
3203
3471
  fulfillmentType: fulfillmentType,
3472
+ orderingSource: orderingSource,
3473
+ channelAccountId: channelAccountId,
3204
3474
  });
3205
3475
  paginator.setPaginator({
3206
3476
  hasNext: data.page.has_next ? true : false,
@@ -3602,6 +3872,8 @@ class Order {
3602
3872
  groupEntity,
3603
3873
  enforceDateFilter,
3604
3874
  fulfillmentType,
3875
+ orderingSource,
3876
+ channelAccountId,
3605
3877
  requestHeaders,
3606
3878
  } = { requestHeaders: {} },
3607
3879
  { responseHeaders } = { responseHeaders: false }
@@ -3645,6 +3917,8 @@ class Order {
3645
3917
  groupEntity,
3646
3918
  enforceDateFilter,
3647
3919
  fulfillmentType,
3920
+ orderingSource,
3921
+ channelAccountId,
3648
3922
  },
3649
3923
  { abortEarly: false, allowUnknown: true }
3650
3924
  );
@@ -3692,6 +3966,8 @@ class Order {
3692
3966
  groupEntity,
3693
3967
  enforceDateFilter,
3694
3968
  fulfillmentType,
3969
+ orderingSource,
3970
+ channelAccountId,
3695
3971
  },
3696
3972
  { abortEarly: false, allowUnknown: false }
3697
3973
  );
@@ -3740,6 +4016,8 @@ class Order {
3740
4016
  query_params["group_entity"] = groupEntity;
3741
4017
  query_params["enforce_date_filter"] = enforceDateFilter;
3742
4018
  query_params["fulfillment_type"] = fulfillmentType;
4019
+ query_params["ordering_source"] = orderingSource;
4020
+ query_params["channel_account_id"] = channelAccountId;
3743
4021
 
3744
4022
  const xHeaders = {};
3745
4023
 
@@ -3858,6 +4136,10 @@ class Order {
3858
4136
  * Listing Orders, This is use when we want to get list of shipments or
3859
4137
  * orders by cross store or cross company or fulfilling Store (by
3860
4138
  * default), this is also depends on the login user accessType and store access
4139
+ * @param {string} [arg.orderingSource] - Filter orders by ordering source.
4140
+ * Accepts comma-separated values for multiple sources.
4141
+ * @param {string} [arg.channelAccountId] - Comma-separated channel account
4142
+ * IDs to filter orders by specific channel accounts.
3861
4143
  * @returns {Paginator<OrderPlatformModel.ShipmentInternalPlatformViewResponseSchema>}
3862
4144
  * @summary: List shipments
3863
4145
  * @description: Get a list of shipments based on the filters provided
@@ -3899,6 +4181,8 @@ class Order {
3899
4181
  groupEntity,
3900
4182
  enforceDateFilter,
3901
4183
  fulfillmentType,
4184
+ orderingSource,
4185
+ channelAccountId,
3902
4186
  } = {}) {
3903
4187
  const paginator = new Paginator();
3904
4188
  const callback = async () => {
@@ -3943,6 +4227,8 @@ class Order {
3943
4227
  groupEntity: groupEntity,
3944
4228
  enforceDateFilter: enforceDateFilter,
3945
4229
  fulfillmentType: fulfillmentType,
4230
+ orderingSource: orderingSource,
4231
+ channelAccountId: channelAccountId,
3946
4232
  });
3947
4233
  paginator.setPaginator({
3948
4234
  hasNext: data.page.has_next ? true : false,
@@ -4437,6 +4723,87 @@ class Order {
4437
4723
  return response;
4438
4724
  }
4439
4725
 
4726
+ /**
4727
+ * @param {OrderPlatformValidator.ListAccountsParam} arg - Arg object
4728
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
4729
+ * @param {import("../PlatformAPIClient").Options} - Options
4730
+ * @returns {Promise<OrderPlatformModel.AccountsList>} - Success response
4731
+ * @name listAccounts
4732
+ * @summary: Get channel accounts list
4733
+ * @description: Retrieves a paginated list of all channel accounts configured for the company. Channel accounts represent different sales channels or marketplace integrations from which orders are received. This endpoint returns account details including the account ID, company ID, and channel account name for each configured channel. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/order/listAccounts/).
4734
+ */
4735
+ async listAccounts(
4736
+ { page, size, requestHeaders } = { requestHeaders: {} },
4737
+ { responseHeaders } = { responseHeaders: false }
4738
+ ) {
4739
+ const { error } = OrderPlatformValidator.listAccounts().validate(
4740
+ {
4741
+ page,
4742
+ size,
4743
+ },
4744
+ { abortEarly: false, allowUnknown: true }
4745
+ );
4746
+ if (error) {
4747
+ return Promise.reject(new FDKClientValidationError(error));
4748
+ }
4749
+
4750
+ // Showing warrnings if extra unknown parameters are found
4751
+ const { error: warrning } = OrderPlatformValidator.listAccounts().validate(
4752
+ {
4753
+ page,
4754
+ size,
4755
+ },
4756
+ { abortEarly: false, allowUnknown: false }
4757
+ );
4758
+ if (warrning) {
4759
+ Logger({
4760
+ level: "WARN",
4761
+ message: `Parameter Validation warrnings for platform > Order > listAccounts \n ${warrning}`,
4762
+ });
4763
+ }
4764
+
4765
+ const query_params = {};
4766
+ query_params["page"] = page;
4767
+ query_params["size"] = size;
4768
+
4769
+ const xHeaders = {};
4770
+
4771
+ const response = await PlatformAPIClient.execute(
4772
+ this.config,
4773
+ "get",
4774
+ `/service/platform/order-manage/v1.0/company/${this.config.companyId}/account`,
4775
+ query_params,
4776
+ undefined,
4777
+ { ...xHeaders, ...requestHeaders },
4778
+ { responseHeaders }
4779
+ );
4780
+
4781
+ let responseData = response;
4782
+ if (responseHeaders) {
4783
+ responseData = response[0];
4784
+ }
4785
+
4786
+ const {
4787
+ error: res_error,
4788
+ } = OrderPlatformModel.AccountsList().validate(responseData, {
4789
+ abortEarly: false,
4790
+ allowUnknown: true,
4791
+ });
4792
+
4793
+ if (res_error) {
4794
+ if (this.config.options.strictResponseCheck === true) {
4795
+ return Promise.reject(new FDKResponseValidationError(res_error));
4796
+ } else {
4797
+ Logger({
4798
+ level: "WARN",
4799
+ message: `Response Validation Warnings for platform > Order > listAccounts \n ${res_error}`,
4800
+ });
4801
+ }
4802
+ }
4803
+
4804
+ return response;
4805
+ }
4806
+
4440
4807
  /**
4441
4808
  * @param {OrderPlatformValidator.OrderUpdateParam} arg - Arg object
4442
4809
  * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
@@ -4922,6 +5289,85 @@ class Order {
4922
5289
  return response;
4923
5290
  }
4924
5291
 
5292
+ /**
5293
+ * @param {OrderPlatformValidator.UpdateAccountParam} arg - Arg object
5294
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
5295
+ * @param {import("../PlatformAPIClient").Options} - Options
5296
+ * @returns {Promise<OrderPlatformModel.Account>} - Success response
5297
+ * @name updateAccount
5298
+ * @summary: Update account
5299
+ * @description: Updates the details of a specific channel account. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/order/updateAccount/).
5300
+ */
5301
+ async updateAccount(
5302
+ { channelAccountId, body, requestHeaders } = { requestHeaders: {} },
5303
+ { responseHeaders } = { responseHeaders: false }
5304
+ ) {
5305
+ const { error } = OrderPlatformValidator.updateAccount().validate(
5306
+ {
5307
+ channelAccountId,
5308
+ body,
5309
+ },
5310
+ { abortEarly: false, allowUnknown: true }
5311
+ );
5312
+ if (error) {
5313
+ return Promise.reject(new FDKClientValidationError(error));
5314
+ }
5315
+
5316
+ // Showing warrnings if extra unknown parameters are found
5317
+ const { error: warrning } = OrderPlatformValidator.updateAccount().validate(
5318
+ {
5319
+ channelAccountId,
5320
+ body,
5321
+ },
5322
+ { abortEarly: false, allowUnknown: false }
5323
+ );
5324
+ if (warrning) {
5325
+ Logger({
5326
+ level: "WARN",
5327
+ message: `Parameter Validation warrnings for platform > Order > updateAccount \n ${warrning}`,
5328
+ });
5329
+ }
5330
+
5331
+ const query_params = {};
5332
+
5333
+ const xHeaders = {};
5334
+
5335
+ const response = await PlatformAPIClient.execute(
5336
+ this.config,
5337
+ "put",
5338
+ `/service/platform/order-manage/v1.0/company/${this.config.companyId}/account/${channelAccountId}`,
5339
+ query_params,
5340
+ body,
5341
+ { ...xHeaders, ...requestHeaders },
5342
+ { responseHeaders }
5343
+ );
5344
+
5345
+ let responseData = response;
5346
+ if (responseHeaders) {
5347
+ responseData = response[0];
5348
+ }
5349
+
5350
+ const {
5351
+ error: res_error,
5352
+ } = OrderPlatformModel.Account().validate(responseData, {
5353
+ abortEarly: false,
5354
+ allowUnknown: true,
5355
+ });
5356
+
5357
+ if (res_error) {
5358
+ if (this.config.options.strictResponseCheck === true) {
5359
+ return Promise.reject(new FDKResponseValidationError(res_error));
5360
+ } else {
5361
+ Logger({
5362
+ level: "WARN",
5363
+ message: `Response Validation Warnings for platform > Order > updateAccount \n ${res_error}`,
5364
+ });
5365
+ }
5366
+ }
5367
+
5368
+ return response;
5369
+ }
5370
+
4925
5371
  /**
4926
5372
  * @param {OrderPlatformValidator.UpdateAddressParam} arg - Arg object
4927
5373
  * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`