@elasticpath/js-sdk 2.0.0 → 3.0.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.
package/dist/index.js CHANGED
@@ -1085,7 +1085,7 @@
1085
1085
  globalThis.Response = browserPonyfill.exports.Response;
1086
1086
  }
1087
1087
 
1088
- var version = "2.0.0";
1088
+ var version = "3.0.0";
1089
1089
 
1090
1090
  var LocalStorageFactory = /*#__PURE__*/function () {
1091
1091
  function LocalStorageFactory() {
@@ -1962,7 +1962,8 @@
1962
1962
  sort = _ref.sort,
1963
1963
  limit = _ref.limit,
1964
1964
  offset = _ref.offset,
1965
- filter = _ref.filter;
1965
+ filter = _ref.filter,
1966
+ useTemplateSlugs = _ref.useTemplateSlugs;
1966
1967
  var query = {};
1967
1968
  if (includes) {
1968
1969
  query.include = includes;
@@ -1979,6 +1980,9 @@
1979
1980
  if (filter) {
1980
1981
  query.filter = filter;
1981
1982
  }
1983
+ if (useTemplateSlugs) {
1984
+ query.useTemplateSlugs = useTemplateSlugs;
1985
+ }
1982
1986
  return Object.keys(query).map(function (k) {
1983
1987
  return formatQueryString(k, query[k]);
1984
1988
  }).join('&');
@@ -1989,7 +1993,7 @@
1989
1993
  }).join('&');
1990
1994
  }
1991
1995
  function buildURL(endpoint, params) {
1992
- if (params.includes || params.sort || params.limit || params.offset || params.filter) {
1996
+ if (params.includes || params.sort || params.limit || params.offset || params.filter || params.useTemplateSlugs) {
1993
1997
  var paramsString = buildQueryParams(params);
1994
1998
  return "".concat(endpoint, "?").concat(paramsString);
1995
1999
  }
@@ -2655,6 +2659,28 @@
2655
2659
  }];
2656
2660
  return this.request.send("".concat(this.endpoint, "/").concat(this.cartId, "/relationships/customers"), 'POST', body, token);
2657
2661
  }
2662
+ }, {
2663
+ key: "AddAccountAssociation",
2664
+ value: function AddAccountAssociation(accountId, token) {
2665
+ var body = [{
2666
+ type: 'account',
2667
+ id: accountId
2668
+ }];
2669
+ return this.request.send("".concat(this.endpoint, "/").concat(this.cartId, "/relationships/accounts"), 'POST', body, undefined, this, true, null, token ? {
2670
+ 'EP-ACCOUNT-MANAGEMENT-AUTHENTICATION-TOKEN': token
2671
+ } : undefined);
2672
+ }
2673
+ }, {
2674
+ key: "RemoveAccountAssociation",
2675
+ value: function RemoveAccountAssociation(accountId, token) {
2676
+ var body = [{
2677
+ type: 'account',
2678
+ id: accountId
2679
+ }];
2680
+ return this.request.send("".concat(this.endpoint, "/").concat(this.cartId, "/relationships/accounts"), 'DELETE', body, undefined, this, true, null, token ? {
2681
+ 'EP-ACCOUNT-MANAGEMENT-AUTHENTICATION-TOKEN': token
2682
+ } : undefined);
2683
+ }
2658
2684
  }, {
2659
2685
  key: "RemoveItem",
2660
2686
  value: function RemoveItem(itemId) {
@@ -2997,9 +3023,10 @@
2997
3023
  }
2998
3024
  }, {
2999
3025
  key: "ExportProducts",
3000
- value: function ExportProducts(filter) {
3026
+ value: function ExportProducts(filter, useTemplateSlugs) {
3001
3027
  return this.request.send(buildURL("".concat(this.endpoint, "/export"), {
3002
- filter: filter
3028
+ filter: filter,
3029
+ useTemplateSlugs: useTemplateSlugs
3003
3030
  }), 'POST');
3004
3031
  }
3005
3032
  }]);
@@ -3969,6 +3996,16 @@
3969
3996
  value: function Subscriptions() {
3970
3997
  return this.request.send("".concat(this.endpoint, "/subscriptions"), 'GET');
3971
3998
  }
3999
+ }, {
4000
+ key: "UpdateSubscriptions",
4001
+ value: function UpdateSubscriptions(body) {
4002
+ return this.request.send("".concat(this.endpoint, "/subscriptions"), 'PUT', body);
4003
+ }
4004
+ }, {
4005
+ key: "Promotions",
4006
+ value: function Promotions() {
4007
+ return this.request.send("".concat(this.endpoint, "/promotions"), 'GET');
4008
+ }
3972
4009
  }]);
3973
4010
  return Settings;
3974
4011
  }();
@@ -4015,12 +4052,15 @@
4015
4052
  }, {
4016
4053
  key: "Codes",
4017
4054
  value: function Codes(promotionId) {
4055
+ var token = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
4018
4056
  var limit = this.limit,
4019
- offset = this.offset;
4057
+ offset = this.offset,
4058
+ filter = this.filter;
4020
4059
  return this.request.send(buildURL("".concat(this.endpoint, "/").concat(promotionId, "/codes"), {
4021
4060
  limit: limit,
4022
- offset: offset
4023
- }), 'GET');
4061
+ offset: offset,
4062
+ filter: filter
4063
+ }), 'GET', undefined, token, this);
4024
4064
  }
4025
4065
  }, {
4026
4066
  key: "PromotionJobs",
@@ -5305,6 +5345,20 @@
5305
5345
  value: function GetAttachedPlans(id) {
5306
5346
  return this.request.send("".concat(this.endpoint, "/").concat(id, "/plans"), 'GET');
5307
5347
  }
5348
+ }, {
5349
+ key: "AttachProrationPolicy",
5350
+ value: function AttachProrationPolicy(offeringId, body) {
5351
+ return this.request.send("".concat(this.endpoint, "/").concat(offeringId, "/relationships/proration-policies"), 'PUT', {
5352
+ data: body
5353
+ }, undefined, undefined, false);
5354
+ }
5355
+ }, {
5356
+ key: "ReplaceProducts",
5357
+ value: function ReplaceProducts(offeringId, productIds) {
5358
+ return this.request.send("".concat(this.endpoint, "/").concat(offeringId, "/products/replace"), 'PUT', {
5359
+ products: productIds
5360
+ });
5361
+ }
5308
5362
  }]);
5309
5363
  return SubscriptionOfferingsEndpoint;
5310
5364
  }(CRUDExtend);
@@ -5324,15 +5378,223 @@
5324
5378
  value: function Create(body) {
5325
5379
  return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
5326
5380
  }
5381
+ }, {
5382
+ key: "Update",
5383
+ value: function Update(id, body) {
5384
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
5385
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', body, token);
5386
+ }
5327
5387
  }, {
5328
5388
  key: "GetInvoices",
5329
5389
  value: function GetInvoices(id) {
5330
5390
  return this.request.send("".concat(this.endpoint, "/").concat(id, "/invoices"), 'GET');
5331
5391
  }
5392
+ }, {
5393
+ key: "GetAttachedProducts",
5394
+ value: function GetAttachedProducts(id) {
5395
+ return this.request.send("".concat(this.endpoint, "/").concat(id, "/products"), 'GET');
5396
+ }
5397
+ }, {
5398
+ key: "GetAttachedPlans",
5399
+ value: function GetAttachedPlans(id) {
5400
+ return this.request.send("".concat(this.endpoint, "/").concat(id, "/plans"), 'GET');
5401
+ }
5402
+ }, {
5403
+ key: "CreateState",
5404
+ value: function CreateState(id, action) {
5405
+ return this.request.send("".concat(this.endpoint, "/").concat(id, "/states"), 'POST', {
5406
+ type: 'subscription_state',
5407
+ attributes: {
5408
+ action: action
5409
+ }
5410
+ });
5411
+ }
5332
5412
  }]);
5333
5413
  return SubscriptionsEndpoint;
5334
5414
  }(CRUDExtend);
5335
5415
 
5416
+ var RulePromotionsEndpoint = /*#__PURE__*/function (_CRUDExtend) {
5417
+ _inherits(RulePromotionsEndpoint, _CRUDExtend);
5418
+ var _super = _createSuper(RulePromotionsEndpoint);
5419
+ function RulePromotionsEndpoint(endpoint) {
5420
+ var _this;
5421
+ _classCallCheck(this, RulePromotionsEndpoint);
5422
+ _this = _super.call(this, endpoint);
5423
+ _this.endpoint = 'rule-promotions';
5424
+ return _this;
5425
+ }
5426
+ _createClass(RulePromotionsEndpoint, [{
5427
+ key: "Create",
5428
+ value: function Create(body) {
5429
+ return this.request.send(this.endpoint, 'POST', _objectSpread2(_objectSpread2({}, body), {}, {
5430
+ type: 'rule_promotion'
5431
+ }));
5432
+ }
5433
+ }, {
5434
+ key: "Update",
5435
+ value: function Update(id, body) {
5436
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
5437
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', _objectSpread2(_objectSpread2({}, body), {}, {
5438
+ type: 'rule_promotion'
5439
+ }), token);
5440
+ }
5441
+ }, {
5442
+ key: "Codes",
5443
+ value: function Codes(promotionId) {
5444
+ var token = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
5445
+ var limit = this.limit,
5446
+ offset = this.offset,
5447
+ filter = this.filter;
5448
+ return this.request.send(buildURL("".concat(this.endpoint, "/").concat(promotionId, "/codes"), {
5449
+ limit: limit,
5450
+ offset: offset,
5451
+ filter: filter
5452
+ }), 'GET', undefined, token, this);
5453
+ }
5454
+ }, {
5455
+ key: "AddCodes",
5456
+ value: function AddCodes(promotionId, codes) {
5457
+ return this.request.send("".concat(this.endpoint, "/").concat(promotionId, "/codes"), 'POST', {
5458
+ type: 'promotion_codes',
5459
+ codes: codes
5460
+ });
5461
+ }
5462
+ }, {
5463
+ key: "DeleteCode",
5464
+ value: function DeleteCode(promotionId, codeId) {
5465
+ return this.request.send("".concat(this.endpoint, "/").concat(promotionId, "/codes/").concat(codeId), 'DELETE');
5466
+ }
5467
+ }, {
5468
+ key: "DeleteCodes",
5469
+ value: function DeleteCodes(promotionId, codes) {
5470
+ return this.request.send("".concat(this.endpoint, "/").concat(promotionId, "/codes"), 'DELETE', {
5471
+ type: 'promotion_codes',
5472
+ codes: codes
5473
+ });
5474
+ }
5475
+ }]);
5476
+ return RulePromotionsEndpoint;
5477
+ }(CRUDExtend);
5478
+
5479
+ var SubscriptionSubscribersEndpoint = /*#__PURE__*/function (_CRUDExtend) {
5480
+ _inherits(SubscriptionSubscribersEndpoint, _CRUDExtend);
5481
+ var _super = _createSuper(SubscriptionSubscribersEndpoint);
5482
+ function SubscriptionSubscribersEndpoint(endpoint) {
5483
+ var _this;
5484
+ _classCallCheck(this, SubscriptionSubscribersEndpoint);
5485
+ _this = _super.call(this, endpoint);
5486
+ _this.endpoint = 'subscriptions/subscribers';
5487
+ return _this;
5488
+ }
5489
+ _createClass(SubscriptionSubscribersEndpoint, [{
5490
+ key: "Create",
5491
+ value: function Create(body) {
5492
+ return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
5493
+ }
5494
+ }, {
5495
+ key: "Update",
5496
+ value: function Update(id, body) {
5497
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
5498
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', _objectSpread2({}, body), token);
5499
+ }
5500
+ }]);
5501
+ return SubscriptionSubscribersEndpoint;
5502
+ }(CRUDExtend);
5503
+
5504
+ var SubscriptionJobsEndpoint = /*#__PURE__*/function (_CRUDExtend) {
5505
+ _inherits(SubscriptionJobsEndpoint, _CRUDExtend);
5506
+ var _super = _createSuper(SubscriptionJobsEndpoint);
5507
+ function SubscriptionJobsEndpoint(endpoint) {
5508
+ var _this;
5509
+ _classCallCheck(this, SubscriptionJobsEndpoint);
5510
+ _this = _super.call(this, endpoint);
5511
+ _this.endpoint = 'subscriptions/jobs';
5512
+ return _this;
5513
+ }
5514
+ _createClass(SubscriptionJobsEndpoint, [{
5515
+ key: "Create",
5516
+ value: function Create(body) {
5517
+ return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
5518
+ }
5519
+ }]);
5520
+ return SubscriptionJobsEndpoint;
5521
+ }(CRUDExtend);
5522
+
5523
+ var SubscriptionSchedulesEndpoint = /*#__PURE__*/function (_CRUDExtend) {
5524
+ _inherits(SubscriptionSchedulesEndpoint, _CRUDExtend);
5525
+ var _super = _createSuper(SubscriptionSchedulesEndpoint);
5526
+ function SubscriptionSchedulesEndpoint(endpoint) {
5527
+ var _this;
5528
+ _classCallCheck(this, SubscriptionSchedulesEndpoint);
5529
+ _this = _super.call(this, endpoint);
5530
+ _this.endpoint = 'subscriptions/schedules';
5531
+ return _this;
5532
+ }
5533
+ _createClass(SubscriptionSchedulesEndpoint, [{
5534
+ key: "Create",
5535
+ value: function Create(body) {
5536
+ return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
5537
+ }
5538
+ }, {
5539
+ key: "Update",
5540
+ value: function Update(id, body) {
5541
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
5542
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', _objectSpread2({}, body), token);
5543
+ }
5544
+ }]);
5545
+ return SubscriptionSchedulesEndpoint;
5546
+ }(CRUDExtend);
5547
+
5548
+ var SubscriptionDunningRulesEndpoint = /*#__PURE__*/function (_CRUDExtend) {
5549
+ _inherits(SubscriptionDunningRulesEndpoint, _CRUDExtend);
5550
+ var _super = _createSuper(SubscriptionDunningRulesEndpoint);
5551
+ function SubscriptionDunningRulesEndpoint(endpoint) {
5552
+ var _this;
5553
+ _classCallCheck(this, SubscriptionDunningRulesEndpoint);
5554
+ _this = _super.call(this, endpoint);
5555
+ _this.endpoint = 'subscriptions/dunning-rules';
5556
+ return _this;
5557
+ }
5558
+ _createClass(SubscriptionDunningRulesEndpoint, [{
5559
+ key: "Create",
5560
+ value: function Create(body) {
5561
+ return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
5562
+ }
5563
+ }, {
5564
+ key: "Update",
5565
+ value: function Update(id, body) {
5566
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
5567
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', _objectSpread2({}, body), token);
5568
+ }
5569
+ }]);
5570
+ return SubscriptionDunningRulesEndpoint;
5571
+ }(CRUDExtend);
5572
+
5573
+ var SubscriptionProrationPoliciesEndpoint = /*#__PURE__*/function (_CRUDExtend) {
5574
+ _inherits(SubscriptionProrationPoliciesEndpoint, _CRUDExtend);
5575
+ var _super = _createSuper(SubscriptionProrationPoliciesEndpoint);
5576
+ function SubscriptionProrationPoliciesEndpoint(endpoint) {
5577
+ var _this;
5578
+ _classCallCheck(this, SubscriptionProrationPoliciesEndpoint);
5579
+ _this = _super.call(this, endpoint);
5580
+ _this.endpoint = 'subscriptions/proration-policies';
5581
+ return _this;
5582
+ }
5583
+ _createClass(SubscriptionProrationPoliciesEndpoint, [{
5584
+ key: "Create",
5585
+ value: function Create(body) {
5586
+ return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
5587
+ }
5588
+ }, {
5589
+ key: "Update",
5590
+ value: function Update(id, body) {
5591
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
5592
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', _objectSpread2({}, body), token);
5593
+ }
5594
+ }]);
5595
+ return SubscriptionProrationPoliciesEndpoint;
5596
+ }(CRUDExtend);
5597
+
5336
5598
  var Nodes$1 = /*#__PURE__*/function (_CRUDExtend) {
5337
5599
  _inherits(Nodes, _CRUDExtend);
5338
5600
  var _super = _createSuper(Nodes);
@@ -5528,11 +5790,6 @@
5528
5790
  filter: filter
5529
5791
  }), 'GET', undefined, token, this);
5530
5792
  }
5531
-
5532
- /**
5533
- * @deprecated The method should not be used. Instead, use
5534
- * @function GetCatalogProducts
5535
- */
5536
5793
  }, {
5537
5794
  key: "GetProductsInCatalogRelease",
5538
5795
  value: function GetProductsInCatalogRelease(_ref12) {
@@ -6069,6 +6326,96 @@
6069
6326
  return ShopperCatalogEndpoint;
6070
6327
  }(ShopperCatalogQuery);
6071
6328
 
6329
+ var CustomApisEndpoint = /*#__PURE__*/function (_CRUDExtend) {
6330
+ _inherits(CustomApisEndpoint, _CRUDExtend);
6331
+ var _super = _createSuper(CustomApisEndpoint);
6332
+ function CustomApisEndpoint(endpoint) {
6333
+ var _this;
6334
+ _classCallCheck(this, CustomApisEndpoint);
6335
+ _this = _super.call(this, endpoint);
6336
+ _this.endpoint = 'settings/extensions/custom-apis';
6337
+ return _this;
6338
+ }
6339
+ _createClass(CustomApisEndpoint, [{
6340
+ key: "Create",
6341
+ value: function Create(body) {
6342
+ return this.request.send(this.endpoint, 'POST', body);
6343
+ }
6344
+ }, {
6345
+ key: "Update",
6346
+ value: function Update(id, body) {
6347
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', body);
6348
+ }
6349
+ }, {
6350
+ key: "GetFields",
6351
+ value: function GetFields(customApiId) {
6352
+ var limit = this.limit,
6353
+ offset = this.offset,
6354
+ sort = this.sort;
6355
+ return this.request.send(buildURL("".concat(this.endpoint, "/").concat(customApiId, "/fields"), {
6356
+ limit: limit,
6357
+ offset: offset,
6358
+ sort: sort
6359
+ }), 'GET');
6360
+ }
6361
+ }, {
6362
+ key: "GetField",
6363
+ value: function GetField(customApiId, customApiFieldId) {
6364
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/fields/").concat(customApiFieldId), 'GET');
6365
+ }
6366
+ }, {
6367
+ key: "CreateField",
6368
+ value: function CreateField(customApiId, body) {
6369
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/fields"), 'POST', body);
6370
+ }
6371
+ }, {
6372
+ key: "UpdateField",
6373
+ value: function UpdateField(customApiId, customApiFieldId, body) {
6374
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/fields/").concat(customApiFieldId), 'PUT', body);
6375
+ }
6376
+ }, {
6377
+ key: "DeleteField",
6378
+ value: function DeleteField(customApiId, customApiFieldId) {
6379
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/fields/").concat(customApiFieldId), 'DELETE');
6380
+ }
6381
+ }, {
6382
+ key: "GetEntries",
6383
+ value: function GetEntries(customApiId) {
6384
+ var limit = this.limit,
6385
+ offset = this.offset,
6386
+ sort = this.sort,
6387
+ filter = this.filter;
6388
+ return this.request.send(buildURL("".concat(this.endpoint, "/").concat(customApiId, "/entries"), {
6389
+ limit: limit,
6390
+ offset: offset,
6391
+ sort: sort,
6392
+ filter: filter
6393
+ }), 'GET');
6394
+ }
6395
+ }, {
6396
+ key: "GetEntry",
6397
+ value: function GetEntry(customApiId, customApiEntryId) {
6398
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/entries/").concat(customApiEntryId), 'GET');
6399
+ }
6400
+ }, {
6401
+ key: "CreateEntry",
6402
+ value: function CreateEntry(customApiId, body) {
6403
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/entries"), 'POST', body);
6404
+ }
6405
+ }, {
6406
+ key: "UpdateEntry",
6407
+ value: function UpdateEntry(customApiId, customApiEntryId, body) {
6408
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/entries/").concat(customApiEntryId), 'PUT', body);
6409
+ }
6410
+ }, {
6411
+ key: "DeleteEntry",
6412
+ value: function DeleteEntry(customApiId, customApiEntryId) {
6413
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/entries/").concat(customApiEntryId), 'DELETE');
6414
+ }
6415
+ }]);
6416
+ return CustomApisEndpoint;
6417
+ }(CRUDExtend);
6418
+
6072
6419
  var ElasticPath = /*#__PURE__*/function () {
6073
6420
  function ElasticPath(config) {
6074
6421
  _classCallCheck(this, ElasticPath);
@@ -6130,6 +6477,13 @@
6130
6477
  this.SubscriptionOfferings = new SubscriptionOfferingsEndpoint(config);
6131
6478
  this.OneTimePasswordTokenRequest = new OneTimePasswordTokenRequestEndpoint(config);
6132
6479
  this.Subscriptions = new SubscriptionsEndpoint(config);
6480
+ this.RulePromotions = new RulePromotionsEndpoint(config);
6481
+ this.SubscriptionSubscribers = new SubscriptionSubscribersEndpoint(config);
6482
+ this.SubscriptionJobs = new SubscriptionJobsEndpoint(config);
6483
+ this.SubscriptionSchedules = new SubscriptionSchedulesEndpoint(config);
6484
+ this.CustomApis = new CustomApisEndpoint(config);
6485
+ this.SubscriptionDunningRules = new SubscriptionDunningRulesEndpoint(config);
6486
+ this.SubscriptionProrationPolicies = new SubscriptionProrationPoliciesEndpoint(config);
6133
6487
  }
6134
6488
 
6135
6489
  // Expose `Cart` class on ElasticPath class
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elasticpath/js-sdk",
3
3
  "description": "SDK for the Elastic Path eCommerce API",
4
- "version": "2.0.0",
4
+ "version": "3.0.0",
5
5
  "homepage": "https://github.com/elasticpath/js-sdk",
6
6
  "author": "Elastic Path (https://elasticpath.com/)",
7
7
  "files": [