@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.esm.js CHANGED
@@ -519,7 +519,7 @@ if (!globalThis.fetch) {
519
519
  globalThis.Response = Response;
520
520
  }
521
521
 
522
- var version = "2.0.0";
522
+ var version = "3.0.0";
523
523
 
524
524
  var LocalStorageFactory = /*#__PURE__*/function () {
525
525
  function LocalStorageFactory() {
@@ -794,7 +794,8 @@ function buildQueryParams(_ref) {
794
794
  sort = _ref.sort,
795
795
  limit = _ref.limit,
796
796
  offset = _ref.offset,
797
- filter = _ref.filter;
797
+ filter = _ref.filter,
798
+ useTemplateSlugs = _ref.useTemplateSlugs;
798
799
  var query = {};
799
800
  if (includes) {
800
801
  query.include = includes;
@@ -811,6 +812,9 @@ function buildQueryParams(_ref) {
811
812
  if (filter) {
812
813
  query.filter = filter;
813
814
  }
815
+ if (useTemplateSlugs) {
816
+ query.useTemplateSlugs = useTemplateSlugs;
817
+ }
814
818
  return Object.keys(query).map(function (k) {
815
819
  return formatQueryString(k, query[k]);
816
820
  }).join('&');
@@ -821,7 +825,7 @@ function formatQueryParams(query) {
821
825
  }).join('&');
822
826
  }
823
827
  function buildURL(endpoint, params) {
824
- if (params.includes || params.sort || params.limit || params.offset || params.filter) {
828
+ if (params.includes || params.sort || params.limit || params.offset || params.filter || params.useTemplateSlugs) {
825
829
  var paramsString = buildQueryParams(params);
826
830
  return "".concat(endpoint, "?").concat(paramsString);
827
831
  }
@@ -1487,6 +1491,28 @@ var CartEndpoint = /*#__PURE__*/function (_BaseExtend) {
1487
1491
  }];
1488
1492
  return this.request.send("".concat(this.endpoint, "/").concat(this.cartId, "/relationships/customers"), 'POST', body, token);
1489
1493
  }
1494
+ }, {
1495
+ key: "AddAccountAssociation",
1496
+ value: function AddAccountAssociation(accountId, token) {
1497
+ var body = [{
1498
+ type: 'account',
1499
+ id: accountId
1500
+ }];
1501
+ return this.request.send("".concat(this.endpoint, "/").concat(this.cartId, "/relationships/accounts"), 'POST', body, undefined, this, true, null, token ? {
1502
+ 'EP-ACCOUNT-MANAGEMENT-AUTHENTICATION-TOKEN': token
1503
+ } : undefined);
1504
+ }
1505
+ }, {
1506
+ key: "RemoveAccountAssociation",
1507
+ value: function RemoveAccountAssociation(accountId, token) {
1508
+ var body = [{
1509
+ type: 'account',
1510
+ id: accountId
1511
+ }];
1512
+ return this.request.send("".concat(this.endpoint, "/").concat(this.cartId, "/relationships/accounts"), 'DELETE', body, undefined, this, true, null, token ? {
1513
+ 'EP-ACCOUNT-MANAGEMENT-AUTHENTICATION-TOKEN': token
1514
+ } : undefined);
1515
+ }
1490
1516
  }, {
1491
1517
  key: "RemoveItem",
1492
1518
  value: function RemoveItem(itemId) {
@@ -1829,9 +1855,10 @@ var PCMEndpoint = /*#__PURE__*/function (_CRUDExtend) {
1829
1855
  }
1830
1856
  }, {
1831
1857
  key: "ExportProducts",
1832
- value: function ExportProducts(filter) {
1858
+ value: function ExportProducts(filter, useTemplateSlugs) {
1833
1859
  return this.request.send(buildURL("".concat(this.endpoint, "/export"), {
1834
- filter: filter
1860
+ filter: filter,
1861
+ useTemplateSlugs: useTemplateSlugs
1835
1862
  }), 'POST');
1836
1863
  }
1837
1864
  }]);
@@ -2797,6 +2824,16 @@ var Settings = /*#__PURE__*/function () {
2797
2824
  value: function Subscriptions() {
2798
2825
  return this.request.send("".concat(this.endpoint, "/subscriptions"), 'GET');
2799
2826
  }
2827
+ }, {
2828
+ key: "UpdateSubscriptions",
2829
+ value: function UpdateSubscriptions(body) {
2830
+ return this.request.send("".concat(this.endpoint, "/subscriptions"), 'PUT', body);
2831
+ }
2832
+ }, {
2833
+ key: "Promotions",
2834
+ value: function Promotions() {
2835
+ return this.request.send("".concat(this.endpoint, "/promotions"), 'GET');
2836
+ }
2800
2837
  }]);
2801
2838
  return Settings;
2802
2839
  }();
@@ -2843,12 +2880,15 @@ var PromotionsEndpoint = /*#__PURE__*/function (_CRUDExtend) {
2843
2880
  }, {
2844
2881
  key: "Codes",
2845
2882
  value: function Codes(promotionId) {
2883
+ var token = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2846
2884
  var limit = this.limit,
2847
- offset = this.offset;
2885
+ offset = this.offset,
2886
+ filter = this.filter;
2848
2887
  return this.request.send(buildURL("".concat(this.endpoint, "/").concat(promotionId, "/codes"), {
2849
2888
  limit: limit,
2850
- offset: offset
2851
- }), 'GET');
2889
+ offset: offset,
2890
+ filter: filter
2891
+ }), 'GET', undefined, token, this);
2852
2892
  }
2853
2893
  }, {
2854
2894
  key: "PromotionJobs",
@@ -4133,6 +4173,20 @@ var SubscriptionOfferingsEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4133
4173
  value: function GetAttachedPlans(id) {
4134
4174
  return this.request.send("".concat(this.endpoint, "/").concat(id, "/plans"), 'GET');
4135
4175
  }
4176
+ }, {
4177
+ key: "AttachProrationPolicy",
4178
+ value: function AttachProrationPolicy(offeringId, body) {
4179
+ return this.request.send("".concat(this.endpoint, "/").concat(offeringId, "/relationships/proration-policies"), 'PUT', {
4180
+ data: body
4181
+ }, undefined, undefined, false);
4182
+ }
4183
+ }, {
4184
+ key: "ReplaceProducts",
4185
+ value: function ReplaceProducts(offeringId, productIds) {
4186
+ return this.request.send("".concat(this.endpoint, "/").concat(offeringId, "/products/replace"), 'PUT', {
4187
+ products: productIds
4188
+ });
4189
+ }
4136
4190
  }]);
4137
4191
  return SubscriptionOfferingsEndpoint;
4138
4192
  }(CRUDExtend);
@@ -4152,15 +4206,223 @@ var SubscriptionsEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4152
4206
  value: function Create(body) {
4153
4207
  return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
4154
4208
  }
4209
+ }, {
4210
+ key: "Update",
4211
+ value: function Update(id, body) {
4212
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4213
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', body, token);
4214
+ }
4155
4215
  }, {
4156
4216
  key: "GetInvoices",
4157
4217
  value: function GetInvoices(id) {
4158
4218
  return this.request.send("".concat(this.endpoint, "/").concat(id, "/invoices"), 'GET');
4159
4219
  }
4220
+ }, {
4221
+ key: "GetAttachedProducts",
4222
+ value: function GetAttachedProducts(id) {
4223
+ return this.request.send("".concat(this.endpoint, "/").concat(id, "/products"), 'GET');
4224
+ }
4225
+ }, {
4226
+ key: "GetAttachedPlans",
4227
+ value: function GetAttachedPlans(id) {
4228
+ return this.request.send("".concat(this.endpoint, "/").concat(id, "/plans"), 'GET');
4229
+ }
4230
+ }, {
4231
+ key: "CreateState",
4232
+ value: function CreateState(id, action) {
4233
+ return this.request.send("".concat(this.endpoint, "/").concat(id, "/states"), 'POST', {
4234
+ type: 'subscription_state',
4235
+ attributes: {
4236
+ action: action
4237
+ }
4238
+ });
4239
+ }
4160
4240
  }]);
4161
4241
  return SubscriptionsEndpoint;
4162
4242
  }(CRUDExtend);
4163
4243
 
4244
+ var RulePromotionsEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4245
+ _inherits(RulePromotionsEndpoint, _CRUDExtend);
4246
+ var _super = _createSuper(RulePromotionsEndpoint);
4247
+ function RulePromotionsEndpoint(endpoint) {
4248
+ var _this;
4249
+ _classCallCheck(this, RulePromotionsEndpoint);
4250
+ _this = _super.call(this, endpoint);
4251
+ _this.endpoint = 'rule-promotions';
4252
+ return _this;
4253
+ }
4254
+ _createClass(RulePromotionsEndpoint, [{
4255
+ key: "Create",
4256
+ value: function Create(body) {
4257
+ return this.request.send(this.endpoint, 'POST', _objectSpread2(_objectSpread2({}, body), {}, {
4258
+ type: 'rule_promotion'
4259
+ }));
4260
+ }
4261
+ }, {
4262
+ key: "Update",
4263
+ value: function Update(id, body) {
4264
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4265
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', _objectSpread2(_objectSpread2({}, body), {}, {
4266
+ type: 'rule_promotion'
4267
+ }), token);
4268
+ }
4269
+ }, {
4270
+ key: "Codes",
4271
+ value: function Codes(promotionId) {
4272
+ var token = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
4273
+ var limit = this.limit,
4274
+ offset = this.offset,
4275
+ filter = this.filter;
4276
+ return this.request.send(buildURL("".concat(this.endpoint, "/").concat(promotionId, "/codes"), {
4277
+ limit: limit,
4278
+ offset: offset,
4279
+ filter: filter
4280
+ }), 'GET', undefined, token, this);
4281
+ }
4282
+ }, {
4283
+ key: "AddCodes",
4284
+ value: function AddCodes(promotionId, codes) {
4285
+ return this.request.send("".concat(this.endpoint, "/").concat(promotionId, "/codes"), 'POST', {
4286
+ type: 'promotion_codes',
4287
+ codes: codes
4288
+ });
4289
+ }
4290
+ }, {
4291
+ key: "DeleteCode",
4292
+ value: function DeleteCode(promotionId, codeId) {
4293
+ return this.request.send("".concat(this.endpoint, "/").concat(promotionId, "/codes/").concat(codeId), 'DELETE');
4294
+ }
4295
+ }, {
4296
+ key: "DeleteCodes",
4297
+ value: function DeleteCodes(promotionId, codes) {
4298
+ return this.request.send("".concat(this.endpoint, "/").concat(promotionId, "/codes"), 'DELETE', {
4299
+ type: 'promotion_codes',
4300
+ codes: codes
4301
+ });
4302
+ }
4303
+ }]);
4304
+ return RulePromotionsEndpoint;
4305
+ }(CRUDExtend);
4306
+
4307
+ var SubscriptionSubscribersEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4308
+ _inherits(SubscriptionSubscribersEndpoint, _CRUDExtend);
4309
+ var _super = _createSuper(SubscriptionSubscribersEndpoint);
4310
+ function SubscriptionSubscribersEndpoint(endpoint) {
4311
+ var _this;
4312
+ _classCallCheck(this, SubscriptionSubscribersEndpoint);
4313
+ _this = _super.call(this, endpoint);
4314
+ _this.endpoint = 'subscriptions/subscribers';
4315
+ return _this;
4316
+ }
4317
+ _createClass(SubscriptionSubscribersEndpoint, [{
4318
+ key: "Create",
4319
+ value: function Create(body) {
4320
+ return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
4321
+ }
4322
+ }, {
4323
+ key: "Update",
4324
+ value: function Update(id, body) {
4325
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4326
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', _objectSpread2({}, body), token);
4327
+ }
4328
+ }]);
4329
+ return SubscriptionSubscribersEndpoint;
4330
+ }(CRUDExtend);
4331
+
4332
+ var SubscriptionJobsEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4333
+ _inherits(SubscriptionJobsEndpoint, _CRUDExtend);
4334
+ var _super = _createSuper(SubscriptionJobsEndpoint);
4335
+ function SubscriptionJobsEndpoint(endpoint) {
4336
+ var _this;
4337
+ _classCallCheck(this, SubscriptionJobsEndpoint);
4338
+ _this = _super.call(this, endpoint);
4339
+ _this.endpoint = 'subscriptions/jobs';
4340
+ return _this;
4341
+ }
4342
+ _createClass(SubscriptionJobsEndpoint, [{
4343
+ key: "Create",
4344
+ value: function Create(body) {
4345
+ return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
4346
+ }
4347
+ }]);
4348
+ return SubscriptionJobsEndpoint;
4349
+ }(CRUDExtend);
4350
+
4351
+ var SubscriptionSchedulesEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4352
+ _inherits(SubscriptionSchedulesEndpoint, _CRUDExtend);
4353
+ var _super = _createSuper(SubscriptionSchedulesEndpoint);
4354
+ function SubscriptionSchedulesEndpoint(endpoint) {
4355
+ var _this;
4356
+ _classCallCheck(this, SubscriptionSchedulesEndpoint);
4357
+ _this = _super.call(this, endpoint);
4358
+ _this.endpoint = 'subscriptions/schedules';
4359
+ return _this;
4360
+ }
4361
+ _createClass(SubscriptionSchedulesEndpoint, [{
4362
+ key: "Create",
4363
+ value: function Create(body) {
4364
+ return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
4365
+ }
4366
+ }, {
4367
+ key: "Update",
4368
+ value: function Update(id, body) {
4369
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4370
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', _objectSpread2({}, body), token);
4371
+ }
4372
+ }]);
4373
+ return SubscriptionSchedulesEndpoint;
4374
+ }(CRUDExtend);
4375
+
4376
+ var SubscriptionDunningRulesEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4377
+ _inherits(SubscriptionDunningRulesEndpoint, _CRUDExtend);
4378
+ var _super = _createSuper(SubscriptionDunningRulesEndpoint);
4379
+ function SubscriptionDunningRulesEndpoint(endpoint) {
4380
+ var _this;
4381
+ _classCallCheck(this, SubscriptionDunningRulesEndpoint);
4382
+ _this = _super.call(this, endpoint);
4383
+ _this.endpoint = 'subscriptions/dunning-rules';
4384
+ return _this;
4385
+ }
4386
+ _createClass(SubscriptionDunningRulesEndpoint, [{
4387
+ key: "Create",
4388
+ value: function Create(body) {
4389
+ return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
4390
+ }
4391
+ }, {
4392
+ key: "Update",
4393
+ value: function Update(id, body) {
4394
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4395
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', _objectSpread2({}, body), token);
4396
+ }
4397
+ }]);
4398
+ return SubscriptionDunningRulesEndpoint;
4399
+ }(CRUDExtend);
4400
+
4401
+ var SubscriptionProrationPoliciesEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4402
+ _inherits(SubscriptionProrationPoliciesEndpoint, _CRUDExtend);
4403
+ var _super = _createSuper(SubscriptionProrationPoliciesEndpoint);
4404
+ function SubscriptionProrationPoliciesEndpoint(endpoint) {
4405
+ var _this;
4406
+ _classCallCheck(this, SubscriptionProrationPoliciesEndpoint);
4407
+ _this = _super.call(this, endpoint);
4408
+ _this.endpoint = 'subscriptions/proration-policies';
4409
+ return _this;
4410
+ }
4411
+ _createClass(SubscriptionProrationPoliciesEndpoint, [{
4412
+ key: "Create",
4413
+ value: function Create(body) {
4414
+ return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
4415
+ }
4416
+ }, {
4417
+ key: "Update",
4418
+ value: function Update(id, body) {
4419
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4420
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', _objectSpread2({}, body), token);
4421
+ }
4422
+ }]);
4423
+ return SubscriptionProrationPoliciesEndpoint;
4424
+ }(CRUDExtend);
4425
+
4164
4426
  var Nodes$1 = /*#__PURE__*/function (_CRUDExtend) {
4165
4427
  _inherits(Nodes, _CRUDExtend);
4166
4428
  var _super = _createSuper(Nodes);
@@ -4356,11 +4618,6 @@ var Products$1 = /*#__PURE__*/function (_CRUDExtend2) {
4356
4618
  filter: filter
4357
4619
  }), 'GET', undefined, token, this);
4358
4620
  }
4359
-
4360
- /**
4361
- * @deprecated The method should not be used. Instead, use
4362
- * @function GetCatalogProducts
4363
- */
4364
4621
  }, {
4365
4622
  key: "GetProductsInCatalogRelease",
4366
4623
  value: function GetProductsInCatalogRelease(_ref12) {
@@ -4897,6 +5154,96 @@ var ShopperCatalogEndpoint = /*#__PURE__*/function (_ShopperCatalogQuery4) {
4897
5154
  return ShopperCatalogEndpoint;
4898
5155
  }(ShopperCatalogQuery);
4899
5156
 
5157
+ var CustomApisEndpoint = /*#__PURE__*/function (_CRUDExtend) {
5158
+ _inherits(CustomApisEndpoint, _CRUDExtend);
5159
+ var _super = _createSuper(CustomApisEndpoint);
5160
+ function CustomApisEndpoint(endpoint) {
5161
+ var _this;
5162
+ _classCallCheck(this, CustomApisEndpoint);
5163
+ _this = _super.call(this, endpoint);
5164
+ _this.endpoint = 'settings/extensions/custom-apis';
5165
+ return _this;
5166
+ }
5167
+ _createClass(CustomApisEndpoint, [{
5168
+ key: "Create",
5169
+ value: function Create(body) {
5170
+ return this.request.send(this.endpoint, 'POST', body);
5171
+ }
5172
+ }, {
5173
+ key: "Update",
5174
+ value: function Update(id, body) {
5175
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', body);
5176
+ }
5177
+ }, {
5178
+ key: "GetFields",
5179
+ value: function GetFields(customApiId) {
5180
+ var limit = this.limit,
5181
+ offset = this.offset,
5182
+ sort = this.sort;
5183
+ return this.request.send(buildURL("".concat(this.endpoint, "/").concat(customApiId, "/fields"), {
5184
+ limit: limit,
5185
+ offset: offset,
5186
+ sort: sort
5187
+ }), 'GET');
5188
+ }
5189
+ }, {
5190
+ key: "GetField",
5191
+ value: function GetField(customApiId, customApiFieldId) {
5192
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/fields/").concat(customApiFieldId), 'GET');
5193
+ }
5194
+ }, {
5195
+ key: "CreateField",
5196
+ value: function CreateField(customApiId, body) {
5197
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/fields"), 'POST', body);
5198
+ }
5199
+ }, {
5200
+ key: "UpdateField",
5201
+ value: function UpdateField(customApiId, customApiFieldId, body) {
5202
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/fields/").concat(customApiFieldId), 'PUT', body);
5203
+ }
5204
+ }, {
5205
+ key: "DeleteField",
5206
+ value: function DeleteField(customApiId, customApiFieldId) {
5207
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/fields/").concat(customApiFieldId), 'DELETE');
5208
+ }
5209
+ }, {
5210
+ key: "GetEntries",
5211
+ value: function GetEntries(customApiId) {
5212
+ var limit = this.limit,
5213
+ offset = this.offset,
5214
+ sort = this.sort,
5215
+ filter = this.filter;
5216
+ return this.request.send(buildURL("".concat(this.endpoint, "/").concat(customApiId, "/entries"), {
5217
+ limit: limit,
5218
+ offset: offset,
5219
+ sort: sort,
5220
+ filter: filter
5221
+ }), 'GET');
5222
+ }
5223
+ }, {
5224
+ key: "GetEntry",
5225
+ value: function GetEntry(customApiId, customApiEntryId) {
5226
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/entries/").concat(customApiEntryId), 'GET');
5227
+ }
5228
+ }, {
5229
+ key: "CreateEntry",
5230
+ value: function CreateEntry(customApiId, body) {
5231
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/entries"), 'POST', body);
5232
+ }
5233
+ }, {
5234
+ key: "UpdateEntry",
5235
+ value: function UpdateEntry(customApiId, customApiEntryId, body) {
5236
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/entries/").concat(customApiEntryId), 'PUT', body);
5237
+ }
5238
+ }, {
5239
+ key: "DeleteEntry",
5240
+ value: function DeleteEntry(customApiId, customApiEntryId) {
5241
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/entries/").concat(customApiEntryId), 'DELETE');
5242
+ }
5243
+ }]);
5244
+ return CustomApisEndpoint;
5245
+ }(CRUDExtend);
5246
+
4900
5247
  var ElasticPath = /*#__PURE__*/function () {
4901
5248
  function ElasticPath(config) {
4902
5249
  _classCallCheck(this, ElasticPath);
@@ -4958,6 +5305,13 @@ var ElasticPath = /*#__PURE__*/function () {
4958
5305
  this.SubscriptionOfferings = new SubscriptionOfferingsEndpoint(config);
4959
5306
  this.OneTimePasswordTokenRequest = new OneTimePasswordTokenRequestEndpoint(config);
4960
5307
  this.Subscriptions = new SubscriptionsEndpoint(config);
5308
+ this.RulePromotions = new RulePromotionsEndpoint(config);
5309
+ this.SubscriptionSubscribers = new SubscriptionSubscribersEndpoint(config);
5310
+ this.SubscriptionJobs = new SubscriptionJobsEndpoint(config);
5311
+ this.SubscriptionSchedules = new SubscriptionSchedulesEndpoint(config);
5312
+ this.CustomApis = new CustomApisEndpoint(config);
5313
+ this.SubscriptionDunningRules = new SubscriptionDunningRulesEndpoint(config);
5314
+ this.SubscriptionProrationPolicies = new SubscriptionProrationPoliciesEndpoint(config);
4961
5315
  }
4962
5316
 
4963
5317
  // Expose `Cart` class on ElasticPath class