@wix/stores 1.0.27 → 1.0.29

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