@wix/pricing-plans 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/build/cjs/index.d.ts +2 -0
  2. package/build/cjs/index.js +25 -0
  3. package/build/cjs/index.js.map +1 -0
  4. package/build/cjs/src/pricing-plans-v2-order.http.d.ts +105 -0
  5. package/build/cjs/src/pricing-plans-v2-order.http.js +751 -0
  6. package/build/cjs/src/pricing-plans-v2-order.http.js.map +1 -0
  7. package/build/cjs/src/pricing-plans-v2-order.public.d.ts +17 -0
  8. package/build/cjs/src/pricing-plans-v2-order.public.js +95 -0
  9. package/build/cjs/src/pricing-plans-v2-order.public.js.map +1 -0
  10. package/build/cjs/src/pricing-plans-v2-order.types.d.ts +1071 -0
  11. package/build/cjs/src/pricing-plans-v2-order.types.js +133 -0
  12. package/build/cjs/src/pricing-plans-v2-order.types.js.map +1 -0
  13. package/build/cjs/src/pricing-plans-v2-order.universal.d.ts +1346 -0
  14. package/build/cjs/src/pricing-plans-v2-order.universal.js +962 -0
  15. package/build/cjs/src/pricing-plans-v2-order.universal.js.map +1 -0
  16. package/build/cjs/src/pricing-plans-v2-plan.http.d.ts +44 -0
  17. package/build/cjs/src/pricing-plans-v2-plan.http.js +453 -0
  18. package/build/cjs/src/pricing-plans-v2-plan.http.js.map +1 -0
  19. package/build/cjs/src/pricing-plans-v2-plan.public.d.ts +16 -0
  20. package/build/cjs/src/pricing-plans-v2-plan.public.js +82 -0
  21. package/build/cjs/src/pricing-plans-v2-plan.public.js.map +1 -0
  22. package/build/cjs/src/pricing-plans-v2-plan.types.d.ts +357 -0
  23. package/build/cjs/src/pricing-plans-v2-plan.types.js +35 -0
  24. package/build/cjs/src/pricing-plans-v2-plan.types.js.map +1 -0
  25. package/build/cjs/src/pricing-plans-v2-plan.universal.d.ts +554 -0
  26. package/build/cjs/src/pricing-plans-v2-plan.universal.js +728 -0
  27. package/build/cjs/src/pricing-plans-v2-plan.universal.js.map +1 -0
  28. package/build/es/index.d.ts +2 -0
  29. package/build/es/index.js +3 -0
  30. package/build/es/index.js.map +1 -0
  31. package/build/es/src/pricing-plans-v2-order.http.d.ts +105 -0
  32. package/build/es/src/pricing-plans-v2-order.http.js +735 -0
  33. package/build/es/src/pricing-plans-v2-order.http.js.map +1 -0
  34. package/build/es/src/pricing-plans-v2-order.public.d.ts +17 -0
  35. package/build/es/src/pricing-plans-v2-order.public.js +68 -0
  36. package/build/es/src/pricing-plans-v2-order.public.js.map +1 -0
  37. package/build/es/src/pricing-plans-v2-order.types.d.ts +1071 -0
  38. package/build/es/src/pricing-plans-v2-order.types.js +130 -0
  39. package/build/es/src/pricing-plans-v2-order.types.js.map +1 -0
  40. package/build/es/src/pricing-plans-v2-order.universal.d.ts +1346 -0
  41. package/build/es/src/pricing-plans-v2-order.universal.js +927 -0
  42. package/build/es/src/pricing-plans-v2-order.universal.js.map +1 -0
  43. package/build/es/src/pricing-plans-v2-plan.http.d.ts +44 -0
  44. package/build/es/src/pricing-plans-v2-plan.http.js +438 -0
  45. package/build/es/src/pricing-plans-v2-plan.http.js.map +1 -0
  46. package/build/es/src/pricing-plans-v2-plan.public.d.ts +16 -0
  47. package/build/es/src/pricing-plans-v2-plan.public.js +63 -0
  48. package/build/es/src/pricing-plans-v2-plan.public.js.map +1 -0
  49. package/build/es/src/pricing-plans-v2-plan.types.d.ts +357 -0
  50. package/build/es/src/pricing-plans-v2-plan.types.js +32 -0
  51. package/build/es/src/pricing-plans-v2-plan.types.js.map +1 -0
  52. package/build/es/src/pricing-plans-v2-plan.universal.d.ts +554 -0
  53. package/build/es/src/pricing-plans-v2-plan.universal.js +694 -0
  54. package/build/es/src/pricing-plans-v2-plan.universal.js.map +1 -0
  55. package/package.json +37 -0
@@ -0,0 +1,728 @@
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.arrangePlans = exports.archivePlan = exports.clearPrimary = exports.makePlanPrimary = exports.setPlanVisibility = exports.updatePlan = exports.createPlan = exports.getPlanStats = exports.listPlans = exports.getPlan = exports.queryPublicPlans = exports.listPublicPlans = exports.PublicFilter = exports.ArchivedFilter = exports.SortOrder = exports.PeriodUnit = exports.__debug = void 0;
32
+ const velo_1 = require("@wix/metro-runtime/velo");
33
+ const ambassadorWixPricingPlansV2Plan = __importStar(require("./pricing-plans-v2-plan.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
+ var PeriodUnit;
50
+ (function (PeriodUnit) {
51
+ PeriodUnit["UNDEFINED"] = "UNDEFINED";
52
+ PeriodUnit["DAY"] = "DAY";
53
+ PeriodUnit["WEEK"] = "WEEK";
54
+ PeriodUnit["MONTH"] = "MONTH";
55
+ PeriodUnit["YEAR"] = "YEAR";
56
+ })(PeriodUnit = exports.PeriodUnit || (exports.PeriodUnit = {}));
57
+ var SortOrder;
58
+ (function (SortOrder) {
59
+ SortOrder["ASC"] = "ASC";
60
+ SortOrder["DESC"] = "DESC";
61
+ })(SortOrder = exports.SortOrder || (exports.SortOrder = {}));
62
+ var ArchivedFilter;
63
+ (function (ArchivedFilter) {
64
+ /** Returns all plans that are active. */
65
+ ArchivedFilter["ACTIVE"] = "ACTIVE";
66
+ /** Returns all plans that are archived. */
67
+ ArchivedFilter["ARCHIVED"] = "ARCHIVED";
68
+ /** Returns all plans that are active and archived. */
69
+ ArchivedFilter["ARCHIVED_AND_ACTIVE"] = "ARCHIVED_AND_ACTIVE";
70
+ })(ArchivedFilter = exports.ArchivedFilter || (exports.ArchivedFilter = {}));
71
+ var PublicFilter;
72
+ (function (PublicFilter) {
73
+ /** Returns all public and hidden plans. */
74
+ PublicFilter["PUBLIC_AND_HIDDEN"] = "PUBLIC_AND_HIDDEN";
75
+ /** Returns only public plans. */
76
+ PublicFilter["PUBLIC"] = "PUBLIC";
77
+ /** Returns only hidden plans. */
78
+ PublicFilter["HIDDEN"] = "HIDDEN";
79
+ })(PublicFilter = exports.PublicFilter || (exports.PublicFilter = {}));
80
+ const _archivePlanRequest = {};
81
+ const _archivePlanResponse = {};
82
+ const _arrangePlansRequest = {};
83
+ const _arrangePlansResponse = {};
84
+ const _clearPrimaryRequest = {};
85
+ const _clearPrimaryResponse = {};
86
+ const _createPlanRequest = {};
87
+ const _createPlanResponse = {};
88
+ const _getPlanRequest = {};
89
+ const _getPlanResponse = {};
90
+ const _getPlanStatsRequest = {};
91
+ const _getPlanStatsResponse = {};
92
+ const _listPlansRequest = {};
93
+ const _listPlansResponse = {};
94
+ const _listPublicPlansRequest = {};
95
+ const _listPublicPlansResponse = {};
96
+ const _makePlanPrimaryRequest = {};
97
+ const _makePlanPrimaryResponse = {};
98
+ const _queryPublicPlansRequest = {};
99
+ const _queryPublicPlansResponse = {};
100
+ const _setPlanVisibilityRequest = {};
101
+ const _setPlanVisibilityResponse = {};
102
+ const _updatePlanRequest = {};
103
+ const _updatePlanResponse = {};
104
+ /**
105
+ * Retrieves a list of up to 100 public pricing plans.
106
+ * @public
107
+ * @documentationMaturity preview
108
+ */
109
+ function listPublicPlans(options) {
110
+ var _a, _b, _c;
111
+ return __awaiter(this, arguments, void 0, function* () {
112
+ const requestTransformation = {
113
+ limit: '$[0].limit',
114
+ offset: '$[0].offset',
115
+ planIds: '$[0].planIds',
116
+ };
117
+ const responseTransformation = '$';
118
+ // @ts-ignore
119
+ const { httpClient, sideEffects } = arguments[1];
120
+ const { toAmbassadorRequest } = velo_1.serializer({
121
+ rootSchema: _listPublicPlansRequest,
122
+ depSchemas: {},
123
+ fqdnTransformation: {
124
+ paths: [],
125
+ transformation: _fromVeloEntity,
126
+ },
127
+ customTransformation: requestTransformation,
128
+ });
129
+ const { fromJSON } = velo_1.serializer({
130
+ rootSchema: _listPublicPlansResponse,
131
+ depSchemas: {},
132
+ fqdnTransformation: {
133
+ paths: [],
134
+ transformation: _toVeloEntity,
135
+ },
136
+ customTransformation: responseTransformation,
137
+ });
138
+ const payload = toAmbassadorRequest([options]);
139
+ const reqOpts = ambassadorWixPricingPlansV2Plan.listPublicPlans(payload);
140
+ __log(`"ListPublicPlans" sending request with: ${__inspect(reqOpts)}`);
141
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
142
+ try {
143
+ const result = yield httpClient.request(reqOpts);
144
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
145
+ return fromJSON(result.data);
146
+ }
147
+ catch (err) {
148
+ const transformedError = velo_1.transformError(err, requestTransformation, [
149
+ 'options',
150
+ ]);
151
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
152
+ throw transformedError;
153
+ }
154
+ });
155
+ }
156
+ exports.listPublicPlans = listPublicPlans;
157
+ /**
158
+ * Retrieves a list of up to 1,000 public pricing plans, given the provided pagination, [sorting, and filtering](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/plans/filter-and-sort).
159
+ * @public
160
+ * @documentationMaturity preview
161
+ */
162
+ function queryPublicPlans(options) {
163
+ var _a, _b, _c;
164
+ return __awaiter(this, arguments, void 0, function* () {
165
+ const requestTransformation = { query: '$[0].query' };
166
+ const responseTransformation = '$';
167
+ // @ts-ignore
168
+ const { httpClient, sideEffects } = arguments[1];
169
+ const { toAmbassadorRequest } = velo_1.serializer({
170
+ rootSchema: _queryPublicPlansRequest,
171
+ depSchemas: {},
172
+ fqdnTransformation: {
173
+ paths: [],
174
+ transformation: _fromVeloEntity,
175
+ },
176
+ customTransformation: requestTransformation,
177
+ });
178
+ const { fromJSON } = velo_1.serializer({
179
+ rootSchema: _queryPublicPlansResponse,
180
+ depSchemas: {},
181
+ fqdnTransformation: {
182
+ paths: [],
183
+ transformation: _toVeloEntity,
184
+ },
185
+ customTransformation: responseTransformation,
186
+ });
187
+ const payload = toAmbassadorRequest([options]);
188
+ const reqOpts = ambassadorWixPricingPlansV2Plan.queryPublicPlans(payload);
189
+ __log(`"QueryPublicPlans" sending request with: ${__inspect(reqOpts)}`);
190
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
191
+ try {
192
+ const result = yield httpClient.request(reqOpts);
193
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
194
+ return fromJSON(result.data);
195
+ }
196
+ catch (err) {
197
+ const transformedError = velo_1.transformError(err, requestTransformation, [
198
+ 'options',
199
+ ]);
200
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
201
+ throw transformedError;
202
+ }
203
+ });
204
+ }
205
+ exports.queryPublicPlans = queryPublicPlans;
206
+ /**
207
+ * Retrieves a pricing plan by ID.
208
+ * @param _id - Plan ID.
209
+ * @public
210
+ * @documentationMaturity preview
211
+ * @requiredField _id
212
+ */
213
+ function getPlan(_id) {
214
+ var _a, _b, _c;
215
+ return __awaiter(this, arguments, void 0, function* () {
216
+ const requestTransformation = { id: '$[0]' };
217
+ const responseTransformation = '$';
218
+ // @ts-ignore
219
+ const { httpClient, sideEffects } = arguments[1];
220
+ const { toAmbassadorRequest } = velo_1.serializer({
221
+ rootSchema: _getPlanRequest,
222
+ depSchemas: {},
223
+ fqdnTransformation: {
224
+ paths: [],
225
+ transformation: _fromVeloEntity,
226
+ },
227
+ customTransformation: requestTransformation,
228
+ });
229
+ const { fromJSON } = velo_1.serializer({
230
+ rootSchema: _getPlanResponse,
231
+ depSchemas: {},
232
+ fqdnTransformation: {
233
+ paths: [...['plan']],
234
+ transformation: _toVeloEntity,
235
+ },
236
+ customTransformation: responseTransformation,
237
+ });
238
+ const payload = toAmbassadorRequest([_id]);
239
+ const reqOpts = ambassadorWixPricingPlansV2Plan.getPlan(payload);
240
+ __log(`"GetPlan" sending request with: ${__inspect(reqOpts)}`);
241
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
242
+ try {
243
+ const result = yield httpClient.request(reqOpts);
244
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
245
+ return fromJSON(result.data);
246
+ }
247
+ catch (err) {
248
+ const transformedError = velo_1.transformError(err, requestTransformation, [
249
+ '_id',
250
+ ]);
251
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
252
+ throw transformedError;
253
+ }
254
+ });
255
+ }
256
+ exports.getPlan = getPlan;
257
+ /**
258
+ * Retrieves a list of up to 100 pricing plans (including public, hidden, and archived plans).
259
+ * @public
260
+ * @documentationMaturity preview
261
+ */
262
+ function listPlans(options) {
263
+ var _a, _b, _c;
264
+ return __awaiter(this, arguments, void 0, function* () {
265
+ const requestTransformation = {
266
+ archived: '$[0].archived',
267
+ public: '$[0].public',
268
+ limit: '$[0].limit',
269
+ offset: '$[0].offset',
270
+ planIds: '$[0].planIds',
271
+ };
272
+ const responseTransformation = '$';
273
+ // @ts-ignore
274
+ const { httpClient, sideEffects } = arguments[1];
275
+ const { toAmbassadorRequest } = velo_1.serializer({
276
+ rootSchema: _listPlansRequest,
277
+ depSchemas: {},
278
+ fqdnTransformation: {
279
+ paths: [],
280
+ transformation: _fromVeloEntity,
281
+ },
282
+ customTransformation: requestTransformation,
283
+ });
284
+ const { fromJSON } = velo_1.serializer({
285
+ rootSchema: _listPlansResponse,
286
+ depSchemas: {},
287
+ fqdnTransformation: {
288
+ paths: [...['Array#plans']],
289
+ transformation: _toVeloEntity,
290
+ },
291
+ customTransformation: responseTransformation,
292
+ });
293
+ const payload = toAmbassadorRequest([options]);
294
+ const reqOpts = ambassadorWixPricingPlansV2Plan.listPlans(payload);
295
+ __log(`"ListPlans" sending request with: ${__inspect(reqOpts)}`);
296
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
297
+ try {
298
+ const result = yield httpClient.request(reqOpts);
299
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
300
+ return fromJSON(result.data);
301
+ }
302
+ catch (err) {
303
+ const transformedError = velo_1.transformError(err, requestTransformation, [
304
+ 'options',
305
+ ]);
306
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
307
+ throw transformedError;
308
+ }
309
+ });
310
+ }
311
+ exports.listPlans = listPlans;
312
+ /**
313
+ * Gets statistics about the pricing plans. Currently providing only the total number of pricing plans.
314
+ * @public
315
+ * @documentationMaturity preview
316
+ */
317
+ function getPlanStats() {
318
+ var _a, _b, _c;
319
+ return __awaiter(this, arguments, void 0, function* () {
320
+ const requestTransformation = {};
321
+ const responseTransformation = '$';
322
+ // @ts-ignore
323
+ const { httpClient, sideEffects } = arguments[0];
324
+ const { toAmbassadorRequest } = velo_1.serializer({
325
+ rootSchema: _getPlanStatsRequest,
326
+ depSchemas: {},
327
+ fqdnTransformation: {
328
+ paths: [],
329
+ transformation: _fromVeloEntity,
330
+ },
331
+ customTransformation: requestTransformation,
332
+ });
333
+ const { fromJSON } = velo_1.serializer({
334
+ rootSchema: _getPlanStatsResponse,
335
+ depSchemas: {},
336
+ fqdnTransformation: {
337
+ paths: [],
338
+ transformation: _toVeloEntity,
339
+ },
340
+ customTransformation: responseTransformation,
341
+ });
342
+ const payload = toAmbassadorRequest([]);
343
+ const reqOpts = ambassadorWixPricingPlansV2Plan.getPlanStats(payload);
344
+ __log(`"GetPlanStats" 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
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
354
+ throw transformedError;
355
+ }
356
+ });
357
+ }
358
+ exports.getPlanStats = getPlanStats;
359
+ /**
360
+ * Creates a pricing plan.
361
+ * @public
362
+ * @documentationMaturity preview
363
+ * @requiredField plan
364
+ * @requiredField plan.name
365
+ * @requiredField plan.pricing
366
+ * @requiredField plan.pricing
367
+ * @requiredField plan.pricing.singlePaymentForDuration.count
368
+ * @requiredField plan.pricing.subscription.cycleCount
369
+ * @requiredField plan.pricing.subscription.cycleDuration
370
+ * @requiredField plan.pricing.subscription.cycleDuration.count
371
+ */
372
+ function createPlan(plan) {
373
+ var _a, _b, _c;
374
+ return __awaiter(this, arguments, void 0, function* () {
375
+ const requestTransformation = { plan: '$[0]' };
376
+ const responseTransformation = '$';
377
+ // @ts-ignore
378
+ const { httpClient, sideEffects } = arguments[1];
379
+ const { toAmbassadorRequest } = velo_1.serializer({
380
+ rootSchema: _createPlanRequest,
381
+ depSchemas: {},
382
+ fqdnTransformation: {
383
+ paths: [...['plan']],
384
+ transformation: _fromVeloEntity,
385
+ },
386
+ customTransformation: requestTransformation,
387
+ });
388
+ const { fromJSON } = velo_1.serializer({
389
+ rootSchema: _createPlanResponse,
390
+ depSchemas: {},
391
+ fqdnTransformation: {
392
+ paths: [...['plan']],
393
+ transformation: _toVeloEntity,
394
+ },
395
+ customTransformation: responseTransformation,
396
+ });
397
+ const payload = toAmbassadorRequest([plan]);
398
+ const reqOpts = ambassadorWixPricingPlansV2Plan.createPlan(payload);
399
+ __log(`"CreatePlan" sending request with: ${__inspect(reqOpts)}`);
400
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
401
+ try {
402
+ const result = yield httpClient.request(reqOpts);
403
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
404
+ return fromJSON(result.data);
405
+ }
406
+ catch (err) {
407
+ const transformedError = velo_1.transformError(err, requestTransformation, [
408
+ 'plan',
409
+ ]);
410
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
411
+ throw transformedError;
412
+ }
413
+ });
414
+ }
415
+ exports.createPlan = createPlan;
416
+ /**
417
+ * Updates a pricing plan.
418
+ * Updating a plan does not impact existing orders made for the plan. All orders keep the details of the original plan that was active at the time of purchase.
419
+ * @param _id - Plan ID.
420
+ * @public
421
+ * @documentationMaturity preview
422
+ * @requiredField _id
423
+ */
424
+ function updatePlan(_id, options) {
425
+ var _a, _b, _c;
426
+ return __awaiter(this, arguments, void 0, function* () {
427
+ const requestTransformation = {
428
+ plan: { '*': '$[1].plan', id: '$[0]' },
429
+ fieldMask: '$[1].fieldMask',
430
+ };
431
+ const responseTransformation = '$';
432
+ // @ts-ignore
433
+ const { httpClient, sideEffects } = arguments[2];
434
+ const { toAmbassadorRequest } = velo_1.serializer({
435
+ rootSchema: _updatePlanRequest,
436
+ depSchemas: {},
437
+ fqdnTransformation: {
438
+ paths: [...['plan']],
439
+ transformation: _fromVeloEntity,
440
+ },
441
+ customTransformation: requestTransformation,
442
+ });
443
+ const { fromJSON } = velo_1.serializer({
444
+ rootSchema: _updatePlanResponse,
445
+ depSchemas: {},
446
+ fqdnTransformation: {
447
+ paths: [...['plan']],
448
+ transformation: _toVeloEntity,
449
+ },
450
+ customTransformation: responseTransformation,
451
+ });
452
+ const payload = toAmbassadorRequest([_id, options]);
453
+ const reqOpts = ambassadorWixPricingPlansV2Plan.updatePlan(payload);
454
+ __log(`"UpdatePlan" sending request with: ${__inspect(reqOpts)}`);
455
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
456
+ try {
457
+ const result = yield httpClient.request(reqOpts);
458
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
459
+ return fromJSON(result.data);
460
+ }
461
+ catch (err) {
462
+ const transformedError = velo_1.transformError(err, requestTransformation, [
463
+ '_id',
464
+ 'options',
465
+ ]);
466
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
467
+ throw transformedError;
468
+ }
469
+ });
470
+ }
471
+ exports.updatePlan = updatePlan;
472
+ /**
473
+ * Sets visibility for pricing plans. Visible plans are considered public plans.
474
+ * By default, pricing plans are public, meaning they are visible. Plans can be hidden so that site members and visitors cannot choose them.
475
+ * As opposed to archiving, setting visibility can be reversed. This means that a public plan can be hidden, and a hidden plan can be made public (visible). (An archived plan always remains archived and cannot be made active again.)
476
+ * Changing a plan’s visibility does not impact existing orders for the plan. All orders for hidden plans are still active and keep their perks.
477
+ * @public
478
+ * @documentationMaturity preview
479
+ * @requiredField _id
480
+ */
481
+ function setPlanVisibility(_id, options) {
482
+ var _a, _b, _c;
483
+ return __awaiter(this, arguments, void 0, function* () {
484
+ const requestTransformation = { id: '$[0]', visible: '$[1].visible' };
485
+ const responseTransformation = '$';
486
+ // @ts-ignore
487
+ const { httpClient, sideEffects } = arguments[2];
488
+ const { toAmbassadorRequest } = velo_1.serializer({
489
+ rootSchema: _setPlanVisibilityRequest,
490
+ depSchemas: {},
491
+ fqdnTransformation: {
492
+ paths: [],
493
+ transformation: _fromVeloEntity,
494
+ },
495
+ customTransformation: requestTransformation,
496
+ });
497
+ const { fromJSON } = velo_1.serializer({
498
+ rootSchema: _setPlanVisibilityResponse,
499
+ depSchemas: {},
500
+ fqdnTransformation: {
501
+ paths: [...['plan']],
502
+ transformation: _toVeloEntity,
503
+ },
504
+ customTransformation: responseTransformation,
505
+ });
506
+ const payload = toAmbassadorRequest([_id, options]);
507
+ const reqOpts = ambassadorWixPricingPlansV2Plan.setPlanVisibility(payload);
508
+ __log(`"SetPlanVisibility" sending request with: ${__inspect(reqOpts)}`);
509
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
510
+ try {
511
+ const result = yield httpClient.request(reqOpts);
512
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
513
+ return fromJSON(result.data);
514
+ }
515
+ catch (err) {
516
+ const transformedError = velo_1.transformError(err, requestTransformation, [
517
+ '_id',
518
+ 'options',
519
+ ]);
520
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
521
+ throw transformedError;
522
+ }
523
+ });
524
+ }
525
+ exports.setPlanVisibility = setPlanVisibility;
526
+ /**
527
+ * Marks a pricing plan as the primary pricing plan. When viewing pricing plans on the site, the primary plan is highlighted with a customizable ribbon.
528
+ * @public
529
+ * @documentationMaturity preview
530
+ * @requiredField _id
531
+ */
532
+ function makePlanPrimary(_id) {
533
+ var _a, _b, _c;
534
+ return __awaiter(this, arguments, void 0, function* () {
535
+ const requestTransformation = { id: '$[0]' };
536
+ const responseTransformation = '$';
537
+ // @ts-ignore
538
+ const { httpClient, sideEffects } = arguments[1];
539
+ const { toAmbassadorRequest } = velo_1.serializer({
540
+ rootSchema: _makePlanPrimaryRequest,
541
+ depSchemas: {},
542
+ fqdnTransformation: {
543
+ paths: [],
544
+ transformation: _fromVeloEntity,
545
+ },
546
+ customTransformation: requestTransformation,
547
+ });
548
+ const { fromJSON } = velo_1.serializer({
549
+ rootSchema: _makePlanPrimaryResponse,
550
+ depSchemas: {},
551
+ fqdnTransformation: {
552
+ paths: [...['plan']],
553
+ transformation: _toVeloEntity,
554
+ },
555
+ customTransformation: responseTransformation,
556
+ });
557
+ const payload = toAmbassadorRequest([_id]);
558
+ const reqOpts = ambassadorWixPricingPlansV2Plan.makePlanPrimary(payload);
559
+ __log(`"MakePlanPrimary" sending request with: ${__inspect(reqOpts)}`);
560
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
561
+ try {
562
+ const result = yield httpClient.request(reqOpts);
563
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
564
+ return fromJSON(result.data);
565
+ }
566
+ catch (err) {
567
+ const transformedError = velo_1.transformError(err, requestTransformation, [
568
+ '_id',
569
+ ]);
570
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
571
+ throw transformedError;
572
+ }
573
+ });
574
+ }
575
+ exports.makePlanPrimary = makePlanPrimary;
576
+ /**
577
+ * Sets all pricing plans as not primary. When viewing pricing plans on the site, no plan is highlighted with a customizable ribbon.
578
+ * @public
579
+ * @documentationMaturity preview
580
+ */
581
+ function clearPrimary() {
582
+ var _a, _b, _c;
583
+ return __awaiter(this, arguments, void 0, function* () {
584
+ const requestTransformation = {};
585
+ const responseTransformation = '$';
586
+ // @ts-ignore
587
+ const { httpClient, sideEffects } = arguments[0];
588
+ const { toAmbassadorRequest } = velo_1.serializer({
589
+ rootSchema: _clearPrimaryRequest,
590
+ depSchemas: {},
591
+ fqdnTransformation: {
592
+ paths: [],
593
+ transformation: _fromVeloEntity,
594
+ },
595
+ customTransformation: requestTransformation,
596
+ });
597
+ const { fromJSON } = velo_1.serializer({
598
+ rootSchema: _clearPrimaryResponse,
599
+ depSchemas: {},
600
+ fqdnTransformation: {
601
+ paths: [],
602
+ transformation: _toVeloEntity,
603
+ },
604
+ customTransformation: responseTransformation,
605
+ });
606
+ const payload = toAmbassadorRequest([]);
607
+ const reqOpts = ambassadorWixPricingPlansV2Plan.clearPrimary(payload);
608
+ __log(`"ClearPrimary" sending request with: ${__inspect(reqOpts)}`);
609
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
610
+ try {
611
+ const result = yield httpClient.request(reqOpts);
612
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
613
+ return fromJSON(result.data);
614
+ }
615
+ catch (err) {
616
+ const transformedError = velo_1.transformError(err, requestTransformation, []);
617
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
618
+ throw transformedError;
619
+ }
620
+ });
621
+ }
622
+ exports.clearPrimary = clearPrimary;
623
+ /**
624
+ * Archives a single plan.
625
+ * When a plan is archived, it is no longer visible as a public plan that can be chosen by site members or visitors. Archived plans cannot be purchased.
626
+ * An archived plan cannot be made active again.
627
+ * Plan archiving does not impact existing orders made for the plan. All orders for the plan are still active and keep their perks.
628
+ * Site owners can see archived plans in the Dashboard under Pricing Plans -> Archived Plans.
629
+ * @public
630
+ * @documentationMaturity preview
631
+ * @requiredField _id
632
+ */
633
+ function archivePlan(_id) {
634
+ var _a, _b, _c;
635
+ return __awaiter(this, arguments, void 0, function* () {
636
+ const requestTransformation = { id: '$[0]' };
637
+ const responseTransformation = '$';
638
+ // @ts-ignore
639
+ const { httpClient, sideEffects } = arguments[1];
640
+ const { toAmbassadorRequest } = velo_1.serializer({
641
+ rootSchema: _archivePlanRequest,
642
+ depSchemas: {},
643
+ fqdnTransformation: {
644
+ paths: [],
645
+ transformation: _fromVeloEntity,
646
+ },
647
+ customTransformation: requestTransformation,
648
+ });
649
+ const { fromJSON } = velo_1.serializer({
650
+ rootSchema: _archivePlanResponse,
651
+ depSchemas: {},
652
+ fqdnTransformation: {
653
+ paths: [...['plan']],
654
+ transformation: _toVeloEntity,
655
+ },
656
+ customTransformation: responseTransformation,
657
+ });
658
+ const payload = toAmbassadorRequest([_id]);
659
+ const reqOpts = ambassadorWixPricingPlansV2Plan.archivePlan(payload);
660
+ __log(`"ArchivePlan" sending request with: ${__inspect(reqOpts)}`);
661
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
662
+ try {
663
+ const result = yield httpClient.request(reqOpts);
664
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
665
+ return fromJSON(result.data);
666
+ }
667
+ catch (err) {
668
+ const transformedError = velo_1.transformError(err, requestTransformation, [
669
+ '_id',
670
+ ]);
671
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
672
+ throw transformedError;
673
+ }
674
+ });
675
+ }
676
+ exports.archivePlan = archivePlan;
677
+ /**
678
+ * Changes the display order of the plans on the site. To rearrange the order of the plans, provide a list of plan IDs in the desired order.
679
+ * Include all public and hidden plans in the list you provide.
680
+ * Make sure to provide all non-archived plan IDs to avoid unpredictable results
681
+ * @public
682
+ * @documentationMaturity preview
683
+ */
684
+ function arrangePlans(options) {
685
+ var _a, _b, _c;
686
+ return __awaiter(this, arguments, void 0, function* () {
687
+ const requestTransformation = { ids: '$[0].ids' };
688
+ const responseTransformation = '$';
689
+ // @ts-ignore
690
+ const { httpClient, sideEffects } = arguments[1];
691
+ const { toAmbassadorRequest } = velo_1.serializer({
692
+ rootSchema: _arrangePlansRequest,
693
+ depSchemas: {},
694
+ fqdnTransformation: {
695
+ paths: [],
696
+ transformation: _fromVeloEntity,
697
+ },
698
+ customTransformation: requestTransformation,
699
+ });
700
+ const { fromJSON } = velo_1.serializer({
701
+ rootSchema: _arrangePlansResponse,
702
+ depSchemas: {},
703
+ fqdnTransformation: {
704
+ paths: [],
705
+ transformation: _toVeloEntity,
706
+ },
707
+ customTransformation: responseTransformation,
708
+ });
709
+ const payload = toAmbassadorRequest([options]);
710
+ const reqOpts = ambassadorWixPricingPlansV2Plan.arrangePlans(payload);
711
+ __log(`"ArrangePlans" sending request with: ${__inspect(reqOpts)}`);
712
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
713
+ try {
714
+ const result = yield httpClient.request(reqOpts);
715
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
716
+ return fromJSON(result.data);
717
+ }
718
+ catch (err) {
719
+ const transformedError = velo_1.transformError(err, requestTransformation, [
720
+ 'options',
721
+ ]);
722
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
723
+ throw transformedError;
724
+ }
725
+ });
726
+ }
727
+ exports.arrangePlans = arrangePlans;
728
+ //# sourceMappingURL=pricing-plans-v2-plan.universal.js.map