@wix/stores 1.0.26 → 1.0.28

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 (39) hide show
  1. package/build/cjs/index.d.ts +1 -0
  2. package/build/cjs/index.js +2 -1
  3. package/build/cjs/index.js.map +1 -1
  4. package/build/cjs/src/stores-catalog-v1-product-products.universal.d.ts +3 -0
  5. package/build/cjs/src/stores-catalog-v1-product-products.universal.js.map +1 -1
  6. package/build/cjs/src/stores-catalog-v1-product.types.d.ts +3 -0
  7. package/build/cjs/src/stores-catalog-v1-product.types.js.map +1 -1
  8. package/build/cjs/src/stores-v1-subscription-option.http.d.ts +49 -0
  9. package/build/cjs/src/stores-v1-subscription-option.http.js +414 -0
  10. package/build/cjs/src/stores-v1-subscription-option.http.js.map +1 -0
  11. package/build/cjs/src/stores-v1-subscription-option.public.d.ts +16 -0
  12. package/build/cjs/src/stores-v1-subscription-option.public.js +80 -0
  13. package/build/cjs/src/stores-v1-subscription-option.public.js.map +1 -0
  14. package/build/cjs/src/stores-v1-subscription-option.types.d.ts +296 -0
  15. package/build/cjs/src/stores-v1-subscription-option.types.js +20 -0
  16. package/build/cjs/src/stores-v1-subscription-option.types.js.map +1 -0
  17. package/build/cjs/src/stores-v1-subscription-option.universal.d.ts +447 -0
  18. package/build/cjs/src/stores-v1-subscription-option.universal.js +738 -0
  19. package/build/cjs/src/stores-v1-subscription-option.universal.js.map +1 -0
  20. package/build/es/index.d.ts +1 -0
  21. package/build/es/index.js +1 -0
  22. package/build/es/index.js.map +1 -1
  23. package/build/es/src/stores-catalog-v1-product-products.universal.d.ts +3 -0
  24. package/build/es/src/stores-catalog-v1-product-products.universal.js.map +1 -1
  25. package/build/es/src/stores-catalog-v1-product.types.d.ts +3 -0
  26. package/build/es/src/stores-catalog-v1-product.types.js.map +1 -1
  27. package/build/es/src/stores-v1-subscription-option.http.d.ts +49 -0
  28. package/build/es/src/stores-v1-subscription-option.http.js +399 -0
  29. package/build/es/src/stores-v1-subscription-option.http.js.map +1 -0
  30. package/build/es/src/stores-v1-subscription-option.public.d.ts +16 -0
  31. package/build/es/src/stores-v1-subscription-option.public.js +63 -0
  32. package/build/es/src/stores-v1-subscription-option.public.js.map +1 -0
  33. package/build/es/src/stores-v1-subscription-option.types.d.ts +296 -0
  34. package/build/es/src/stores-v1-subscription-option.types.js +17 -0
  35. package/build/es/src/stores-v1-subscription-option.types.js.map +1 -0
  36. package/build/es/src/stores-v1-subscription-option.universal.d.ts +447 -0
  37. package/build/es/src/stores-v1-subscription-option.universal.js +704 -0
  38. package/build/es/src/stores-v1-subscription-option.universal.js.map +1 -0
  39. package/package.json +2 -2
@@ -0,0 +1,738 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.getOneTimePurchasesStatus = exports.getProductIdsForSubscriptionOption = exports.getSubscriptionOptionsForProduct = exports.getSubscriptionOption = exports.allowOneTimePurchases = exports.assignSubscriptionOptionsToProduct = exports.bulkDeleteSubscriptionOptions = exports.bulkUpdateSubscriptionOptions = exports.bulkCreateSubscriptionOptions = exports.deleteSubscriptionOption = exports.updateSubscriptionOption = exports.createSubscriptionOption = exports.DiscountType = exports.SubscriptionFrequency = exports.__debug = void 0;
32
+ const velo_1 = require("@wix/metro-runtime/velo");
33
+ const ambassadorWixStoresV1SubscriptionOption = __importStar(require("./stores-v1-subscription-option.http"));
34
+ let __verbose = false;
35
+ function __log(...args) {
36
+ __verbose && console.log(...args);
37
+ }
38
+ function __inspect(obj) {
39
+ return obj;
40
+ }
41
+ exports.__debug = {
42
+ verboseLogging: {
43
+ on: () => (__verbose = true),
44
+ off: () => (__verbose = false),
45
+ },
46
+ };
47
+ const _toVeloEntity = '$';
48
+ const _fromVeloEntity = '$';
49
+ /** Frequency unit of recurring payment */
50
+ var SubscriptionFrequency;
51
+ (function (SubscriptionFrequency) {
52
+ SubscriptionFrequency["UNDEFINED"] = "UNDEFINED";
53
+ SubscriptionFrequency["DAY"] = "DAY";
54
+ SubscriptionFrequency["WEEK"] = "WEEK";
55
+ SubscriptionFrequency["MONTH"] = "MONTH";
56
+ SubscriptionFrequency["YEAR"] = "YEAR";
57
+ })(SubscriptionFrequency = exports.SubscriptionFrequency || (exports.SubscriptionFrequency = {}));
58
+ var DiscountType;
59
+ (function (DiscountType) {
60
+ DiscountType["UNDEFINED"] = "UNDEFINED";
61
+ /** No discount */
62
+ DiscountType["AMOUNT"] = "AMOUNT";
63
+ DiscountType["PERCENT"] = "PERCENT";
64
+ })(DiscountType = exports.DiscountType || (exports.DiscountType = {}));
65
+ const _allowOneTimePurchasesRequest = {};
66
+ const _allowOneTimePurchasesResponse = {};
67
+ const _assignSubscriptionOptionsToProductRequest = {};
68
+ const _assignSubscriptionOptionsToProductResponse = {};
69
+ const _bulkCreateSubscriptionOptionsRequest = {};
70
+ const _bulkCreateSubscriptionOptionsResponse = {};
71
+ const _bulkDeleteSubscriptionOptionsRequest = {};
72
+ const _bulkDeleteSubscriptionOptionsResponse = {};
73
+ const _bulkUpdateSubscriptionOptionsRequest = {};
74
+ const _bulkUpdateSubscriptionOptionsResponse = {};
75
+ const _createSubscriptionOptionRequest = {};
76
+ const _createSubscriptionOptionResponse = {};
77
+ const _deleteSubscriptionOptionRequest = {};
78
+ const _deleteSubscriptionOptionResponse = {};
79
+ const _getOneTimePurchasesStatusRequest = {};
80
+ const _getOneTimePurchasesStatusResponse = {};
81
+ const _getProductIdsForSubscriptionOptionRequest = {};
82
+ const _getProductIdsForSubscriptionOptionResponse = {};
83
+ const _getSubscriptionOptionRequest = {};
84
+ const _getSubscriptionOptionResponse = {};
85
+ const _getSubscriptionOptionsForProductRequest = {};
86
+ const _getSubscriptionOptionsForProductResponse = {};
87
+ const _updateSubscriptionOptionRequest = {};
88
+ const _updateSubscriptionOptionResponse = {};
89
+ /**
90
+ * Creates a subscription option.
91
+ * To assign to a product, call [Assign Subscription Options to Product](https://dev.wix.com/api/rest/wix-stores/subscription-options/assign-subscription-options-to-product).
92
+ * Subscription options that are not assigned to a product will not be visible in the Wix business manager.
93
+ * @param subscriptionOption - Subscription option info.
94
+ * @public
95
+ * @documentationMaturity preview
96
+ * @requiredField subscriptionOption
97
+ * @requiredField subscriptionOption.subscriptionSettings
98
+ * @requiredField subscriptionOption.title
99
+ * @returns Newly created subscription option.
100
+ */
101
+ function createSubscriptionOption(subscriptionOption) {
102
+ var _a, _b, _c;
103
+ return __awaiter(this, arguments, void 0, function* () {
104
+ const requestTransformation = { subscriptionOption: '$[0]' };
105
+ const responseTransformation = '$.subscriptionOption';
106
+ // @ts-ignore
107
+ const { httpClient, sideEffects } = arguments[1];
108
+ const { toAmbassadorRequest } = velo_1.serializer({
109
+ rootSchema: _createSubscriptionOptionRequest,
110
+ depSchemas: {},
111
+ fqdnTransformation: {
112
+ paths: [...['subscriptionOption']],
113
+ transformation: _fromVeloEntity,
114
+ },
115
+ customTransformation: requestTransformation,
116
+ });
117
+ const { fromJSON } = velo_1.serializer({
118
+ rootSchema: _createSubscriptionOptionResponse,
119
+ depSchemas: {},
120
+ fqdnTransformation: {
121
+ paths: [...['subscriptionOption']],
122
+ transformation: _toVeloEntity,
123
+ },
124
+ customTransformation: responseTransformation,
125
+ });
126
+ const payload = toAmbassadorRequest([subscriptionOption]);
127
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.createSubscriptionOption(payload);
128
+ __log(`"CreateSubscriptionOption" sending request with: ${__inspect(reqOpts)}`);
129
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
130
+ try {
131
+ const result = yield httpClient.request(reqOpts);
132
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
133
+ return fromJSON(result.data);
134
+ }
135
+ catch (err) {
136
+ const transformedError = velo_1.transformError(err, requestTransformation, [
137
+ 'subscriptionOption',
138
+ ]);
139
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
140
+ throw transformedError;
141
+ }
142
+ });
143
+ }
144
+ exports.createSubscriptionOption = createSubscriptionOption;
145
+ /**
146
+ * Updates a subscription option.
147
+ * Only parameters passed will be updated.
148
+ * @param _id - Subscription option ID (auto-generated upon subscription option creation).
149
+ * @public
150
+ * @documentationMaturity preview
151
+ * @requiredField _id
152
+ * @requiredField subscriptionOption
153
+ * @returns Updated subscription option.
154
+ */
155
+ function updateSubscriptionOption(_id, subscriptionOption) {
156
+ var _a, _b, _c;
157
+ return __awaiter(this, arguments, void 0, function* () {
158
+ const requestTransformation = {
159
+ subscriptionOption: { '*': '$[1]', id: '$[0]' },
160
+ };
161
+ const responseTransformation = '$.subscriptionOption';
162
+ // @ts-ignore
163
+ const { httpClient, sideEffects } = arguments[2];
164
+ const { toAmbassadorRequest } = velo_1.serializer({
165
+ rootSchema: _updateSubscriptionOptionRequest,
166
+ depSchemas: {},
167
+ fqdnTransformation: {
168
+ paths: [...['subscriptionOption']],
169
+ transformation: _fromVeloEntity,
170
+ },
171
+ customTransformation: requestTransformation,
172
+ });
173
+ const { fromJSON } = velo_1.serializer({
174
+ rootSchema: _updateSubscriptionOptionResponse,
175
+ depSchemas: {},
176
+ fqdnTransformation: {
177
+ paths: [...['subscriptionOption']],
178
+ transformation: _toVeloEntity,
179
+ },
180
+ customTransformation: responseTransformation,
181
+ });
182
+ const payload = toAmbassadorRequest([_id, subscriptionOption]);
183
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.updateSubscriptionOption(payload);
184
+ __log(`"UpdateSubscriptionOption" sending request with: ${__inspect(reqOpts)}`);
185
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
186
+ try {
187
+ const result = yield httpClient.request(reqOpts);
188
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
189
+ return fromJSON(result.data);
190
+ }
191
+ catch (err) {
192
+ const transformedError = velo_1.transformError(err, requestTransformation, [
193
+ '_id',
194
+ 'subscriptionOption',
195
+ ]);
196
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
197
+ throw transformedError;
198
+ }
199
+ });
200
+ }
201
+ exports.updateSubscriptionOption = updateSubscriptionOption;
202
+ /**
203
+ * Deletes a subscription option.
204
+ * @param _id - ID of the subscription option to delete.
205
+ * @public
206
+ * @documentationMaturity preview
207
+ * @requiredField _id
208
+ */
209
+ function deleteSubscriptionOption(_id) {
210
+ var _a, _b, _c;
211
+ return __awaiter(this, arguments, void 0, function* () {
212
+ const requestTransformation = { id: '$[0]' };
213
+ const responseTransformation = '$';
214
+ // @ts-ignore
215
+ const { httpClient, sideEffects } = arguments[1];
216
+ const { toAmbassadorRequest } = velo_1.serializer({
217
+ rootSchema: _deleteSubscriptionOptionRequest,
218
+ depSchemas: {},
219
+ fqdnTransformation: {
220
+ paths: [],
221
+ transformation: _fromVeloEntity,
222
+ },
223
+ customTransformation: requestTransformation,
224
+ });
225
+ const { fromJSON } = velo_1.serializer({
226
+ rootSchema: _deleteSubscriptionOptionResponse,
227
+ depSchemas: {},
228
+ fqdnTransformation: {
229
+ paths: [],
230
+ transformation: _toVeloEntity,
231
+ },
232
+ customTransformation: responseTransformation,
233
+ });
234
+ const payload = toAmbassadorRequest([_id]);
235
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.deleteSubscriptionOption(payload);
236
+ __log(`"DeleteSubscriptionOption" sending request with: ${__inspect(reqOpts)}`);
237
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
238
+ try {
239
+ const result = yield httpClient.request(reqOpts);
240
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
241
+ return fromJSON(result.data);
242
+ }
243
+ catch (err) {
244
+ const transformedError = velo_1.transformError(err, requestTransformation, [
245
+ '_id',
246
+ ]);
247
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
248
+ throw transformedError;
249
+ }
250
+ });
251
+ }
252
+ exports.deleteSubscriptionOption = deleteSubscriptionOption;
253
+ /**
254
+ * Creates multiple subscription options (up to 100).
255
+ * To assign to a product, call [Assign Subscription Options to Product](https://dev.wix.com/api/rest/wix-stores/subscription-options/assign-subscription-options-to-product).
256
+ * Subscription options that are not assigned to a product will not be visible in the Wix business manager.
257
+ * @param subscriptionOptions - Subscription options info.
258
+ * @public
259
+ * @documentationMaturity preview
260
+ * @requiredField subscriptionOptions
261
+ * @requiredField subscriptionOptions.subscriptionSettings
262
+ * @requiredField subscriptionOptions.title
263
+ */
264
+ function bulkCreateSubscriptionOptions(subscriptionOptions) {
265
+ var _a, _b, _c;
266
+ return __awaiter(this, arguments, void 0, function* () {
267
+ const requestTransformation = { subscriptionOptions: '$[0]' };
268
+ const responseTransformation = '$';
269
+ // @ts-ignore
270
+ const { httpClient, sideEffects } = arguments[1];
271
+ const { toAmbassadorRequest } = velo_1.serializer({
272
+ rootSchema: _bulkCreateSubscriptionOptionsRequest,
273
+ depSchemas: {},
274
+ fqdnTransformation: {
275
+ paths: [...['Array#subscriptionOptions']],
276
+ transformation: _fromVeloEntity,
277
+ },
278
+ customTransformation: requestTransformation,
279
+ });
280
+ const { fromJSON } = velo_1.serializer({
281
+ rootSchema: _bulkCreateSubscriptionOptionsResponse,
282
+ depSchemas: {},
283
+ fqdnTransformation: {
284
+ paths: [...['Array#subscriptionOptions']],
285
+ transformation: _toVeloEntity,
286
+ },
287
+ customTransformation: responseTransformation,
288
+ });
289
+ const payload = toAmbassadorRequest([subscriptionOptions]);
290
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.bulkCreateSubscriptionOptions(payload);
291
+ __log(`"BulkCreateSubscriptionOptions" sending request with: ${__inspect(reqOpts)}`);
292
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
293
+ try {
294
+ const result = yield httpClient.request(reqOpts);
295
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
296
+ return fromJSON(result.data);
297
+ }
298
+ catch (err) {
299
+ const transformedError = velo_1.transformError(err, requestTransformation, [
300
+ 'subscriptionOptions',
301
+ ]);
302
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
303
+ throw transformedError;
304
+ }
305
+ });
306
+ }
307
+ exports.bulkCreateSubscriptionOptions = bulkCreateSubscriptionOptions;
308
+ /**
309
+ * Updates multiple subscription options.
310
+ * Only parameters passed will be updated.
311
+ * @param subscriptionOptions - Subscription options info. Only the passed parameters in each subscription option will be updated.
312
+ * @public
313
+ * @documentationMaturity preview
314
+ * @requiredField subscriptionOptions
315
+ * @requiredField subscriptionOptions._id
316
+ */
317
+ function bulkUpdateSubscriptionOptions(subscriptionOptions) {
318
+ var _a, _b, _c;
319
+ return __awaiter(this, arguments, void 0, function* () {
320
+ const requestTransformation = { subscriptionOptions: '$[0]' };
321
+ const responseTransformation = '$';
322
+ // @ts-ignore
323
+ const { httpClient, sideEffects } = arguments[1];
324
+ const { toAmbassadorRequest } = velo_1.serializer({
325
+ rootSchema: _bulkUpdateSubscriptionOptionsRequest,
326
+ depSchemas: {},
327
+ fqdnTransformation: {
328
+ paths: [...['Array#subscriptionOptions']],
329
+ transformation: _fromVeloEntity,
330
+ },
331
+ customTransformation: requestTransformation,
332
+ });
333
+ const { fromJSON } = velo_1.serializer({
334
+ rootSchema: _bulkUpdateSubscriptionOptionsResponse,
335
+ depSchemas: {},
336
+ fqdnTransformation: {
337
+ paths: [...['Array#subscriptionOptions']],
338
+ transformation: _toVeloEntity,
339
+ },
340
+ customTransformation: responseTransformation,
341
+ });
342
+ const payload = toAmbassadorRequest([subscriptionOptions]);
343
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.bulkUpdateSubscriptionOptions(payload);
344
+ __log(`"BulkUpdateSubscriptionOptions" sending request with: ${__inspect(reqOpts)}`);
345
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
346
+ try {
347
+ const result = yield httpClient.request(reqOpts);
348
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
349
+ return fromJSON(result.data);
350
+ }
351
+ catch (err) {
352
+ const transformedError = velo_1.transformError(err, requestTransformation, [
353
+ 'subscriptionOptions',
354
+ ]);
355
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
356
+ throw transformedError;
357
+ }
358
+ });
359
+ }
360
+ exports.bulkUpdateSubscriptionOptions = bulkUpdateSubscriptionOptions;
361
+ /**
362
+ * Deletes multiple subscription options.
363
+ * @param ids - IDs of the subscription options to delete.
364
+ * @public
365
+ * @documentationMaturity preview
366
+ * @requiredField ids
367
+ */
368
+ function bulkDeleteSubscriptionOptions(ids) {
369
+ var _a, _b, _c;
370
+ return __awaiter(this, arguments, void 0, function* () {
371
+ const requestTransformation = { ids: '$[0]' };
372
+ const responseTransformation = '$';
373
+ // @ts-ignore
374
+ const { httpClient, sideEffects } = arguments[1];
375
+ const { toAmbassadorRequest } = velo_1.serializer({
376
+ rootSchema: _bulkDeleteSubscriptionOptionsRequest,
377
+ depSchemas: {},
378
+ fqdnTransformation: {
379
+ paths: [],
380
+ transformation: _fromVeloEntity,
381
+ },
382
+ customTransformation: requestTransformation,
383
+ });
384
+ const { fromJSON } = velo_1.serializer({
385
+ rootSchema: _bulkDeleteSubscriptionOptionsResponse,
386
+ depSchemas: {},
387
+ fqdnTransformation: {
388
+ paths: [],
389
+ transformation: _toVeloEntity,
390
+ },
391
+ customTransformation: responseTransformation,
392
+ });
393
+ const payload = toAmbassadorRequest([ids]);
394
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.bulkDeleteSubscriptionOptions(payload);
395
+ __log(`"BulkDeleteSubscriptionOptions" sending request with: ${__inspect(reqOpts)}`);
396
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
397
+ try {
398
+ const result = yield httpClient.request(reqOpts);
399
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
400
+ return fromJSON(result.data);
401
+ }
402
+ catch (err) {
403
+ const transformedError = velo_1.transformError(err, requestTransformation, [
404
+ 'ids',
405
+ ]);
406
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
407
+ throw transformedError;
408
+ }
409
+ });
410
+ }
411
+ exports.bulkDeleteSubscriptionOptions = bulkDeleteSubscriptionOptions;
412
+ /**
413
+ * Assign up to 6 subscription options to a specified product.
414
+ * Pass an empty array to remove all subscription options assigned to a product.
415
+ * @param productId - Product ID.
416
+ * @public
417
+ * @documentationMaturity preview
418
+ * @requiredField productId
419
+ */
420
+ function assignSubscriptionOptionsToProduct(productId, options) {
421
+ var _a, _b, _c;
422
+ return __awaiter(this, arguments, void 0, function* () {
423
+ const requestTransformation = {
424
+ productId: '$[0]',
425
+ assignedSubscriptionOptions: '$[1].assignedSubscriptionOptions',
426
+ };
427
+ const responseTransformation = '$';
428
+ // @ts-ignore
429
+ const { httpClient, sideEffects } = arguments[2];
430
+ const { toAmbassadorRequest } = velo_1.serializer({
431
+ rootSchema: _assignSubscriptionOptionsToProductRequest,
432
+ depSchemas: {},
433
+ fqdnTransformation: {
434
+ paths: [],
435
+ transformation: _fromVeloEntity,
436
+ },
437
+ customTransformation: requestTransformation,
438
+ });
439
+ const { fromJSON } = velo_1.serializer({
440
+ rootSchema: _assignSubscriptionOptionsToProductResponse,
441
+ depSchemas: {},
442
+ fqdnTransformation: {
443
+ paths: [],
444
+ transformation: _toVeloEntity,
445
+ },
446
+ customTransformation: responseTransformation,
447
+ });
448
+ const payload = toAmbassadorRequest([productId, options]);
449
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.assignSubscriptionOptionsToProduct(payload);
450
+ __log(`"AssignSubscriptionOptionsToProduct" sending request with: ${__inspect(reqOpts)}`);
451
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
452
+ try {
453
+ const result = yield httpClient.request(reqOpts);
454
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
455
+ return fromJSON(result.data);
456
+ }
457
+ catch (err) {
458
+ const transformedError = velo_1.transformError(err, requestTransformation, [
459
+ 'productId',
460
+ 'options',
461
+ ]);
462
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
463
+ throw transformedError;
464
+ }
465
+ });
466
+ }
467
+ exports.assignSubscriptionOptionsToProduct = assignSubscriptionOptionsToProduct;
468
+ /**
469
+ * Allow for one-time purchase of a product.
470
+ * By default, product can be sold only as part of a subscription, not as a one-time purchase.
471
+ * @param productId - Product ID.
472
+ * @param allowed - Pass `true` to offer product by subscription and as one-time purchase. Pass `false` to offer product as subscription only.
473
+ * @public
474
+ * @documentationMaturity preview
475
+ * @requiredField allowed
476
+ * @requiredField productId
477
+ */
478
+ function allowOneTimePurchases(productId, allowed) {
479
+ var _a, _b, _c;
480
+ return __awaiter(this, arguments, void 0, function* () {
481
+ const requestTransformation = { productId: '$[0]', allowed: '$[1]' };
482
+ const responseTransformation = '$';
483
+ // @ts-ignore
484
+ const { httpClient, sideEffects } = arguments[2];
485
+ const { toAmbassadorRequest } = velo_1.serializer({
486
+ rootSchema: _allowOneTimePurchasesRequest,
487
+ depSchemas: {},
488
+ fqdnTransformation: {
489
+ paths: [],
490
+ transformation: _fromVeloEntity,
491
+ },
492
+ customTransformation: requestTransformation,
493
+ });
494
+ const { fromJSON } = velo_1.serializer({
495
+ rootSchema: _allowOneTimePurchasesResponse,
496
+ depSchemas: {},
497
+ fqdnTransformation: {
498
+ paths: [],
499
+ transformation: _toVeloEntity,
500
+ },
501
+ customTransformation: responseTransformation,
502
+ });
503
+ const payload = toAmbassadorRequest([productId, allowed]);
504
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.allowOneTimePurchases(payload);
505
+ __log(`"AllowOneTimePurchases" sending request with: ${__inspect(reqOpts)}`);
506
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
507
+ try {
508
+ const result = yield httpClient.request(reqOpts);
509
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
510
+ return fromJSON(result.data);
511
+ }
512
+ catch (err) {
513
+ const transformedError = velo_1.transformError(err, requestTransformation, [
514
+ 'productId',
515
+ 'allowed',
516
+ ]);
517
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
518
+ throw transformedError;
519
+ }
520
+ });
521
+ }
522
+ exports.allowOneTimePurchases = allowOneTimePurchases;
523
+ /**
524
+ * Retrieves a subscription option by ID.
525
+ * @param _id - Subscription option ID.
526
+ * @public
527
+ * @documentationMaturity preview
528
+ * @requiredField _id
529
+ * @returns Subscription option.
530
+ */
531
+ function getSubscriptionOption(_id) {
532
+ var _a, _b, _c;
533
+ return __awaiter(this, arguments, void 0, function* () {
534
+ const requestTransformation = { id: '$[0]' };
535
+ const responseTransformation = '$.subscriptionOption';
536
+ // @ts-ignore
537
+ const { httpClient, sideEffects } = arguments[1];
538
+ const { toAmbassadorRequest } = velo_1.serializer({
539
+ rootSchema: _getSubscriptionOptionRequest,
540
+ depSchemas: {},
541
+ fqdnTransformation: {
542
+ paths: [],
543
+ transformation: _fromVeloEntity,
544
+ },
545
+ customTransformation: requestTransformation,
546
+ });
547
+ const { fromJSON } = velo_1.serializer({
548
+ rootSchema: _getSubscriptionOptionResponse,
549
+ depSchemas: {},
550
+ fqdnTransformation: {
551
+ paths: [...['subscriptionOption']],
552
+ transformation: _toVeloEntity,
553
+ },
554
+ customTransformation: responseTransformation,
555
+ });
556
+ const payload = toAmbassadorRequest([_id]);
557
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.getSubscriptionOption(payload);
558
+ __log(`"GetSubscriptionOption" sending request with: ${__inspect(reqOpts)}`);
559
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
560
+ try {
561
+ const result = yield httpClient.request(reqOpts);
562
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
563
+ return fromJSON(result.data);
564
+ }
565
+ catch (err) {
566
+ const transformedError = velo_1.transformError(err, requestTransformation, [
567
+ '_id',
568
+ ]);
569
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
570
+ throw transformedError;
571
+ }
572
+ });
573
+ }
574
+ exports.getSubscriptionOption = getSubscriptionOption;
575
+ /**
576
+ * Retrieves all subscription options assigned to a specified product.
577
+ * By default, hidden subscription options are not returned. To retrieve all subscription options you must pass `includeHiddenSubscriptionOptions = true`.
578
+ * @param productId - Product ID.
579
+ * @public
580
+ * @documentationMaturity preview
581
+ * @requiredField productId
582
+ */
583
+ function getSubscriptionOptionsForProduct(productId, options) {
584
+ var _a, _b, _c;
585
+ return __awaiter(this, arguments, void 0, function* () {
586
+ const requestTransformation = {
587
+ productId: '$[0]',
588
+ includeHiddenSubscriptionOptions: '$[1].includeHiddenSubscriptionOptions',
589
+ };
590
+ const responseTransformation = '$';
591
+ // @ts-ignore
592
+ const { httpClient, sideEffects } = arguments[2];
593
+ const { toAmbassadorRequest } = velo_1.serializer({
594
+ rootSchema: _getSubscriptionOptionsForProductRequest,
595
+ depSchemas: {},
596
+ fqdnTransformation: {
597
+ paths: [],
598
+ transformation: _fromVeloEntity,
599
+ },
600
+ customTransformation: requestTransformation,
601
+ });
602
+ const { fromJSON } = velo_1.serializer({
603
+ rootSchema: _getSubscriptionOptionsForProductResponse,
604
+ depSchemas: {},
605
+ fqdnTransformation: {
606
+ paths: [],
607
+ transformation: _toVeloEntity,
608
+ },
609
+ customTransformation: responseTransformation,
610
+ });
611
+ const payload = toAmbassadorRequest([productId, options]);
612
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.getSubscriptionOptionsForProduct(payload);
613
+ __log(`"GetSubscriptionOptionsForProduct" sending request with: ${__inspect(reqOpts)}`);
614
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
615
+ try {
616
+ const result = yield httpClient.request(reqOpts);
617
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
618
+ return fromJSON(result.data);
619
+ }
620
+ catch (err) {
621
+ const transformedError = velo_1.transformError(err, requestTransformation, [
622
+ 'productId',
623
+ 'options',
624
+ ]);
625
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
626
+ throw transformedError;
627
+ }
628
+ });
629
+ }
630
+ exports.getSubscriptionOptionsForProduct = getSubscriptionOptionsForProduct;
631
+ /**
632
+ * Retrieves the IDs of products associated with a specified subscription option.
633
+ * @param _id - Subscription option ID.
634
+ * @public
635
+ * @documentationMaturity preview
636
+ * @requiredField _id
637
+ */
638
+ function getProductIdsForSubscriptionOption(_id, options) {
639
+ var _a, _b, _c;
640
+ return __awaiter(this, arguments, void 0, function* () {
641
+ const requestTransformation = {
642
+ id: '$[0]',
643
+ includeHiddenProducts: '$[1].includeHiddenProducts',
644
+ paging: '$[1].paging',
645
+ };
646
+ const responseTransformation = '$';
647
+ // @ts-ignore
648
+ const { httpClient, sideEffects } = arguments[2];
649
+ const { toAmbassadorRequest } = velo_1.serializer({
650
+ rootSchema: _getProductIdsForSubscriptionOptionRequest,
651
+ depSchemas: {},
652
+ fqdnTransformation: {
653
+ paths: [],
654
+ transformation: _fromVeloEntity,
655
+ },
656
+ customTransformation: requestTransformation,
657
+ });
658
+ const { fromJSON } = velo_1.serializer({
659
+ rootSchema: _getProductIdsForSubscriptionOptionResponse,
660
+ depSchemas: {},
661
+ fqdnTransformation: {
662
+ paths: [],
663
+ transformation: _toVeloEntity,
664
+ },
665
+ customTransformation: responseTransformation,
666
+ });
667
+ const payload = toAmbassadorRequest([_id, options]);
668
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.getProductIdsForSubscriptionOption(payload);
669
+ __log(`"GetProductIdsForSubscriptionOption" sending request with: ${__inspect(reqOpts)}`);
670
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
671
+ try {
672
+ const result = yield httpClient.request(reqOpts);
673
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
674
+ return fromJSON(result.data);
675
+ }
676
+ catch (err) {
677
+ const transformedError = velo_1.transformError(err, requestTransformation, [
678
+ '_id',
679
+ 'options',
680
+ ]);
681
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
682
+ throw transformedError;
683
+ }
684
+ });
685
+ }
686
+ exports.getProductIdsForSubscriptionOption = getProductIdsForSubscriptionOption;
687
+ /**
688
+ * Checks whether a specified product (associated with subscription options) is available for one-time purchase.
689
+ * @param productId - Product ID.
690
+ * @public
691
+ * @documentationMaturity preview
692
+ * @requiredField productId
693
+ */
694
+ function getOneTimePurchasesStatus(productId) {
695
+ var _a, _b, _c;
696
+ return __awaiter(this, arguments, void 0, function* () {
697
+ const requestTransformation = { productId: '$[0]' };
698
+ const responseTransformation = '$';
699
+ // @ts-ignore
700
+ const { httpClient, sideEffects } = arguments[1];
701
+ const { toAmbassadorRequest } = velo_1.serializer({
702
+ rootSchema: _getOneTimePurchasesStatusRequest,
703
+ depSchemas: {},
704
+ fqdnTransformation: {
705
+ paths: [],
706
+ transformation: _fromVeloEntity,
707
+ },
708
+ customTransformation: requestTransformation,
709
+ });
710
+ const { fromJSON } = velo_1.serializer({
711
+ rootSchema: _getOneTimePurchasesStatusResponse,
712
+ depSchemas: {},
713
+ fqdnTransformation: {
714
+ paths: [],
715
+ transformation: _toVeloEntity,
716
+ },
717
+ customTransformation: responseTransformation,
718
+ });
719
+ const payload = toAmbassadorRequest([productId]);
720
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.getOneTimePurchasesStatus(payload);
721
+ __log(`"GetOneTimePurchasesStatus" sending request with: ${__inspect(reqOpts)}`);
722
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
723
+ try {
724
+ const result = yield httpClient.request(reqOpts);
725
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
726
+ return fromJSON(result.data);
727
+ }
728
+ catch (err) {
729
+ const transformedError = velo_1.transformError(err, requestTransformation, [
730
+ 'productId',
731
+ ]);
732
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
733
+ throw transformedError;
734
+ }
735
+ });
736
+ }
737
+ exports.getOneTimePurchasesStatus = getOneTimePurchasesStatus;
738
+ //# sourceMappingURL=stores-v1-subscription-option.universal.js.map