@elasticpath/js-sdk 2.0.0 → 3.0.1

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.cjs.js CHANGED
@@ -530,7 +530,7 @@ if (!globalThis.fetch) {
530
530
  globalThis.Response = fetch$1.Response;
531
531
  }
532
532
 
533
- var version = "2.0.0";
533
+ var version = "3.0.1";
534
534
 
535
535
  var LocalStorageFactory = /*#__PURE__*/function () {
536
536
  function LocalStorageFactory() {
@@ -805,7 +805,8 @@ function buildQueryParams(_ref) {
805
805
  sort = _ref.sort,
806
806
  limit = _ref.limit,
807
807
  offset = _ref.offset,
808
- filter = _ref.filter;
808
+ filter = _ref.filter,
809
+ useTemplateSlugs = _ref.useTemplateSlugs;
809
810
  var query = {};
810
811
  if (includes) {
811
812
  query.include = includes;
@@ -822,6 +823,9 @@ function buildQueryParams(_ref) {
822
823
  if (filter) {
823
824
  query.filter = filter;
824
825
  }
826
+ if (useTemplateSlugs) {
827
+ query.useTemplateSlugs = useTemplateSlugs;
828
+ }
825
829
  return Object.keys(query).map(function (k) {
826
830
  return formatQueryString(k, query[k]);
827
831
  }).join('&');
@@ -832,7 +836,7 @@ function formatQueryParams(query) {
832
836
  }).join('&');
833
837
  }
834
838
  function buildURL(endpoint, params) {
835
- if (params.includes || params.sort || params.limit || params.offset || params.filter) {
839
+ if (params.includes || params.sort || params.limit || params.offset || params.filter || params.useTemplateSlugs) {
836
840
  var paramsString = buildQueryParams(params);
837
841
  return "".concat(endpoint, "?").concat(paramsString);
838
842
  }
@@ -1498,6 +1502,28 @@ var CartEndpoint = /*#__PURE__*/function (_BaseExtend) {
1498
1502
  }];
1499
1503
  return this.request.send("".concat(this.endpoint, "/").concat(this.cartId, "/relationships/customers"), 'POST', body, token);
1500
1504
  }
1505
+ }, {
1506
+ key: "AddAccountAssociation",
1507
+ value: function AddAccountAssociation(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"), 'POST', body, undefined, this, true, null, token ? {
1513
+ 'EP-ACCOUNT-MANAGEMENT-AUTHENTICATION-TOKEN': token
1514
+ } : undefined);
1515
+ }
1516
+ }, {
1517
+ key: "RemoveAccountAssociation",
1518
+ value: function RemoveAccountAssociation(accountId, token) {
1519
+ var body = [{
1520
+ type: 'account',
1521
+ id: accountId
1522
+ }];
1523
+ return this.request.send("".concat(this.endpoint, "/").concat(this.cartId, "/relationships/accounts"), 'DELETE', body, undefined, this, true, null, token ? {
1524
+ 'EP-ACCOUNT-MANAGEMENT-AUTHENTICATION-TOKEN': token
1525
+ } : undefined);
1526
+ }
1501
1527
  }, {
1502
1528
  key: "RemoveItem",
1503
1529
  value: function RemoveItem(itemId) {
@@ -1840,9 +1866,10 @@ var PCMEndpoint = /*#__PURE__*/function (_CRUDExtend) {
1840
1866
  }
1841
1867
  }, {
1842
1868
  key: "ExportProducts",
1843
- value: function ExportProducts(filter) {
1869
+ value: function ExportProducts(filter, useTemplateSlugs) {
1844
1870
  return this.request.send(buildURL("".concat(this.endpoint, "/export"), {
1845
- filter: filter
1871
+ filter: filter,
1872
+ useTemplateSlugs: useTemplateSlugs
1846
1873
  }), 'POST');
1847
1874
  }
1848
1875
  }]);
@@ -2808,6 +2835,16 @@ var Settings = /*#__PURE__*/function () {
2808
2835
  value: function Subscriptions() {
2809
2836
  return this.request.send("".concat(this.endpoint, "/subscriptions"), 'GET');
2810
2837
  }
2838
+ }, {
2839
+ key: "UpdateSubscriptions",
2840
+ value: function UpdateSubscriptions(body) {
2841
+ return this.request.send("".concat(this.endpoint, "/subscriptions"), 'PUT', body);
2842
+ }
2843
+ }, {
2844
+ key: "Promotions",
2845
+ value: function Promotions() {
2846
+ return this.request.send("".concat(this.endpoint, "/promotions"), 'GET');
2847
+ }
2811
2848
  }]);
2812
2849
  return Settings;
2813
2850
  }();
@@ -2854,12 +2891,15 @@ var PromotionsEndpoint = /*#__PURE__*/function (_CRUDExtend) {
2854
2891
  }, {
2855
2892
  key: "Codes",
2856
2893
  value: function Codes(promotionId) {
2894
+ var token = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2857
2895
  var limit = this.limit,
2858
- offset = this.offset;
2896
+ offset = this.offset,
2897
+ filter = this.filter;
2859
2898
  return this.request.send(buildURL("".concat(this.endpoint, "/").concat(promotionId, "/codes"), {
2860
2899
  limit: limit,
2861
- offset: offset
2862
- }), 'GET');
2900
+ offset: offset,
2901
+ filter: filter
2902
+ }), 'GET', undefined, token, this);
2863
2903
  }
2864
2904
  }, {
2865
2905
  key: "PromotionJobs",
@@ -4144,6 +4184,20 @@ var SubscriptionOfferingsEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4144
4184
  value: function GetAttachedPlans(id) {
4145
4185
  return this.request.send("".concat(this.endpoint, "/").concat(id, "/plans"), 'GET');
4146
4186
  }
4187
+ }, {
4188
+ key: "AttachProrationPolicy",
4189
+ value: function AttachProrationPolicy(offeringId, body) {
4190
+ return this.request.send("".concat(this.endpoint, "/").concat(offeringId, "/relationships/proration-policies"), 'PUT', {
4191
+ data: body
4192
+ }, undefined, undefined, false);
4193
+ }
4194
+ }, {
4195
+ key: "ReplaceProducts",
4196
+ value: function ReplaceProducts(offeringId, productIds) {
4197
+ return this.request.send("".concat(this.endpoint, "/").concat(offeringId, "/products/replace"), 'PUT', {
4198
+ products: productIds
4199
+ });
4200
+ }
4147
4201
  }]);
4148
4202
  return SubscriptionOfferingsEndpoint;
4149
4203
  }(CRUDExtend);
@@ -4163,15 +4217,223 @@ var SubscriptionsEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4163
4217
  value: function Create(body) {
4164
4218
  return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
4165
4219
  }
4220
+ }, {
4221
+ key: "Update",
4222
+ value: function Update(id, body) {
4223
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4224
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', body, token);
4225
+ }
4166
4226
  }, {
4167
4227
  key: "GetInvoices",
4168
4228
  value: function GetInvoices(id) {
4169
4229
  return this.request.send("".concat(this.endpoint, "/").concat(id, "/invoices"), 'GET');
4170
4230
  }
4231
+ }, {
4232
+ key: "GetAttachedProducts",
4233
+ value: function GetAttachedProducts(id) {
4234
+ return this.request.send("".concat(this.endpoint, "/").concat(id, "/products"), 'GET');
4235
+ }
4236
+ }, {
4237
+ key: "GetAttachedPlans",
4238
+ value: function GetAttachedPlans(id) {
4239
+ return this.request.send("".concat(this.endpoint, "/").concat(id, "/plans"), 'GET');
4240
+ }
4241
+ }, {
4242
+ key: "CreateState",
4243
+ value: function CreateState(id, action) {
4244
+ return this.request.send("".concat(this.endpoint, "/").concat(id, "/states"), 'POST', {
4245
+ type: 'subscription_state',
4246
+ attributes: {
4247
+ action: action
4248
+ }
4249
+ });
4250
+ }
4171
4251
  }]);
4172
4252
  return SubscriptionsEndpoint;
4173
4253
  }(CRUDExtend);
4174
4254
 
4255
+ var RulePromotionsEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4256
+ _inherits(RulePromotionsEndpoint, _CRUDExtend);
4257
+ var _super = _createSuper(RulePromotionsEndpoint);
4258
+ function RulePromotionsEndpoint(endpoint) {
4259
+ var _this;
4260
+ _classCallCheck(this, RulePromotionsEndpoint);
4261
+ _this = _super.call(this, endpoint);
4262
+ _this.endpoint = 'rule-promotions';
4263
+ return _this;
4264
+ }
4265
+ _createClass(RulePromotionsEndpoint, [{
4266
+ key: "Create",
4267
+ value: function Create(body) {
4268
+ return this.request.send(this.endpoint, 'POST', _objectSpread2(_objectSpread2({}, body), {}, {
4269
+ type: 'rule_promotion'
4270
+ }));
4271
+ }
4272
+ }, {
4273
+ key: "Update",
4274
+ value: function Update(id, body) {
4275
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4276
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', _objectSpread2(_objectSpread2({}, body), {}, {
4277
+ type: 'rule_promotion'
4278
+ }), token);
4279
+ }
4280
+ }, {
4281
+ key: "Codes",
4282
+ value: function Codes(promotionId) {
4283
+ var token = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
4284
+ var limit = this.limit,
4285
+ offset = this.offset,
4286
+ filter = this.filter;
4287
+ return this.request.send(buildURL("".concat(this.endpoint, "/").concat(promotionId, "/codes"), {
4288
+ limit: limit,
4289
+ offset: offset,
4290
+ filter: filter
4291
+ }), 'GET', undefined, token, this);
4292
+ }
4293
+ }, {
4294
+ key: "AddCodes",
4295
+ value: function AddCodes(promotionId, codes) {
4296
+ return this.request.send("".concat(this.endpoint, "/").concat(promotionId, "/codes"), 'POST', {
4297
+ type: 'promotion_codes',
4298
+ codes: codes
4299
+ });
4300
+ }
4301
+ }, {
4302
+ key: "DeleteCode",
4303
+ value: function DeleteCode(promotionId, codeId) {
4304
+ return this.request.send("".concat(this.endpoint, "/").concat(promotionId, "/codes/").concat(codeId), 'DELETE');
4305
+ }
4306
+ }, {
4307
+ key: "DeleteCodes",
4308
+ value: function DeleteCodes(promotionId, codes) {
4309
+ return this.request.send("".concat(this.endpoint, "/").concat(promotionId, "/codes"), 'DELETE', {
4310
+ type: 'promotion_codes',
4311
+ codes: codes
4312
+ });
4313
+ }
4314
+ }]);
4315
+ return RulePromotionsEndpoint;
4316
+ }(CRUDExtend);
4317
+
4318
+ var SubscriptionSubscribersEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4319
+ _inherits(SubscriptionSubscribersEndpoint, _CRUDExtend);
4320
+ var _super = _createSuper(SubscriptionSubscribersEndpoint);
4321
+ function SubscriptionSubscribersEndpoint(endpoint) {
4322
+ var _this;
4323
+ _classCallCheck(this, SubscriptionSubscribersEndpoint);
4324
+ _this = _super.call(this, endpoint);
4325
+ _this.endpoint = 'subscriptions/subscribers';
4326
+ return _this;
4327
+ }
4328
+ _createClass(SubscriptionSubscribersEndpoint, [{
4329
+ key: "Create",
4330
+ value: function Create(body) {
4331
+ return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
4332
+ }
4333
+ }, {
4334
+ key: "Update",
4335
+ value: function Update(id, body) {
4336
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4337
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', _objectSpread2({}, body), token);
4338
+ }
4339
+ }]);
4340
+ return SubscriptionSubscribersEndpoint;
4341
+ }(CRUDExtend);
4342
+
4343
+ var SubscriptionJobsEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4344
+ _inherits(SubscriptionJobsEndpoint, _CRUDExtend);
4345
+ var _super = _createSuper(SubscriptionJobsEndpoint);
4346
+ function SubscriptionJobsEndpoint(endpoint) {
4347
+ var _this;
4348
+ _classCallCheck(this, SubscriptionJobsEndpoint);
4349
+ _this = _super.call(this, endpoint);
4350
+ _this.endpoint = 'subscriptions/jobs';
4351
+ return _this;
4352
+ }
4353
+ _createClass(SubscriptionJobsEndpoint, [{
4354
+ key: "Create",
4355
+ value: function Create(body) {
4356
+ return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
4357
+ }
4358
+ }]);
4359
+ return SubscriptionJobsEndpoint;
4360
+ }(CRUDExtend);
4361
+
4362
+ var SubscriptionSchedulesEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4363
+ _inherits(SubscriptionSchedulesEndpoint, _CRUDExtend);
4364
+ var _super = _createSuper(SubscriptionSchedulesEndpoint);
4365
+ function SubscriptionSchedulesEndpoint(endpoint) {
4366
+ var _this;
4367
+ _classCallCheck(this, SubscriptionSchedulesEndpoint);
4368
+ _this = _super.call(this, endpoint);
4369
+ _this.endpoint = 'subscriptions/schedules';
4370
+ return _this;
4371
+ }
4372
+ _createClass(SubscriptionSchedulesEndpoint, [{
4373
+ key: "Create",
4374
+ value: function Create(body) {
4375
+ return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
4376
+ }
4377
+ }, {
4378
+ key: "Update",
4379
+ value: function Update(id, body) {
4380
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4381
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', _objectSpread2({}, body), token);
4382
+ }
4383
+ }]);
4384
+ return SubscriptionSchedulesEndpoint;
4385
+ }(CRUDExtend);
4386
+
4387
+ var SubscriptionDunningRulesEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4388
+ _inherits(SubscriptionDunningRulesEndpoint, _CRUDExtend);
4389
+ var _super = _createSuper(SubscriptionDunningRulesEndpoint);
4390
+ function SubscriptionDunningRulesEndpoint(endpoint) {
4391
+ var _this;
4392
+ _classCallCheck(this, SubscriptionDunningRulesEndpoint);
4393
+ _this = _super.call(this, endpoint);
4394
+ _this.endpoint = 'subscriptions/dunning-rules';
4395
+ return _this;
4396
+ }
4397
+ _createClass(SubscriptionDunningRulesEndpoint, [{
4398
+ key: "Create",
4399
+ value: function Create(body) {
4400
+ return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
4401
+ }
4402
+ }, {
4403
+ key: "Update",
4404
+ value: function Update(id, body) {
4405
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4406
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', _objectSpread2({}, body), token);
4407
+ }
4408
+ }]);
4409
+ return SubscriptionDunningRulesEndpoint;
4410
+ }(CRUDExtend);
4411
+
4412
+ var SubscriptionProrationPoliciesEndpoint = /*#__PURE__*/function (_CRUDExtend) {
4413
+ _inherits(SubscriptionProrationPoliciesEndpoint, _CRUDExtend);
4414
+ var _super = _createSuper(SubscriptionProrationPoliciesEndpoint);
4415
+ function SubscriptionProrationPoliciesEndpoint(endpoint) {
4416
+ var _this;
4417
+ _classCallCheck(this, SubscriptionProrationPoliciesEndpoint);
4418
+ _this = _super.call(this, endpoint);
4419
+ _this.endpoint = 'subscriptions/proration-policies';
4420
+ return _this;
4421
+ }
4422
+ _createClass(SubscriptionProrationPoliciesEndpoint, [{
4423
+ key: "Create",
4424
+ value: function Create(body) {
4425
+ return this.request.send(this.endpoint, 'POST', _objectSpread2({}, body));
4426
+ }
4427
+ }, {
4428
+ key: "Update",
4429
+ value: function Update(id, body) {
4430
+ var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4431
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', _objectSpread2({}, body), token);
4432
+ }
4433
+ }]);
4434
+ return SubscriptionProrationPoliciesEndpoint;
4435
+ }(CRUDExtend);
4436
+
4175
4437
  var Nodes$1 = /*#__PURE__*/function (_CRUDExtend) {
4176
4438
  _inherits(Nodes, _CRUDExtend);
4177
4439
  var _super = _createSuper(Nodes);
@@ -4367,11 +4629,6 @@ var Products$1 = /*#__PURE__*/function (_CRUDExtend2) {
4367
4629
  filter: filter
4368
4630
  }), 'GET', undefined, token, this);
4369
4631
  }
4370
-
4371
- /**
4372
- * @deprecated The method should not be used. Instead, use
4373
- * @function GetCatalogProducts
4374
- */
4375
4632
  }, {
4376
4633
  key: "GetProductsInCatalogRelease",
4377
4634
  value: function GetProductsInCatalogRelease(_ref12) {
@@ -4908,6 +5165,96 @@ var ShopperCatalogEndpoint = /*#__PURE__*/function (_ShopperCatalogQuery4) {
4908
5165
  return ShopperCatalogEndpoint;
4909
5166
  }(ShopperCatalogQuery);
4910
5167
 
5168
+ var CustomApisEndpoint = /*#__PURE__*/function (_CRUDExtend) {
5169
+ _inherits(CustomApisEndpoint, _CRUDExtend);
5170
+ var _super = _createSuper(CustomApisEndpoint);
5171
+ function CustomApisEndpoint(endpoint) {
5172
+ var _this;
5173
+ _classCallCheck(this, CustomApisEndpoint);
5174
+ _this = _super.call(this, endpoint);
5175
+ _this.endpoint = 'settings/extensions/custom-apis';
5176
+ return _this;
5177
+ }
5178
+ _createClass(CustomApisEndpoint, [{
5179
+ key: "Create",
5180
+ value: function Create(body) {
5181
+ return this.request.send(this.endpoint, 'POST', body);
5182
+ }
5183
+ }, {
5184
+ key: "Update",
5185
+ value: function Update(id, body) {
5186
+ return this.request.send("".concat(this.endpoint, "/").concat(id), 'PUT', body);
5187
+ }
5188
+ }, {
5189
+ key: "GetFields",
5190
+ value: function GetFields(customApiId) {
5191
+ var limit = this.limit,
5192
+ offset = this.offset,
5193
+ sort = this.sort;
5194
+ return this.request.send(buildURL("".concat(this.endpoint, "/").concat(customApiId, "/fields"), {
5195
+ limit: limit,
5196
+ offset: offset,
5197
+ sort: sort
5198
+ }), 'GET');
5199
+ }
5200
+ }, {
5201
+ key: "GetField",
5202
+ value: function GetField(customApiId, customApiFieldId) {
5203
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/fields/").concat(customApiFieldId), 'GET');
5204
+ }
5205
+ }, {
5206
+ key: "CreateField",
5207
+ value: function CreateField(customApiId, body) {
5208
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/fields"), 'POST', body);
5209
+ }
5210
+ }, {
5211
+ key: "UpdateField",
5212
+ value: function UpdateField(customApiId, customApiFieldId, body) {
5213
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/fields/").concat(customApiFieldId), 'PUT', body);
5214
+ }
5215
+ }, {
5216
+ key: "DeleteField",
5217
+ value: function DeleteField(customApiId, customApiFieldId) {
5218
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/fields/").concat(customApiFieldId), 'DELETE');
5219
+ }
5220
+ }, {
5221
+ key: "GetEntries",
5222
+ value: function GetEntries(customApiId) {
5223
+ var limit = this.limit,
5224
+ offset = this.offset,
5225
+ sort = this.sort,
5226
+ filter = this.filter;
5227
+ return this.request.send(buildURL("".concat(this.endpoint, "/").concat(customApiId, "/entries"), {
5228
+ limit: limit,
5229
+ offset: offset,
5230
+ sort: sort,
5231
+ filter: filter
5232
+ }), 'GET');
5233
+ }
5234
+ }, {
5235
+ key: "GetEntry",
5236
+ value: function GetEntry(customApiId, customApiEntryId) {
5237
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/entries/").concat(customApiEntryId), 'GET');
5238
+ }
5239
+ }, {
5240
+ key: "CreateEntry",
5241
+ value: function CreateEntry(customApiId, body) {
5242
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/entries"), 'POST', body);
5243
+ }
5244
+ }, {
5245
+ key: "UpdateEntry",
5246
+ value: function UpdateEntry(customApiId, customApiEntryId, body) {
5247
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/entries/").concat(customApiEntryId), 'PUT', body);
5248
+ }
5249
+ }, {
5250
+ key: "DeleteEntry",
5251
+ value: function DeleteEntry(customApiId, customApiEntryId) {
5252
+ return this.request.send("".concat(this.endpoint, "/").concat(customApiId, "/entries/").concat(customApiEntryId), 'DELETE');
5253
+ }
5254
+ }]);
5255
+ return CustomApisEndpoint;
5256
+ }(CRUDExtend);
5257
+
4911
5258
  var ElasticPath = /*#__PURE__*/function () {
4912
5259
  function ElasticPath(config) {
4913
5260
  _classCallCheck(this, ElasticPath);
@@ -4969,6 +5316,13 @@ var ElasticPath = /*#__PURE__*/function () {
4969
5316
  this.SubscriptionOfferings = new SubscriptionOfferingsEndpoint(config);
4970
5317
  this.OneTimePasswordTokenRequest = new OneTimePasswordTokenRequestEndpoint(config);
4971
5318
  this.Subscriptions = new SubscriptionsEndpoint(config);
5319
+ this.RulePromotions = new RulePromotionsEndpoint(config);
5320
+ this.SubscriptionSubscribers = new SubscriptionSubscribersEndpoint(config);
5321
+ this.SubscriptionJobs = new SubscriptionJobsEndpoint(config);
5322
+ this.SubscriptionSchedules = new SubscriptionSchedulesEndpoint(config);
5323
+ this.CustomApis = new CustomApisEndpoint(config);
5324
+ this.SubscriptionDunningRules = new SubscriptionDunningRulesEndpoint(config);
5325
+ this.SubscriptionProrationPolicies = new SubscriptionProrationPoliciesEndpoint(config);
4972
5326
  }
4973
5327
 
4974
5328
  // Expose `Cart` class on ElasticPath class