@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,704 @@
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 [Assign Subscription Options to Product](https://dev.wix.com/api/rest/wix-stores/subscription-options/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
+ * @returns Updated subscription option.
131
+ */
132
+ export function updateSubscriptionOption(_id, subscriptionOption) {
133
+ var _a, _b, _c;
134
+ return __awaiter(this, arguments, void 0, function* () {
135
+ const requestTransformation = {
136
+ subscriptionOption: { '*': '$[1]', id: '$[0]' },
137
+ };
138
+ const responseTransformation = '$.subscriptionOption';
139
+ // @ts-ignore
140
+ const { httpClient, sideEffects } = arguments[2];
141
+ const { toAmbassadorRequest } = serializer({
142
+ rootSchema: _updateSubscriptionOptionRequest,
143
+ depSchemas: {},
144
+ fqdnTransformation: {
145
+ paths: [...['subscriptionOption']],
146
+ transformation: _fromVeloEntity,
147
+ },
148
+ customTransformation: requestTransformation,
149
+ });
150
+ const { fromJSON } = serializer({
151
+ rootSchema: _updateSubscriptionOptionResponse,
152
+ depSchemas: {},
153
+ fqdnTransformation: {
154
+ paths: [...['subscriptionOption']],
155
+ transformation: _toVeloEntity,
156
+ },
157
+ customTransformation: responseTransformation,
158
+ });
159
+ const payload = toAmbassadorRequest([_id, subscriptionOption]);
160
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.updateSubscriptionOption(payload);
161
+ __log(`"UpdateSubscriptionOption" sending request with: ${__inspect(reqOpts)}`);
162
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
163
+ try {
164
+ const result = yield httpClient.request(reqOpts);
165
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
166
+ return fromJSON(result.data);
167
+ }
168
+ catch (err) {
169
+ const transformedError = transformError(err, requestTransformation, [
170
+ '_id',
171
+ 'subscriptionOption',
172
+ ]);
173
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
174
+ throw transformedError;
175
+ }
176
+ });
177
+ }
178
+ /**
179
+ * Deletes a subscription option.
180
+ * @param _id - ID of the subscription option to delete.
181
+ * @public
182
+ * @documentationMaturity preview
183
+ * @requiredField _id
184
+ */
185
+ export function deleteSubscriptionOption(_id) {
186
+ var _a, _b, _c;
187
+ return __awaiter(this, arguments, void 0, function* () {
188
+ const requestTransformation = { id: '$[0]' };
189
+ const responseTransformation = '$';
190
+ // @ts-ignore
191
+ const { httpClient, sideEffects } = arguments[1];
192
+ const { toAmbassadorRequest } = serializer({
193
+ rootSchema: _deleteSubscriptionOptionRequest,
194
+ depSchemas: {},
195
+ fqdnTransformation: {
196
+ paths: [],
197
+ transformation: _fromVeloEntity,
198
+ },
199
+ customTransformation: requestTransformation,
200
+ });
201
+ const { fromJSON } = serializer({
202
+ rootSchema: _deleteSubscriptionOptionResponse,
203
+ depSchemas: {},
204
+ fqdnTransformation: {
205
+ paths: [],
206
+ transformation: _toVeloEntity,
207
+ },
208
+ customTransformation: responseTransformation,
209
+ });
210
+ const payload = toAmbassadorRequest([_id]);
211
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.deleteSubscriptionOption(payload);
212
+ __log(`"DeleteSubscriptionOption" sending request with: ${__inspect(reqOpts)}`);
213
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
214
+ try {
215
+ const result = yield httpClient.request(reqOpts);
216
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
217
+ return fromJSON(result.data);
218
+ }
219
+ catch (err) {
220
+ const transformedError = transformError(err, requestTransformation, [
221
+ '_id',
222
+ ]);
223
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
224
+ throw transformedError;
225
+ }
226
+ });
227
+ }
228
+ /**
229
+ * Creates multiple subscription options (up to 100).
230
+ * 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).
231
+ * Subscription options that are not assigned to a product will not be visible in the Wix business manager.
232
+ * @param subscriptionOptions - Subscription options info.
233
+ * @public
234
+ * @documentationMaturity preview
235
+ * @requiredField subscriptionOptions
236
+ * @requiredField subscriptionOptions.subscriptionSettings
237
+ * @requiredField subscriptionOptions.title
238
+ */
239
+ export function bulkCreateSubscriptionOptions(subscriptionOptions) {
240
+ var _a, _b, _c;
241
+ return __awaiter(this, arguments, void 0, function* () {
242
+ const requestTransformation = { subscriptionOptions: '$[0]' };
243
+ const responseTransformation = '$';
244
+ // @ts-ignore
245
+ const { httpClient, sideEffects } = arguments[1];
246
+ const { toAmbassadorRequest } = serializer({
247
+ rootSchema: _bulkCreateSubscriptionOptionsRequest,
248
+ depSchemas: {},
249
+ fqdnTransformation: {
250
+ paths: [...['Array#subscriptionOptions']],
251
+ transformation: _fromVeloEntity,
252
+ },
253
+ customTransformation: requestTransformation,
254
+ });
255
+ const { fromJSON } = serializer({
256
+ rootSchema: _bulkCreateSubscriptionOptionsResponse,
257
+ depSchemas: {},
258
+ fqdnTransformation: {
259
+ paths: [...['Array#subscriptionOptions']],
260
+ transformation: _toVeloEntity,
261
+ },
262
+ customTransformation: responseTransformation,
263
+ });
264
+ const payload = toAmbassadorRequest([subscriptionOptions]);
265
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.bulkCreateSubscriptionOptions(payload);
266
+ __log(`"BulkCreateSubscriptionOptions" sending request with: ${__inspect(reqOpts)}`);
267
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
268
+ try {
269
+ const result = yield httpClient.request(reqOpts);
270
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
271
+ return fromJSON(result.data);
272
+ }
273
+ catch (err) {
274
+ const transformedError = transformError(err, requestTransformation, [
275
+ 'subscriptionOptions',
276
+ ]);
277
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
278
+ throw transformedError;
279
+ }
280
+ });
281
+ }
282
+ /**
283
+ * Updates multiple subscription options.
284
+ * Only parameters passed will be updated.
285
+ * @param subscriptionOptions - Subscription options info. Only the passed parameters in each subscription option will be updated.
286
+ * @public
287
+ * @documentationMaturity preview
288
+ * @requiredField subscriptionOptions
289
+ * @requiredField subscriptionOptions._id
290
+ */
291
+ export function bulkUpdateSubscriptionOptions(subscriptionOptions) {
292
+ var _a, _b, _c;
293
+ return __awaiter(this, arguments, void 0, function* () {
294
+ const requestTransformation = { subscriptionOptions: '$[0]' };
295
+ const responseTransformation = '$';
296
+ // @ts-ignore
297
+ const { httpClient, sideEffects } = arguments[1];
298
+ const { toAmbassadorRequest } = serializer({
299
+ rootSchema: _bulkUpdateSubscriptionOptionsRequest,
300
+ depSchemas: {},
301
+ fqdnTransformation: {
302
+ paths: [...['Array#subscriptionOptions']],
303
+ transformation: _fromVeloEntity,
304
+ },
305
+ customTransformation: requestTransformation,
306
+ });
307
+ const { fromJSON } = serializer({
308
+ rootSchema: _bulkUpdateSubscriptionOptionsResponse,
309
+ depSchemas: {},
310
+ fqdnTransformation: {
311
+ paths: [...['Array#subscriptionOptions']],
312
+ transformation: _toVeloEntity,
313
+ },
314
+ customTransformation: responseTransformation,
315
+ });
316
+ const payload = toAmbassadorRequest([subscriptionOptions]);
317
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.bulkUpdateSubscriptionOptions(payload);
318
+ __log(`"BulkUpdateSubscriptionOptions" sending request with: ${__inspect(reqOpts)}`);
319
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
320
+ try {
321
+ const result = yield httpClient.request(reqOpts);
322
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
323
+ return fromJSON(result.data);
324
+ }
325
+ catch (err) {
326
+ const transformedError = transformError(err, requestTransformation, [
327
+ 'subscriptionOptions',
328
+ ]);
329
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
330
+ throw transformedError;
331
+ }
332
+ });
333
+ }
334
+ /**
335
+ * Deletes multiple subscription options.
336
+ * @param ids - IDs of the subscription options to delete.
337
+ * @public
338
+ * @documentationMaturity preview
339
+ * @requiredField ids
340
+ */
341
+ export function bulkDeleteSubscriptionOptions(ids) {
342
+ var _a, _b, _c;
343
+ return __awaiter(this, arguments, void 0, function* () {
344
+ const requestTransformation = { ids: '$[0]' };
345
+ const responseTransformation = '$';
346
+ // @ts-ignore
347
+ const { httpClient, sideEffects } = arguments[1];
348
+ const { toAmbassadorRequest } = serializer({
349
+ rootSchema: _bulkDeleteSubscriptionOptionsRequest,
350
+ depSchemas: {},
351
+ fqdnTransformation: {
352
+ paths: [],
353
+ transformation: _fromVeloEntity,
354
+ },
355
+ customTransformation: requestTransformation,
356
+ });
357
+ const { fromJSON } = serializer({
358
+ rootSchema: _bulkDeleteSubscriptionOptionsResponse,
359
+ depSchemas: {},
360
+ fqdnTransformation: {
361
+ paths: [],
362
+ transformation: _toVeloEntity,
363
+ },
364
+ customTransformation: responseTransformation,
365
+ });
366
+ const payload = toAmbassadorRequest([ids]);
367
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.bulkDeleteSubscriptionOptions(payload);
368
+ __log(`"BulkDeleteSubscriptionOptions" sending request with: ${__inspect(reqOpts)}`);
369
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
370
+ try {
371
+ const result = yield httpClient.request(reqOpts);
372
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
373
+ return fromJSON(result.data);
374
+ }
375
+ catch (err) {
376
+ const transformedError = transformError(err, requestTransformation, [
377
+ 'ids',
378
+ ]);
379
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
380
+ throw transformedError;
381
+ }
382
+ });
383
+ }
384
+ /**
385
+ * Assign up to 6 subscription options to a specified product.
386
+ * Pass an empty array to remove all subscription options assigned to a product.
387
+ * @param productId - Product ID.
388
+ * @public
389
+ * @documentationMaturity preview
390
+ * @requiredField productId
391
+ */
392
+ export function assignSubscriptionOptionsToProduct(productId, options) {
393
+ var _a, _b, _c;
394
+ return __awaiter(this, arguments, void 0, function* () {
395
+ const requestTransformation = {
396
+ productId: '$[0]',
397
+ assignedSubscriptionOptions: '$[1].assignedSubscriptionOptions',
398
+ };
399
+ const responseTransformation = '$';
400
+ // @ts-ignore
401
+ const { httpClient, sideEffects } = arguments[2];
402
+ const { toAmbassadorRequest } = serializer({
403
+ rootSchema: _assignSubscriptionOptionsToProductRequest,
404
+ depSchemas: {},
405
+ fqdnTransformation: {
406
+ paths: [],
407
+ transformation: _fromVeloEntity,
408
+ },
409
+ customTransformation: requestTransformation,
410
+ });
411
+ const { fromJSON } = serializer({
412
+ rootSchema: _assignSubscriptionOptionsToProductResponse,
413
+ depSchemas: {},
414
+ fqdnTransformation: {
415
+ paths: [],
416
+ transformation: _toVeloEntity,
417
+ },
418
+ customTransformation: responseTransformation,
419
+ });
420
+ const payload = toAmbassadorRequest([productId, options]);
421
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.assignSubscriptionOptionsToProduct(payload);
422
+ __log(`"AssignSubscriptionOptionsToProduct" sending request with: ${__inspect(reqOpts)}`);
423
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
424
+ try {
425
+ const result = yield httpClient.request(reqOpts);
426
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
427
+ return fromJSON(result.data);
428
+ }
429
+ catch (err) {
430
+ const transformedError = transformError(err, requestTransformation, [
431
+ 'productId',
432
+ 'options',
433
+ ]);
434
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
435
+ throw transformedError;
436
+ }
437
+ });
438
+ }
439
+ /**
440
+ * Allow for one-time purchase of a product.
441
+ * By default, product can be sold only as part of a subscription, not as a one-time purchase.
442
+ * @param productId - Product ID.
443
+ * @param allowed - Pass `true` to offer product by subscription and as one-time purchase. Pass `false` to offer product as subscription only.
444
+ * @public
445
+ * @documentationMaturity preview
446
+ * @requiredField allowed
447
+ * @requiredField productId
448
+ */
449
+ export function allowOneTimePurchases(productId, allowed) {
450
+ var _a, _b, _c;
451
+ return __awaiter(this, arguments, void 0, function* () {
452
+ const requestTransformation = { productId: '$[0]', allowed: '$[1]' };
453
+ const responseTransformation = '$';
454
+ // @ts-ignore
455
+ const { httpClient, sideEffects } = arguments[2];
456
+ const { toAmbassadorRequest } = serializer({
457
+ rootSchema: _allowOneTimePurchasesRequest,
458
+ depSchemas: {},
459
+ fqdnTransformation: {
460
+ paths: [],
461
+ transformation: _fromVeloEntity,
462
+ },
463
+ customTransformation: requestTransformation,
464
+ });
465
+ const { fromJSON } = serializer({
466
+ rootSchema: _allowOneTimePurchasesResponse,
467
+ depSchemas: {},
468
+ fqdnTransformation: {
469
+ paths: [],
470
+ transformation: _toVeloEntity,
471
+ },
472
+ customTransformation: responseTransformation,
473
+ });
474
+ const payload = toAmbassadorRequest([productId, allowed]);
475
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.allowOneTimePurchases(payload);
476
+ __log(`"AllowOneTimePurchases" sending request with: ${__inspect(reqOpts)}`);
477
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
478
+ try {
479
+ const result = yield httpClient.request(reqOpts);
480
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
481
+ return fromJSON(result.data);
482
+ }
483
+ catch (err) {
484
+ const transformedError = transformError(err, requestTransformation, [
485
+ 'productId',
486
+ 'allowed',
487
+ ]);
488
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
489
+ throw transformedError;
490
+ }
491
+ });
492
+ }
493
+ /**
494
+ * Retrieves a subscription option by ID.
495
+ * @param _id - Subscription option ID.
496
+ * @public
497
+ * @documentationMaturity preview
498
+ * @requiredField _id
499
+ * @returns Subscription option.
500
+ */
501
+ export function getSubscriptionOption(_id) {
502
+ var _a, _b, _c;
503
+ return __awaiter(this, arguments, void 0, function* () {
504
+ const requestTransformation = { id: '$[0]' };
505
+ const responseTransformation = '$.subscriptionOption';
506
+ // @ts-ignore
507
+ const { httpClient, sideEffects } = arguments[1];
508
+ const { toAmbassadorRequest } = serializer({
509
+ rootSchema: _getSubscriptionOptionRequest,
510
+ depSchemas: {},
511
+ fqdnTransformation: {
512
+ paths: [],
513
+ transformation: _fromVeloEntity,
514
+ },
515
+ customTransformation: requestTransformation,
516
+ });
517
+ const { fromJSON } = serializer({
518
+ rootSchema: _getSubscriptionOptionResponse,
519
+ depSchemas: {},
520
+ fqdnTransformation: {
521
+ paths: [...['subscriptionOption']],
522
+ transformation: _toVeloEntity,
523
+ },
524
+ customTransformation: responseTransformation,
525
+ });
526
+ const payload = toAmbassadorRequest([_id]);
527
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.getSubscriptionOption(payload);
528
+ __log(`"GetSubscriptionOption" sending request with: ${__inspect(reqOpts)}`);
529
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
530
+ try {
531
+ const result = yield httpClient.request(reqOpts);
532
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
533
+ return fromJSON(result.data);
534
+ }
535
+ catch (err) {
536
+ const transformedError = transformError(err, requestTransformation, [
537
+ '_id',
538
+ ]);
539
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
540
+ throw transformedError;
541
+ }
542
+ });
543
+ }
544
+ /**
545
+ * Retrieves all subscription options assigned to a specified product.
546
+ * By default, hidden subscription options are not returned. To retrieve all subscription options you must pass `includeHiddenSubscriptionOptions = true`.
547
+ * @param productId - Product ID.
548
+ * @public
549
+ * @documentationMaturity preview
550
+ * @requiredField productId
551
+ */
552
+ export function getSubscriptionOptionsForProduct(productId, options) {
553
+ var _a, _b, _c;
554
+ return __awaiter(this, arguments, void 0, function* () {
555
+ const requestTransformation = {
556
+ productId: '$[0]',
557
+ includeHiddenSubscriptionOptions: '$[1].includeHiddenSubscriptionOptions',
558
+ };
559
+ const responseTransformation = '$';
560
+ // @ts-ignore
561
+ const { httpClient, sideEffects } = arguments[2];
562
+ const { toAmbassadorRequest } = serializer({
563
+ rootSchema: _getSubscriptionOptionsForProductRequest,
564
+ depSchemas: {},
565
+ fqdnTransformation: {
566
+ paths: [],
567
+ transformation: _fromVeloEntity,
568
+ },
569
+ customTransformation: requestTransformation,
570
+ });
571
+ const { fromJSON } = serializer({
572
+ rootSchema: _getSubscriptionOptionsForProductResponse,
573
+ depSchemas: {},
574
+ fqdnTransformation: {
575
+ paths: [],
576
+ transformation: _toVeloEntity,
577
+ },
578
+ customTransformation: responseTransformation,
579
+ });
580
+ const payload = toAmbassadorRequest([productId, options]);
581
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.getSubscriptionOptionsForProduct(payload);
582
+ __log(`"GetSubscriptionOptionsForProduct" sending request with: ${__inspect(reqOpts)}`);
583
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
584
+ try {
585
+ const result = yield httpClient.request(reqOpts);
586
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
587
+ return fromJSON(result.data);
588
+ }
589
+ catch (err) {
590
+ const transformedError = transformError(err, requestTransformation, [
591
+ 'productId',
592
+ 'options',
593
+ ]);
594
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
595
+ throw transformedError;
596
+ }
597
+ });
598
+ }
599
+ /**
600
+ * Retrieves the IDs of products associated with a specified subscription option.
601
+ * @param _id - Subscription option ID.
602
+ * @public
603
+ * @documentationMaturity preview
604
+ * @requiredField _id
605
+ */
606
+ export function getProductIdsForSubscriptionOption(_id, options) {
607
+ var _a, _b, _c;
608
+ return __awaiter(this, arguments, void 0, function* () {
609
+ const requestTransformation = {
610
+ id: '$[0]',
611
+ includeHiddenProducts: '$[1].includeHiddenProducts',
612
+ paging: '$[1].paging',
613
+ };
614
+ const responseTransformation = '$';
615
+ // @ts-ignore
616
+ const { httpClient, sideEffects } = arguments[2];
617
+ const { toAmbassadorRequest } = serializer({
618
+ rootSchema: _getProductIdsForSubscriptionOptionRequest,
619
+ depSchemas: {},
620
+ fqdnTransformation: {
621
+ paths: [],
622
+ transformation: _fromVeloEntity,
623
+ },
624
+ customTransformation: requestTransformation,
625
+ });
626
+ const { fromJSON } = serializer({
627
+ rootSchema: _getProductIdsForSubscriptionOptionResponse,
628
+ depSchemas: {},
629
+ fqdnTransformation: {
630
+ paths: [],
631
+ transformation: _toVeloEntity,
632
+ },
633
+ customTransformation: responseTransformation,
634
+ });
635
+ const payload = toAmbassadorRequest([_id, options]);
636
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.getProductIdsForSubscriptionOption(payload);
637
+ __log(`"GetProductIdsForSubscriptionOption" sending request with: ${__inspect(reqOpts)}`);
638
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
639
+ try {
640
+ const result = yield httpClient.request(reqOpts);
641
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
642
+ return fromJSON(result.data);
643
+ }
644
+ catch (err) {
645
+ const transformedError = transformError(err, requestTransformation, [
646
+ '_id',
647
+ 'options',
648
+ ]);
649
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
650
+ throw transformedError;
651
+ }
652
+ });
653
+ }
654
+ /**
655
+ * Checks whether a specified product (associated with subscription options) is available for one-time purchase.
656
+ * @param productId - Product ID.
657
+ * @public
658
+ * @documentationMaturity preview
659
+ * @requiredField productId
660
+ */
661
+ export function getOneTimePurchasesStatus(productId) {
662
+ var _a, _b, _c;
663
+ return __awaiter(this, arguments, void 0, function* () {
664
+ const requestTransformation = { productId: '$[0]' };
665
+ const responseTransformation = '$';
666
+ // @ts-ignore
667
+ const { httpClient, sideEffects } = arguments[1];
668
+ const { toAmbassadorRequest } = serializer({
669
+ rootSchema: _getOneTimePurchasesStatusRequest,
670
+ depSchemas: {},
671
+ fqdnTransformation: {
672
+ paths: [],
673
+ transformation: _fromVeloEntity,
674
+ },
675
+ customTransformation: requestTransformation,
676
+ });
677
+ const { fromJSON } = serializer({
678
+ rootSchema: _getOneTimePurchasesStatusResponse,
679
+ depSchemas: {},
680
+ fqdnTransformation: {
681
+ paths: [],
682
+ transformation: _toVeloEntity,
683
+ },
684
+ customTransformation: responseTransformation,
685
+ });
686
+ const payload = toAmbassadorRequest([productId]);
687
+ const reqOpts = ambassadorWixStoresV1SubscriptionOption.getOneTimePurchasesStatus(payload);
688
+ __log(`"GetOneTimePurchasesStatus" sending request with: ${__inspect(reqOpts)}`);
689
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
690
+ try {
691
+ const result = yield httpClient.request(reqOpts);
692
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
693
+ return fromJSON(result.data);
694
+ }
695
+ catch (err) {
696
+ const transformedError = transformError(err, requestTransformation, [
697
+ 'productId',
698
+ ]);
699
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
700
+ throw transformedError;
701
+ }
702
+ });
703
+ }
704
+ //# sourceMappingURL=stores-v1-subscription-option.universal.js.map