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