@wix/pricing-plans 1.0.53 → 1.0.55
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/context.d.ts +2 -2
- package/build/cjs/context.js +2 -2
- package/build/cjs/context.js.map +1 -1
- package/build/cjs/index.d.ts +2 -2
- package/build/cjs/index.js +2 -2
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/meta.d.ts +2 -2
- package/build/cjs/meta.js +2 -2
- package/build/cjs/meta.js.map +1 -1
- package/build/es/context.d.ts +2 -2
- package/build/es/context.js +2 -2
- package/build/es/context.js.map +1 -1
- package/build/es/index.d.ts +2 -2
- package/build/es/index.js +2 -2
- package/build/es/index.js.map +1 -1
- package/build/es/meta.d.ts +2 -2
- package/build/es/meta.js +2 -2
- package/build/es/meta.js.map +1 -1
- package/package.json +12 -9
- package/build/cjs/index.typings.d.ts +0 -2
- package/build/cjs/index.typings.js +0 -29
- package/build/cjs/index.typings.js.map +0 -1
- package/build/cjs/src/pricing-plans-v2-order.context.d.ts +0 -15
- package/build/cjs/src/pricing-plans-v2-order.context.js +0 -148
- package/build/cjs/src/pricing-plans-v2-order.context.js.map +0 -1
- package/build/cjs/src/pricing-plans-v2-order.http.d.ts +0 -165
- package/build/cjs/src/pricing-plans-v2-order.http.js +0 -818
- package/build/cjs/src/pricing-plans-v2-order.http.js.map +0 -1
- package/build/cjs/src/pricing-plans-v2-order.meta.d.ts +0 -41
- package/build/cjs/src/pricing-plans-v2-order.meta.js +0 -275
- package/build/cjs/src/pricing-plans-v2-order.meta.js.map +0 -1
- package/build/cjs/src/pricing-plans-v2-order.public.d.ts +0 -103
- package/build/cjs/src/pricing-plans-v2-order.public.js +0 -96
- package/build/cjs/src/pricing-plans-v2-order.public.js.map +0 -1
- package/build/cjs/src/pricing-plans-v2-order.types.d.ts +0 -1801
- package/build/cjs/src/pricing-plans-v2-order.types.js +0 -135
- package/build/cjs/src/pricing-plans-v2-order.types.js.map +0 -1
- package/build/cjs/src/pricing-plans-v2-order.universal.d.ts +0 -2203
- package/build/cjs/src/pricing-plans-v2-order.universal.js +0 -1137
- package/build/cjs/src/pricing-plans-v2-order.universal.js.map +0 -1
- package/build/cjs/src/pricing-plans-v2-plan.context.d.ts +0 -14
- package/build/cjs/src/pricing-plans-v2-plan.context.js +0 -137
- package/build/cjs/src/pricing-plans-v2-plan.context.js.map +0 -1
- package/build/cjs/src/pricing-plans-v2-plan.http.d.ts +0 -134
- package/build/cjs/src/pricing-plans-v2-plan.http.js +0 -544
- package/build/cjs/src/pricing-plans-v2-plan.http.js.map +0 -1
- package/build/cjs/src/pricing-plans-v2-plan.meta.d.ts +0 -34
- package/build/cjs/src/pricing-plans-v2-plan.meta.js +0 -256
- package/build/cjs/src/pricing-plans-v2-plan.meta.js.map +0 -1
- package/build/cjs/src/pricing-plans-v2-plan.public.d.ts +0 -85
- package/build/cjs/src/pricing-plans-v2-plan.public.js +0 -84
- package/build/cjs/src/pricing-plans-v2-plan.public.js.map +0 -1
- package/build/cjs/src/pricing-plans-v2-plan.types.d.ts +0 -732
- package/build/cjs/src/pricing-plans-v2-plan.types.js +0 -41
- package/build/cjs/src/pricing-plans-v2-plan.types.js.map +0 -1
- package/build/cjs/src/pricing-plans-v2-plan.universal.d.ts +0 -1163
- package/build/cjs/src/pricing-plans-v2-plan.universal.js +0 -908
- package/build/cjs/src/pricing-plans-v2-plan.universal.js.map +0 -1
- package/build/es/index.typings.d.ts +0 -2
- package/build/es/index.typings.js +0 -3
- package/build/es/index.typings.js.map +0 -1
- package/build/es/src/pricing-plans-v2-order.context.d.ts +0 -15
- package/build/es/src/pricing-plans-v2-order.context.js +0 -132
- package/build/es/src/pricing-plans-v2-order.context.js.map +0 -1
- package/build/es/src/pricing-plans-v2-order.http.d.ts +0 -165
- package/build/es/src/pricing-plans-v2-order.http.js +0 -802
- package/build/es/src/pricing-plans-v2-order.http.js.map +0 -1
- package/build/es/src/pricing-plans-v2-order.meta.d.ts +0 -41
- package/build/es/src/pricing-plans-v2-order.meta.js +0 -236
- package/build/es/src/pricing-plans-v2-order.meta.js.map +0 -1
- package/build/es/src/pricing-plans-v2-order.public.d.ts +0 -103
- package/build/es/src/pricing-plans-v2-order.public.js +0 -69
- package/build/es/src/pricing-plans-v2-order.public.js.map +0 -1
- package/build/es/src/pricing-plans-v2-order.types.d.ts +0 -1801
- package/build/es/src/pricing-plans-v2-order.types.js +0 -132
- package/build/es/src/pricing-plans-v2-order.types.js.map +0 -1
- package/build/es/src/pricing-plans-v2-order.universal.d.ts +0 -2203
- package/build/es/src/pricing-plans-v2-order.universal.js +0 -1098
- package/build/es/src/pricing-plans-v2-order.universal.js.map +0 -1
- package/build/es/src/pricing-plans-v2-plan.context.d.ts +0 -14
- package/build/es/src/pricing-plans-v2-plan.context.js +0 -122
- package/build/es/src/pricing-plans-v2-plan.context.js.map +0 -1
- package/build/es/src/pricing-plans-v2-plan.http.d.ts +0 -134
- package/build/es/src/pricing-plans-v2-plan.http.js +0 -529
- package/build/es/src/pricing-plans-v2-plan.http.js.map +0 -1
- package/build/es/src/pricing-plans-v2-plan.meta.d.ts +0 -34
- package/build/es/src/pricing-plans-v2-plan.meta.js +0 -218
- package/build/es/src/pricing-plans-v2-plan.meta.js.map +0 -1
- package/build/es/src/pricing-plans-v2-plan.public.d.ts +0 -85
- package/build/es/src/pricing-plans-v2-plan.public.js +0 -64
- package/build/es/src/pricing-plans-v2-plan.public.js.map +0 -1
- package/build/es/src/pricing-plans-v2-plan.types.d.ts +0 -732
- package/build/es/src/pricing-plans-v2-plan.types.js +0 -38
- package/build/es/src/pricing-plans-v2-plan.types.js.map +0 -1
- package/build/es/src/pricing-plans-v2-plan.universal.d.ts +0 -1163
- package/build/es/src/pricing-plans-v2-plan.universal.js +0 -870
- package/build/es/src/pricing-plans-v2-plan.universal.js.map +0 -1
@@ -1,908 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
32
|
-
});
|
33
|
-
};
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
35
|
-
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.AppliedAt = exports.PeriodUnit = void 0;
|
36
|
-
const velo_1 = require("@wix/metro-runtime/velo");
|
37
|
-
const transform_error_1 = require("@wix/sdk-runtime/transform-error");
|
38
|
-
const ambassadorWixPricingPlansV2Plan = __importStar(require("./pricing-plans-v2-plan.http"));
|
39
|
-
// @ts-ignore
|
40
|
-
const motion_edm_autogen_query_wrapper_1 = require("@wix/motion-edm-autogen-query-wrapper");
|
41
|
-
const _toVeloEntity = '$';
|
42
|
-
const _fromVeloEntity = '$';
|
43
|
-
var PeriodUnit;
|
44
|
-
(function (PeriodUnit) {
|
45
|
-
PeriodUnit["UNDEFINED"] = "UNDEFINED";
|
46
|
-
PeriodUnit["DAY"] = "DAY";
|
47
|
-
PeriodUnit["WEEK"] = "WEEK";
|
48
|
-
PeriodUnit["MONTH"] = "MONTH";
|
49
|
-
PeriodUnit["YEAR"] = "YEAR";
|
50
|
-
})(PeriodUnit || (exports.PeriodUnit = PeriodUnit = {}));
|
51
|
-
var AppliedAt;
|
52
|
-
(function (AppliedAt) {
|
53
|
-
AppliedAt["UNKNOWN_CHARGE_EVENT"] = "UNKNOWN_CHARGE_EVENT";
|
54
|
-
/** Will charge the fee on first payment. If order has a free trial meaning it will charge after the free trial. */
|
55
|
-
AppliedAt["FIRST_PAYMENT"] = "FIRST_PAYMENT";
|
56
|
-
})(AppliedAt || (exports.AppliedAt = AppliedAt = {}));
|
57
|
-
var SortOrder;
|
58
|
-
(function (SortOrder) {
|
59
|
-
SortOrder["ASC"] = "ASC";
|
60
|
-
SortOrder["DESC"] = "DESC";
|
61
|
-
})(SortOrder || (exports.SortOrder = 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 = 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 = 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 public pricing plans.
|
106
|
-
*
|
107
|
-
*
|
108
|
-
* The `listPublicPlans()` function returns a Promise that resolves to a list of up to 100 public pricing plans. Public plans are visible plans that site visitors can see on the site and purchase.
|
109
|
-
* @public
|
110
|
-
* @param options - Options for filtering and paging the list of public plans.
|
111
|
-
* @permissionScope Read Pricing Plans
|
112
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.READ-PLANS
|
113
|
-
* @permissionScope Manage Orders
|
114
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
|
115
|
-
* @permissionScope Manage Bookings Services and Settings
|
116
|
-
* @permissionScopeId SCOPE.BOOKINGS.CONFIGURATION
|
117
|
-
* @permissionScope Read Orders
|
118
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
|
119
|
-
* @permissionScope Manage Pricing Plans
|
120
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
|
121
|
-
* @applicableIdentity APP
|
122
|
-
* @applicableIdentity MEMBER
|
123
|
-
* @applicableIdentity VISITOR
|
124
|
-
* @returns Fulfilled - List of public pricing plans.
|
125
|
-
*/
|
126
|
-
function listPublicPlans(options) {
|
127
|
-
var _a, _b, _c;
|
128
|
-
return __awaiter(this, arguments, void 0, function* () {
|
129
|
-
const requestTransformation = {
|
130
|
-
limit: '$[0].limit',
|
131
|
-
offset: '$[0].offset',
|
132
|
-
planIds: '$[0].planIds',
|
133
|
-
};
|
134
|
-
const responseTransformation = '$';
|
135
|
-
// @ts-ignore
|
136
|
-
const { httpClient, sideEffects } = arguments[1];
|
137
|
-
const { toAmbassadorRequest } = (0, velo_1.serializer)({
|
138
|
-
rootSchema: _listPublicPlansRequest,
|
139
|
-
depSchemas: {},
|
140
|
-
fqdnTransformation: {
|
141
|
-
paths: [],
|
142
|
-
transformation: _fromVeloEntity,
|
143
|
-
},
|
144
|
-
customTransformation: requestTransformation,
|
145
|
-
});
|
146
|
-
const { fromJSON } = (0, velo_1.serializer)({
|
147
|
-
rootSchema: _listPublicPlansResponse,
|
148
|
-
depSchemas: {},
|
149
|
-
fqdnTransformation: {
|
150
|
-
paths: [],
|
151
|
-
transformation: _toVeloEntity,
|
152
|
-
},
|
153
|
-
customTransformation: responseTransformation,
|
154
|
-
});
|
155
|
-
const payload = toAmbassadorRequest([options]);
|
156
|
-
const reqOpts = ambassadorWixPricingPlansV2Plan.listPublicPlans(payload);
|
157
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
158
|
-
try {
|
159
|
-
const result = yield httpClient.request(reqOpts);
|
160
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
161
|
-
return fromJSON(result.data);
|
162
|
-
}
|
163
|
-
catch (err) {
|
164
|
-
const transformedError = (0, transform_error_1.transformError)(err, {
|
165
|
-
spreadPathsToArguments: {},
|
166
|
-
explicitPathsToArguments: {
|
167
|
-
limit: '$[0].limit',
|
168
|
-
offset: '$[0].offset',
|
169
|
-
planIds: '$[0].planIds',
|
170
|
-
},
|
171
|
-
singleArgumentUnchanged: false,
|
172
|
-
}, ['options']);
|
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
|
-
exports.listPublicPlans = listPublicPlans;
|
179
|
-
/**
|
180
|
-
* Creates a query to retrieve a list of public pricing plans.
|
181
|
-
*
|
182
|
-
*
|
183
|
-
* The `queryPublicPlans()` function builds a query to retrieve a list of up to 1,000 public plans and returns a [`PublicPlansQueryBuilder`](#plansquerybuilder) object.
|
184
|
-
*
|
185
|
-
* The returned object contains the query definition which is typically used to run the query using the [`find()`](#plansquerybuilder/find) function.
|
186
|
-
*
|
187
|
-
* You can refine the query by chaining `PublicPlansQueryBuilder` functions onto the query. `PublicPlansQueryBuilder` functions enable you to sort, filter, and control the results that `queryPublicPlans()` returns.
|
188
|
-
*
|
189
|
-
* `queryPublicPlans()` runs with the following `PublicPlansQueryBuilder` defaults that you can override:
|
190
|
-
* - [`skip`](#plansquerybuilder/skip): `0`
|
191
|
-
* - [`limit`](#plansquerybuilder/limit): `50`
|
192
|
-
*
|
193
|
-
* The functions that are chained to `queryPublicPlans()` are applied in the order they are called. For example, if you sort on the `_createdDate` property in ascending order and then on the `_id` property in ascending order, the results are sorted first by the created date of the items and then, if there are multiple results with the same date, the items are sorted by `_id` in ascending order, per created date value.
|
194
|
-
*
|
195
|
-
* The following `PublicPlansQueryBuilder` functions are supported for the `queryPublicPlans()` function. For a full description of the Plans object, see the object returned for the [`items`](#plansqueryresult/items) property in [`PublicPlansQueryResult`](#plansqueryresult).
|
196
|
-
* @public
|
197
|
-
* @permissionScope Read Pricing Plans
|
198
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.READ-PLANS
|
199
|
-
* @permissionScope Manage Orders
|
200
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
|
201
|
-
* @permissionScope Manage Bookings Services and Settings
|
202
|
-
* @permissionScopeId SCOPE.BOOKINGS.CONFIGURATION
|
203
|
-
* @permissionScope Read Orders
|
204
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
|
205
|
-
* @permissionScope Manage Pricing Plans
|
206
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
|
207
|
-
* @applicableIdentity APP
|
208
|
-
* @applicableIdentity MEMBER
|
209
|
-
* @applicableIdentity VISITOR
|
210
|
-
*/
|
211
|
-
function queryPublicPlans() {
|
212
|
-
const requestTransformation = { '*': '$[1]', query: '$[0]' };
|
213
|
-
const responseTransformation = {
|
214
|
-
items: '$.plans',
|
215
|
-
pagingMetadata: '$.pagingMetadata',
|
216
|
-
};
|
217
|
-
// @ts-ignore
|
218
|
-
const { httpClient, sideEffects } = arguments[0];
|
219
|
-
const { toAmbassadorRequest } = (0, velo_1.serializer)({
|
220
|
-
rootSchema: _queryPublicPlansRequest,
|
221
|
-
depSchemas: {},
|
222
|
-
fqdnTransformation: {
|
223
|
-
paths: [],
|
224
|
-
transformation: _fromVeloEntity,
|
225
|
-
},
|
226
|
-
customTransformation: requestTransformation,
|
227
|
-
});
|
228
|
-
const { fromJSON } = (0, velo_1.serializer)({
|
229
|
-
rootSchema: _queryPublicPlansResponse,
|
230
|
-
depSchemas: {},
|
231
|
-
fqdnTransformation: {
|
232
|
-
paths: [],
|
233
|
-
transformation: _toVeloEntity,
|
234
|
-
},
|
235
|
-
customTransformation: responseTransformation,
|
236
|
-
});
|
237
|
-
return (0, motion_edm_autogen_query_wrapper_1.wrapWithQueryBuilder)({
|
238
|
-
func: (payload) => __awaiter(this, void 0, void 0, function* () {
|
239
|
-
var _a, _b, _c;
|
240
|
-
const reqOpts = ambassadorWixPricingPlansV2Plan.queryPublicPlans(payload);
|
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 result;
|
246
|
-
}
|
247
|
-
catch (err) {
|
248
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
249
|
-
throw err;
|
250
|
-
}
|
251
|
-
}),
|
252
|
-
requestTransformer: (...args) => toAmbassadorRequest(args),
|
253
|
-
responseTransformer: ({ data }) => fromJSON(data),
|
254
|
-
errorTransformer: (err) => {
|
255
|
-
const transformedError = (0, velo_1.transformError)(err, requestTransformation);
|
256
|
-
throw transformedError;
|
257
|
-
},
|
258
|
-
pagingMethod: 'OFFSET',
|
259
|
-
transformationPaths: (0, velo_1.resolveQueryFieldsTransformationPaths)(_toVeloEntity),
|
260
|
-
})({ cursorWithEmptyFilterAndSort: true });
|
261
|
-
}
|
262
|
-
exports.queryPublicPlans = queryPublicPlans;
|
263
|
-
/**
|
264
|
-
* Retrieves a pricing plan by the specified ID.
|
265
|
-
*
|
266
|
-
* The `getPlan()` function returns a Promise that resolves to a plan whose ID matched the specified ID.
|
267
|
-
* @param _id - Plan ID.
|
268
|
-
* @public
|
269
|
-
* @requiredField _id
|
270
|
-
* @permissionScope Read Pricing Plans
|
271
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.READ-PLANS
|
272
|
-
* @permissionScope Manage Pricing Plans
|
273
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
|
274
|
-
* @applicableIdentity APP
|
275
|
-
* @returns Fulfilled - The retrieved plan's information.
|
276
|
-
*/
|
277
|
-
function getPlan(_id) {
|
278
|
-
var _a, _b, _c;
|
279
|
-
return __awaiter(this, arguments, void 0, function* () {
|
280
|
-
const requestTransformation = { id: '$[0]' };
|
281
|
-
const responseTransformation = '$.plan';
|
282
|
-
// @ts-ignore
|
283
|
-
const { httpClient, sideEffects } = arguments[1];
|
284
|
-
const { toAmbassadorRequest } = (0, velo_1.serializer)({
|
285
|
-
rootSchema: _getPlanRequest,
|
286
|
-
depSchemas: {},
|
287
|
-
fqdnTransformation: {
|
288
|
-
paths: [],
|
289
|
-
transformation: _fromVeloEntity,
|
290
|
-
},
|
291
|
-
customTransformation: requestTransformation,
|
292
|
-
});
|
293
|
-
const { fromJSON } = (0, velo_1.serializer)({
|
294
|
-
rootSchema: _getPlanResponse,
|
295
|
-
depSchemas: {},
|
296
|
-
fqdnTransformation: {
|
297
|
-
paths: [...['plan']],
|
298
|
-
transformation: _toVeloEntity,
|
299
|
-
},
|
300
|
-
customTransformation: responseTransformation,
|
301
|
-
});
|
302
|
-
const payload = toAmbassadorRequest([_id]);
|
303
|
-
const reqOpts = ambassadorWixPricingPlansV2Plan.getPlan(payload);
|
304
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
305
|
-
try {
|
306
|
-
const result = yield httpClient.request(reqOpts);
|
307
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
308
|
-
return fromJSON(result.data);
|
309
|
-
}
|
310
|
-
catch (err) {
|
311
|
-
const transformedError = (0, transform_error_1.transformError)(err, {
|
312
|
-
spreadPathsToArguments: {},
|
313
|
-
explicitPathsToArguments: { id: '$[0]' },
|
314
|
-
singleArgumentUnchanged: false,
|
315
|
-
}, ['_id']);
|
316
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
317
|
-
throw transformedError;
|
318
|
-
}
|
319
|
-
});
|
320
|
-
}
|
321
|
-
exports.getPlan = getPlan;
|
322
|
-
/**
|
323
|
-
* Retrieves a list of pricing plans.
|
324
|
-
*
|
325
|
-
* The `listPlans()` function returns a Promise that resolves to a list of up to 100 pricing plans. This includes public, hidden, and archived plans.
|
326
|
-
* @public
|
327
|
-
* @documentationMaturity preview
|
328
|
-
* @param options - Options for filtering and paging the list of plans.
|
329
|
-
* @permissionScope Read Pricing Plans
|
330
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.READ-PLANS
|
331
|
-
* @permissionScope Manage Pricing Plans
|
332
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
|
333
|
-
* @applicableIdentity APP
|
334
|
-
* @returns Fulfilled - List of plans that match the given criteria.
|
335
|
-
*/
|
336
|
-
function listPlans(options) {
|
337
|
-
var _a, _b, _c;
|
338
|
-
return __awaiter(this, arguments, void 0, function* () {
|
339
|
-
const requestTransformation = {
|
340
|
-
archived: '$[0].archived',
|
341
|
-
public: '$[0].public',
|
342
|
-
limit: '$[0].limit',
|
343
|
-
offset: '$[0].offset',
|
344
|
-
planIds: '$[0].planIds',
|
345
|
-
};
|
346
|
-
const responseTransformation = '$';
|
347
|
-
// @ts-ignore
|
348
|
-
const { httpClient, sideEffects } = arguments[1];
|
349
|
-
const { toAmbassadorRequest } = (0, velo_1.serializer)({
|
350
|
-
rootSchema: _listPlansRequest,
|
351
|
-
depSchemas: {},
|
352
|
-
fqdnTransformation: {
|
353
|
-
paths: [],
|
354
|
-
transformation: _fromVeloEntity,
|
355
|
-
},
|
356
|
-
customTransformation: requestTransformation,
|
357
|
-
});
|
358
|
-
const { fromJSON } = (0, velo_1.serializer)({
|
359
|
-
rootSchema: _listPlansResponse,
|
360
|
-
depSchemas: {},
|
361
|
-
fqdnTransformation: {
|
362
|
-
paths: [...['Array#plans']],
|
363
|
-
transformation: _toVeloEntity,
|
364
|
-
},
|
365
|
-
customTransformation: responseTransformation,
|
366
|
-
});
|
367
|
-
const payload = toAmbassadorRequest([options]);
|
368
|
-
const reqOpts = ambassadorWixPricingPlansV2Plan.listPlans(payload);
|
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 = (0, transform_error_1.transformError)(err, {
|
377
|
-
spreadPathsToArguments: {},
|
378
|
-
explicitPathsToArguments: {
|
379
|
-
archived: '$[0].archived',
|
380
|
-
public: '$[0].public',
|
381
|
-
limit: '$[0].limit',
|
382
|
-
offset: '$[0].offset',
|
383
|
-
planIds: '$[0].planIds',
|
384
|
-
},
|
385
|
-
singleArgumentUnchanged: false,
|
386
|
-
}, ['options']);
|
387
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
388
|
-
throw transformedError;
|
389
|
-
}
|
390
|
-
});
|
391
|
-
}
|
392
|
-
exports.listPlans = listPlans;
|
393
|
-
/**
|
394
|
-
* Retrieves statistics about the pricing plans.
|
395
|
-
*
|
396
|
-
*
|
397
|
-
* The `getPlanStats()` function returns a Promise that resolves to statistics about the plan on the site.
|
398
|
-
*
|
399
|
-
* Currently this function provides only the total number of pricing plans, including archived plans.
|
400
|
-
* @public
|
401
|
-
* @permissionScope Read Pricing Plans
|
402
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.READ-PLANS
|
403
|
-
* @permissionScope Manage Pricing Plans
|
404
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
|
405
|
-
* @applicableIdentity APP
|
406
|
-
* @returns Fulfilled - Overall statistics about the pricing plans.
|
407
|
-
*/
|
408
|
-
function getPlanStats() {
|
409
|
-
var _a, _b, _c;
|
410
|
-
return __awaiter(this, arguments, void 0, function* () {
|
411
|
-
const requestTransformation = {};
|
412
|
-
const responseTransformation = '$';
|
413
|
-
// @ts-ignore
|
414
|
-
const { httpClient, sideEffects } = arguments[0];
|
415
|
-
const { toAmbassadorRequest } = (0, velo_1.serializer)({
|
416
|
-
rootSchema: _getPlanStatsRequest,
|
417
|
-
depSchemas: {},
|
418
|
-
fqdnTransformation: {
|
419
|
-
paths: [],
|
420
|
-
transformation: _fromVeloEntity,
|
421
|
-
},
|
422
|
-
customTransformation: requestTransformation,
|
423
|
-
});
|
424
|
-
const { fromJSON } = (0, velo_1.serializer)({
|
425
|
-
rootSchema: _getPlanStatsResponse,
|
426
|
-
depSchemas: {},
|
427
|
-
fqdnTransformation: {
|
428
|
-
paths: [],
|
429
|
-
transformation: _toVeloEntity,
|
430
|
-
},
|
431
|
-
customTransformation: responseTransformation,
|
432
|
-
});
|
433
|
-
const payload = toAmbassadorRequest([]);
|
434
|
-
const reqOpts = ambassadorWixPricingPlansV2Plan.getPlanStats(payload);
|
435
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
436
|
-
try {
|
437
|
-
const result = yield httpClient.request(reqOpts);
|
438
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
439
|
-
return fromJSON(result.data);
|
440
|
-
}
|
441
|
-
catch (err) {
|
442
|
-
const transformedError = (0, transform_error_1.transformError)(err, {
|
443
|
-
spreadPathsToArguments: {},
|
444
|
-
explicitPathsToArguments: {},
|
445
|
-
singleArgumentUnchanged: false,
|
446
|
-
}, []);
|
447
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
448
|
-
throw transformedError;
|
449
|
-
}
|
450
|
-
});
|
451
|
-
}
|
452
|
-
exports.getPlanStats = getPlanStats;
|
453
|
-
/**
|
454
|
-
* Creates a pricing plan.
|
455
|
-
*
|
456
|
-
*
|
457
|
-
* The `createPlan()` function returns a Promise that resolves to a newly-created pricing plan after is has successfully been created.
|
458
|
-
*
|
459
|
-
* The passed `plan` object must contain a [pricing model](https://www.wix.com/velo/reference/wix-pricing-plans-v2/plans/pricing-models). A pricing model can be one of the following:
|
460
|
-
* - **A subscription**: A subscription with recurring payment and how often the plan occurs. Subscriptions can have free trial days.
|
461
|
-
* - **A plan that does not renew**: A single payment for a specific duration that doesn't renew.
|
462
|
-
* - **An unlimited plan**: A single payment for an unlimited amount of time (until canceled).
|
463
|
-
*
|
464
|
-
* Pricing plans created by this function are available to the site owner in the Pricing Plans section in the Dashboard.
|
465
|
-
* @public
|
466
|
-
* @requiredField plan
|
467
|
-
* @requiredField plan.name
|
468
|
-
* @requiredField plan.pricing
|
469
|
-
* @requiredField plan.pricing.singlePaymentForDuration.count
|
470
|
-
* @requiredField plan.pricing.subscription.cycleCount
|
471
|
-
* @requiredField plan.pricing.subscription.cycleDuration
|
472
|
-
* @requiredField plan.pricing.subscription.cycleDuration.count
|
473
|
-
* @param plan - Information for the plan being created.
|
474
|
-
* @permissionScope Manage Pricing Plans
|
475
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
|
476
|
-
* @applicableIdentity APP
|
477
|
-
* @returns Fulfilled - The created plan.
|
478
|
-
*
|
479
|
-
* Rejected - Error message.
|
480
|
-
*/
|
481
|
-
function createPlan(plan) {
|
482
|
-
var _a, _b, _c;
|
483
|
-
return __awaiter(this, arguments, void 0, function* () {
|
484
|
-
const requestTransformation = { plan: '$[0]' };
|
485
|
-
const responseTransformation = '$.plan';
|
486
|
-
// @ts-ignore
|
487
|
-
const { httpClient, sideEffects } = arguments[1];
|
488
|
-
const { toAmbassadorRequest } = (0, velo_1.serializer)({
|
489
|
-
rootSchema: _createPlanRequest,
|
490
|
-
depSchemas: {},
|
491
|
-
fqdnTransformation: {
|
492
|
-
paths: [...['plan']],
|
493
|
-
transformation: _fromVeloEntity,
|
494
|
-
},
|
495
|
-
customTransformation: requestTransformation,
|
496
|
-
});
|
497
|
-
const { fromJSON } = (0, velo_1.serializer)({
|
498
|
-
rootSchema: _createPlanResponse,
|
499
|
-
depSchemas: {},
|
500
|
-
fqdnTransformation: {
|
501
|
-
paths: [...['plan']],
|
502
|
-
transformation: _toVeloEntity,
|
503
|
-
},
|
504
|
-
customTransformation: responseTransformation,
|
505
|
-
});
|
506
|
-
const payload = toAmbassadorRequest([plan]);
|
507
|
-
const reqOpts = ambassadorWixPricingPlansV2Plan.createPlan(payload);
|
508
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
509
|
-
try {
|
510
|
-
const result = yield httpClient.request(reqOpts);
|
511
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
512
|
-
return fromJSON(result.data);
|
513
|
-
}
|
514
|
-
catch (err) {
|
515
|
-
const transformedError = (0, transform_error_1.transformError)(err, {
|
516
|
-
spreadPathsToArguments: {},
|
517
|
-
explicitPathsToArguments: { plan: '$[0]' },
|
518
|
-
singleArgumentUnchanged: false,
|
519
|
-
}, ['plan']);
|
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.createPlan = createPlan;
|
526
|
-
/**
|
527
|
-
* Updates a pricing plan.
|
528
|
-
*
|
529
|
-
*
|
530
|
-
* The `updatePlan()` function returns a Promise that resolves to an updated plan.
|
531
|
-
*
|
532
|
-
* Updating a plan does not impact existing purchases made for the plan. All purchases keep the details of the original plan that was active at the time of the purchase.
|
533
|
-
* @public
|
534
|
-
* @requiredField _id
|
535
|
-
* @requiredField plan
|
536
|
-
* @param _id - ID of the plan to update.
|
537
|
-
* @param options - Options for updating the plan.
|
538
|
-
* @permissionScope Manage Pricing Plans
|
539
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
|
540
|
-
* @applicableIdentity APP
|
541
|
-
* @returns Fulfilled - The updated plan.
|
542
|
-
*
|
543
|
-
* Rejected - Error message.
|
544
|
-
*/
|
545
|
-
function updatePlan(_id, plan) {
|
546
|
-
var _a, _b, _c;
|
547
|
-
return __awaiter(this, arguments, void 0, function* () {
|
548
|
-
const requestTransformation = { plan: { '*': '$[1]', id: '$[0]' } };
|
549
|
-
const responseTransformation = '$.plan';
|
550
|
-
// @ts-ignore
|
551
|
-
const { httpClient, sideEffects } = arguments[2];
|
552
|
-
const { toAmbassadorRequest } = (0, velo_1.serializer)({
|
553
|
-
rootSchema: _updatePlanRequest,
|
554
|
-
depSchemas: {},
|
555
|
-
fqdnTransformation: {
|
556
|
-
paths: [...['plan']],
|
557
|
-
transformation: _fromVeloEntity,
|
558
|
-
},
|
559
|
-
customTransformation: requestTransformation,
|
560
|
-
});
|
561
|
-
const { fromJSON } = (0, velo_1.serializer)({
|
562
|
-
rootSchema: _updatePlanResponse,
|
563
|
-
depSchemas: {},
|
564
|
-
fqdnTransformation: {
|
565
|
-
paths: [...['plan']],
|
566
|
-
transformation: _toVeloEntity,
|
567
|
-
},
|
568
|
-
customTransformation: responseTransformation,
|
569
|
-
});
|
570
|
-
const payload = toAmbassadorRequest([_id, plan]);
|
571
|
-
const reqOpts = ambassadorWixPricingPlansV2Plan.updatePlan(payload);
|
572
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
573
|
-
try {
|
574
|
-
const result = yield httpClient.request(reqOpts);
|
575
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
576
|
-
return fromJSON(result.data);
|
577
|
-
}
|
578
|
-
catch (err) {
|
579
|
-
const transformedError = (0, transform_error_1.transformError)(err, {
|
580
|
-
spreadPathsToArguments: { plan: '$[1]' },
|
581
|
-
explicitPathsToArguments: { 'plan.id': '$[0]' },
|
582
|
-
singleArgumentUnchanged: false,
|
583
|
-
}, ['_id', 'plan']);
|
584
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
585
|
-
throw transformedError;
|
586
|
-
}
|
587
|
-
});
|
588
|
-
}
|
589
|
-
exports.updatePlan = updatePlan;
|
590
|
-
/**
|
591
|
-
* Sets visibility for non-archived pricing plans.
|
592
|
-
*
|
593
|
-
* The `setPlanVisibility()` functions returns a Promise that resolves to a pricing plan when its visibility has successfully been set.
|
594
|
-
*
|
595
|
-
* By default, pricing plans are public, meaning they are visible. [Plans can be hidden](https://support.wix.com/en/article/pricing-plans-removing-a-plan-from-your-site#hiding-plans) so that site members and visitors cannot see or choose them.
|
596
|
-
*
|
597
|
-
* 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).
|
598
|
-
*
|
599
|
-
* >**Note:** An archived plan always remains archived and cannot be made active again. When archiving a plan, its `public` property is automatically set to `false` so that it is hidden.
|
600
|
-
*
|
601
|
-
* Changing a plan's visibility does not impact existing orders for the plan. All orders for hidden plans are still active and keep their terms and payment options.
|
602
|
-
* @param visible - Whether to set the plan as visible.
|
603
|
-
* @public
|
604
|
-
* @requiredField _id
|
605
|
-
* @requiredField visible
|
606
|
-
* @param _id - The ID of the plan to either display or hide on the site page.
|
607
|
-
* @param options - Plan visibility options.
|
608
|
-
* @permissionScope Manage Pricing Plans
|
609
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
|
610
|
-
* @applicableIdentity APP
|
611
|
-
* @returns Fulfilled - The plan's information.
|
612
|
-
*
|
613
|
-
* Rejected - Error message.
|
614
|
-
*/
|
615
|
-
function setPlanVisibility(_id, visible) {
|
616
|
-
var _a, _b, _c;
|
617
|
-
return __awaiter(this, arguments, void 0, function* () {
|
618
|
-
const requestTransformation = { id: '$[0]', visible: '$[1]' };
|
619
|
-
const responseTransformation = '$';
|
620
|
-
// @ts-ignore
|
621
|
-
const { httpClient, sideEffects } = arguments[2];
|
622
|
-
const { toAmbassadorRequest } = (0, velo_1.serializer)({
|
623
|
-
rootSchema: _setPlanVisibilityRequest,
|
624
|
-
depSchemas: {},
|
625
|
-
fqdnTransformation: {
|
626
|
-
paths: [],
|
627
|
-
transformation: _fromVeloEntity,
|
628
|
-
},
|
629
|
-
customTransformation: requestTransformation,
|
630
|
-
});
|
631
|
-
const { fromJSON } = (0, velo_1.serializer)({
|
632
|
-
rootSchema: _setPlanVisibilityResponse,
|
633
|
-
depSchemas: {},
|
634
|
-
fqdnTransformation: {
|
635
|
-
paths: [...['plan']],
|
636
|
-
transformation: _toVeloEntity,
|
637
|
-
},
|
638
|
-
customTransformation: responseTransformation,
|
639
|
-
});
|
640
|
-
const payload = toAmbassadorRequest([_id, visible]);
|
641
|
-
const reqOpts = ambassadorWixPricingPlansV2Plan.setPlanVisibility(payload);
|
642
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
643
|
-
try {
|
644
|
-
const result = yield httpClient.request(reqOpts);
|
645
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
646
|
-
return fromJSON(result.data);
|
647
|
-
}
|
648
|
-
catch (err) {
|
649
|
-
const transformedError = (0, transform_error_1.transformError)(err, {
|
650
|
-
spreadPathsToArguments: {},
|
651
|
-
explicitPathsToArguments: { id: '$[0]', visible: '$[1]' },
|
652
|
-
singleArgumentUnchanged: false,
|
653
|
-
}, ['_id', 'visible']);
|
654
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
655
|
-
throw transformedError;
|
656
|
-
}
|
657
|
-
});
|
658
|
-
}
|
659
|
-
exports.setPlanVisibility = setPlanVisibility;
|
660
|
-
/**
|
661
|
-
* Marks a pricing plan as the primary pricing plan.
|
662
|
-
*
|
663
|
-
*
|
664
|
-
* The `makePlanPrimary()` function returns a Promise that resolves to the now primary pricing plan.
|
665
|
-
*
|
666
|
-
* Only a single plan can be marked as a primary plan at any given time. If there is an existing plan marked as primary, calling `makePlanPrimary()` causes the existing primary plan to lose its primary status.
|
667
|
-
*
|
668
|
-
* When viewing pricing plans on the site, the primary plan is highlighted with a customizable ribbon.
|
669
|
-
* @public
|
670
|
-
* @requiredField _id
|
671
|
-
* @param _id - ID of the pricing plan to set as the primary plan.
|
672
|
-
* @permissionScope Manage Pricing Plans
|
673
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
|
674
|
-
* @applicableIdentity APP
|
675
|
-
* @returns Fulfilled - The primary plan.
|
676
|
-
*/
|
677
|
-
function makePlanPrimary(_id) {
|
678
|
-
var _a, _b, _c;
|
679
|
-
return __awaiter(this, arguments, void 0, function* () {
|
680
|
-
const requestTransformation = { id: '$[0]' };
|
681
|
-
const responseTransformation = '$';
|
682
|
-
// @ts-ignore
|
683
|
-
const { httpClient, sideEffects } = arguments[1];
|
684
|
-
const { toAmbassadorRequest } = (0, velo_1.serializer)({
|
685
|
-
rootSchema: _makePlanPrimaryRequest,
|
686
|
-
depSchemas: {},
|
687
|
-
fqdnTransformation: {
|
688
|
-
paths: [],
|
689
|
-
transformation: _fromVeloEntity,
|
690
|
-
},
|
691
|
-
customTransformation: requestTransformation,
|
692
|
-
});
|
693
|
-
const { fromJSON } = (0, velo_1.serializer)({
|
694
|
-
rootSchema: _makePlanPrimaryResponse,
|
695
|
-
depSchemas: {},
|
696
|
-
fqdnTransformation: {
|
697
|
-
paths: [...['plan']],
|
698
|
-
transformation: _toVeloEntity,
|
699
|
-
},
|
700
|
-
customTransformation: responseTransformation,
|
701
|
-
});
|
702
|
-
const payload = toAmbassadorRequest([_id]);
|
703
|
-
const reqOpts = ambassadorWixPricingPlansV2Plan.makePlanPrimary(payload);
|
704
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
705
|
-
try {
|
706
|
-
const result = yield httpClient.request(reqOpts);
|
707
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
708
|
-
return fromJSON(result.data);
|
709
|
-
}
|
710
|
-
catch (err) {
|
711
|
-
const transformedError = (0, transform_error_1.transformError)(err, {
|
712
|
-
spreadPathsToArguments: {},
|
713
|
-
explicitPathsToArguments: { id: '$[0]' },
|
714
|
-
singleArgumentUnchanged: false,
|
715
|
-
}, ['_id']);
|
716
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
717
|
-
throw transformedError;
|
718
|
-
}
|
719
|
-
});
|
720
|
-
}
|
721
|
-
exports.makePlanPrimary = makePlanPrimary;
|
722
|
-
/**
|
723
|
-
* Sets all pricing plans to no longer be primary.
|
724
|
-
*
|
725
|
-
* The `clearPrimary()` function returns a Promise that is resolved when there are no pricing plans marked as `primary`.
|
726
|
-
*
|
727
|
-
* After clearing the primary plan, when viewing pricing plans on the site, no plan is highlighted with a customizable ribbon.
|
728
|
-
* @public
|
729
|
-
* @permissionScope Manage Pricing Plans
|
730
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
|
731
|
-
* @applicableIdentity APP
|
732
|
-
*/
|
733
|
-
function clearPrimary() {
|
734
|
-
var _a, _b, _c;
|
735
|
-
return __awaiter(this, arguments, void 0, function* () {
|
736
|
-
const requestTransformation = {};
|
737
|
-
const responseTransformation = '$';
|
738
|
-
// @ts-ignore
|
739
|
-
const { httpClient, sideEffects } = arguments[0];
|
740
|
-
const { toAmbassadorRequest } = (0, velo_1.serializer)({
|
741
|
-
rootSchema: _clearPrimaryRequest,
|
742
|
-
depSchemas: {},
|
743
|
-
fqdnTransformation: {
|
744
|
-
paths: [],
|
745
|
-
transformation: _fromVeloEntity,
|
746
|
-
},
|
747
|
-
customTransformation: requestTransformation,
|
748
|
-
});
|
749
|
-
const { fromJSON } = (0, velo_1.serializer)({
|
750
|
-
rootSchema: _clearPrimaryResponse,
|
751
|
-
depSchemas: {},
|
752
|
-
fqdnTransformation: {
|
753
|
-
paths: [],
|
754
|
-
transformation: _toVeloEntity,
|
755
|
-
},
|
756
|
-
customTransformation: responseTransformation,
|
757
|
-
});
|
758
|
-
const payload = toAmbassadorRequest([]);
|
759
|
-
const reqOpts = ambassadorWixPricingPlansV2Plan.clearPrimary(payload);
|
760
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
761
|
-
try {
|
762
|
-
const result = yield httpClient.request(reqOpts);
|
763
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
764
|
-
}
|
765
|
-
catch (err) {
|
766
|
-
const transformedError = (0, transform_error_1.transformError)(err, {
|
767
|
-
spreadPathsToArguments: {},
|
768
|
-
explicitPathsToArguments: {},
|
769
|
-
singleArgumentUnchanged: false,
|
770
|
-
}, []);
|
771
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
772
|
-
throw transformedError;
|
773
|
-
}
|
774
|
-
});
|
775
|
-
}
|
776
|
-
exports.clearPrimary = clearPrimary;
|
777
|
-
/**
|
778
|
-
* Archives a single plan.
|
779
|
-
*
|
780
|
-
*
|
781
|
-
* The `archivePlan()` function returns a Promise that resolves to the newly-archived plan.
|
782
|
-
*
|
783
|
-
* When a plan is archived, the plan
|
784
|
-
* - Is no longer available for display or selection by visitors. This is because the plan's `public` property is automatically set to `false`.
|
785
|
-
* - Cannot be purchased.
|
786
|
-
* - Cannot be "un-archived", meaning the plan cannot be made active again.
|
787
|
-
*
|
788
|
-
* Plan archiving does not impact existing purchases made for the plan. All purchases for the plan are still active and keep their payment options and terms.
|
789
|
-
*
|
790
|
-
* Site owners can see archived plans in the Dashboard under **Pricing Plans -> Archived Plans**.
|
791
|
-
*
|
792
|
-
* >**Note:** An attempt to archive an already-archived plan throws an error.
|
793
|
-
* @public
|
794
|
-
* @requiredField _id
|
795
|
-
* @param _id - ID of the active plan to archive.
|
796
|
-
* @permissionScope Manage Pricing Plans
|
797
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
|
798
|
-
* @applicableIdentity APP
|
799
|
-
* @returns Fulfilled - The archived plan.
|
800
|
-
*
|
801
|
-
* Rejected - Error message.
|
802
|
-
*/
|
803
|
-
function archivePlan(_id) {
|
804
|
-
var _a, _b, _c;
|
805
|
-
return __awaiter(this, arguments, void 0, function* () {
|
806
|
-
const requestTransformation = { id: '$[0]' };
|
807
|
-
const responseTransformation = '$';
|
808
|
-
// @ts-ignore
|
809
|
-
const { httpClient, sideEffects } = arguments[1];
|
810
|
-
const { toAmbassadorRequest } = (0, velo_1.serializer)({
|
811
|
-
rootSchema: _archivePlanRequest,
|
812
|
-
depSchemas: {},
|
813
|
-
fqdnTransformation: {
|
814
|
-
paths: [],
|
815
|
-
transformation: _fromVeloEntity,
|
816
|
-
},
|
817
|
-
customTransformation: requestTransformation,
|
818
|
-
});
|
819
|
-
const { fromJSON } = (0, velo_1.serializer)({
|
820
|
-
rootSchema: _archivePlanResponse,
|
821
|
-
depSchemas: {},
|
822
|
-
fqdnTransformation: {
|
823
|
-
paths: [...['plan']],
|
824
|
-
transformation: _toVeloEntity,
|
825
|
-
},
|
826
|
-
customTransformation: responseTransformation,
|
827
|
-
});
|
828
|
-
const payload = toAmbassadorRequest([_id]);
|
829
|
-
const reqOpts = ambassadorWixPricingPlansV2Plan.archivePlan(payload);
|
830
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
831
|
-
try {
|
832
|
-
const result = yield httpClient.request(reqOpts);
|
833
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
834
|
-
return fromJSON(result.data);
|
835
|
-
}
|
836
|
-
catch (err) {
|
837
|
-
const transformedError = (0, transform_error_1.transformError)(err, {
|
838
|
-
spreadPathsToArguments: {},
|
839
|
-
explicitPathsToArguments: { id: '$[0]' },
|
840
|
-
singleArgumentUnchanged: false,
|
841
|
-
}, ['_id']);
|
842
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
843
|
-
throw transformedError;
|
844
|
-
}
|
845
|
-
});
|
846
|
-
}
|
847
|
-
exports.archivePlan = archivePlan;
|
848
|
-
/**
|
849
|
-
* Changes the display order of the pricing plans on the site page and in the Dashboard.
|
850
|
-
*
|
851
|
-
*
|
852
|
-
* The `arrangePlans()` function returns a Promise that resolves when the plans are rearranged on the site page and in the Dashboard.
|
853
|
-
*
|
854
|
-
* To rearrange the order of the plans, provide a list of the IDs for all non-archived plans in the desired order, including hidden plans.
|
855
|
-
*
|
856
|
-
* >**Note:** Make sure to provide *all* non-archived plan IDs to avoid unpredictable results.
|
857
|
-
* @param ids - IDs of all non-archived plans in the order you want them arranged.
|
858
|
-
* @public
|
859
|
-
* @requiredField ids
|
860
|
-
* @permissionScope Manage Pricing Plans
|
861
|
-
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
|
862
|
-
* @applicableIdentity APP
|
863
|
-
*/
|
864
|
-
function arrangePlans(ids) {
|
865
|
-
var _a, _b, _c;
|
866
|
-
return __awaiter(this, arguments, void 0, function* () {
|
867
|
-
const requestTransformation = { ids: '$[0]' };
|
868
|
-
const responseTransformation = '$';
|
869
|
-
// @ts-ignore
|
870
|
-
const { httpClient, sideEffects } = arguments[1];
|
871
|
-
const { toAmbassadorRequest } = (0, velo_1.serializer)({
|
872
|
-
rootSchema: _arrangePlansRequest,
|
873
|
-
depSchemas: {},
|
874
|
-
fqdnTransformation: {
|
875
|
-
paths: [],
|
876
|
-
transformation: _fromVeloEntity,
|
877
|
-
},
|
878
|
-
customTransformation: requestTransformation,
|
879
|
-
});
|
880
|
-
const { fromJSON } = (0, velo_1.serializer)({
|
881
|
-
rootSchema: _arrangePlansResponse,
|
882
|
-
depSchemas: {},
|
883
|
-
fqdnTransformation: {
|
884
|
-
paths: [],
|
885
|
-
transformation: _toVeloEntity,
|
886
|
-
},
|
887
|
-
customTransformation: responseTransformation,
|
888
|
-
});
|
889
|
-
const payload = toAmbassadorRequest([ids]);
|
890
|
-
const reqOpts = ambassadorWixPricingPlansV2Plan.arrangePlans(payload);
|
891
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
892
|
-
try {
|
893
|
-
const result = yield httpClient.request(reqOpts);
|
894
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
895
|
-
}
|
896
|
-
catch (err) {
|
897
|
-
const transformedError = (0, transform_error_1.transformError)(err, {
|
898
|
-
spreadPathsToArguments: {},
|
899
|
-
explicitPathsToArguments: { ids: '$[0]' },
|
900
|
-
singleArgumentUnchanged: false,
|
901
|
-
}, ['ids']);
|
902
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
903
|
-
throw transformedError;
|
904
|
-
}
|
905
|
-
});
|
906
|
-
}
|
907
|
-
exports.arrangePlans = arrangePlans;
|
908
|
-
//# sourceMappingURL=pricing-plans-v2-plan.universal.js.map
|