@wix/members 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 +1 -0
- package/build/cjs/index.js +24 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/src/badges-v3-badge.http.d.ts +49 -0
- package/build/cjs/src/badges-v3-badge.http.js +451 -0
- package/build/cjs/src/badges-v3-badge.http.js.map +1 -0
- package/build/cjs/src/badges-v3-badge.public.d.ts +16 -0
- package/build/cjs/src/badges-v3-badge.public.js +79 -0
- package/build/cjs/src/badges-v3-badge.public.js.map +1 -0
- package/build/cjs/src/badges-v3-badge.types.d.ts +250 -0
- package/build/cjs/src/badges-v3-badge.types.js +9 -0
- package/build/cjs/src/badges-v3-badge.types.js.map +1 -0
- package/build/cjs/src/badges-v3-badge.universal.d.ts +456 -0
- package/build/cjs/src/badges-v3-badge.universal.js +711 -0
- package/build/cjs/src/badges-v3-badge.universal.js.map +1 -0
- package/build/es/index.d.ts +1 -0
- package/build/es/index.js +2 -0
- package/build/es/index.js.map +1 -0
- package/build/es/src/badges-v3-badge.http.d.ts +49 -0
- package/build/es/src/badges-v3-badge.http.js +436 -0
- package/build/es/src/badges-v3-badge.http.js.map +1 -0
- package/build/es/src/badges-v3-badge.public.d.ts +16 -0
- package/build/es/src/badges-v3-badge.public.js +63 -0
- package/build/es/src/badges-v3-badge.public.js.map +1 -0
- package/build/es/src/badges-v3-badge.types.d.ts +250 -0
- package/build/es/src/badges-v3-badge.types.js +6 -0
- package/build/es/src/badges-v3-badge.types.js.map +1 -0
- package/build/es/src/badges-v3-badge.universal.d.ts +456 -0
- package/build/es/src/badges-v3-badge.universal.js +677 -0
- package/build/es/src/badges-v3-badge.universal.js.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,677 @@
|
|
|
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 ambassadorWixBadgesV3Badge from './badges-v3-badge.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 SortOrder;
|
|
28
|
+
(function (SortOrder) {
|
|
29
|
+
SortOrder["ASC"] = "ASC";
|
|
30
|
+
SortOrder["DESC"] = "DESC";
|
|
31
|
+
})(SortOrder || (SortOrder = {}));
|
|
32
|
+
const _assignBadgeRequest = {};
|
|
33
|
+
const _assignBadgeResponse = {};
|
|
34
|
+
const _createBadgeRequest = {};
|
|
35
|
+
const _createBadgeResponse = {};
|
|
36
|
+
const _deleteBadgeRequest = {};
|
|
37
|
+
const _deleteBadgeResponse = {};
|
|
38
|
+
const _getBadgeRequest = {};
|
|
39
|
+
const _getBadgeResponse = {};
|
|
40
|
+
const _getMemberCountsPerBadgeRequest = {};
|
|
41
|
+
const _getMemberCountsPerBadgeResponse = {};
|
|
42
|
+
const _listBadgesRequest = {};
|
|
43
|
+
const _listBadgesResponse = {};
|
|
44
|
+
const _listMembersBadgeIdsRequest = {};
|
|
45
|
+
const _listMembersBadgeIdsResponse = {};
|
|
46
|
+
const _listMembersRequest = {};
|
|
47
|
+
const _listMembersResponse = {};
|
|
48
|
+
const _queryBadgesRequest = {};
|
|
49
|
+
const _queryBadgesResponse = {};
|
|
50
|
+
const _unassignBadgeRequest = {};
|
|
51
|
+
const _unassignBadgeResponse = {};
|
|
52
|
+
const _updateBadgeRequest = {};
|
|
53
|
+
const _updateBadgeResponse = {};
|
|
54
|
+
const _updateBadgesDisplayOrderRequest = {};
|
|
55
|
+
const _updateBadgesDisplayOrderResponse = {};
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new badge.
|
|
58
|
+
* @param badge - Badge to create.
|
|
59
|
+
* @public
|
|
60
|
+
* @documentationMaturity preview
|
|
61
|
+
* @requiredField badge
|
|
62
|
+
* @requiredField badge.backgroundColor
|
|
63
|
+
* @requiredField badge.textColor
|
|
64
|
+
* @requiredField badge.title
|
|
65
|
+
*/
|
|
66
|
+
export function createBadge(badge) {
|
|
67
|
+
var _a, _b, _c;
|
|
68
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
69
|
+
const requestTransformation = { badge: '$[0]' };
|
|
70
|
+
const responseTransformation = '$';
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
73
|
+
const { toAmbassadorRequest } = serializer({
|
|
74
|
+
rootSchema: _createBadgeRequest,
|
|
75
|
+
depSchemas: {},
|
|
76
|
+
fqdnTransformation: {
|
|
77
|
+
paths: [...['badge']],
|
|
78
|
+
transformation: _fromVeloEntity,
|
|
79
|
+
},
|
|
80
|
+
customTransformation: requestTransformation,
|
|
81
|
+
});
|
|
82
|
+
const { fromJSON } = serializer({
|
|
83
|
+
rootSchema: _createBadgeResponse,
|
|
84
|
+
depSchemas: {},
|
|
85
|
+
fqdnTransformation: {
|
|
86
|
+
paths: [...['badge']],
|
|
87
|
+
transformation: _toVeloEntity,
|
|
88
|
+
},
|
|
89
|
+
customTransformation: responseTransformation,
|
|
90
|
+
});
|
|
91
|
+
const payload = toAmbassadorRequest([badge]);
|
|
92
|
+
const reqOpts = ambassadorWixBadgesV3Badge.createBadge(payload);
|
|
93
|
+
__log(`"CreateBadge" sending request with: ${__inspect(reqOpts)}`);
|
|
94
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
95
|
+
try {
|
|
96
|
+
const result = yield httpClient.request(reqOpts);
|
|
97
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
98
|
+
return fromJSON(result.data);
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
102
|
+
'badge',
|
|
103
|
+
]);
|
|
104
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
105
|
+
throw transformedError;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Updates a badge's specified properties.
|
|
111
|
+
* @param _id - Badge ID.
|
|
112
|
+
* @public
|
|
113
|
+
* @documentationMaturity preview
|
|
114
|
+
* @requiredField _id
|
|
115
|
+
* @requiredField badge
|
|
116
|
+
*/
|
|
117
|
+
export function updateBadge(_id, badge) {
|
|
118
|
+
var _a, _b, _c;
|
|
119
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
120
|
+
const requestTransformation = { badge: { '*': '$[1]', id: '$[0]' } };
|
|
121
|
+
const responseTransformation = '$';
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
124
|
+
const { toAmbassadorRequest } = serializer({
|
|
125
|
+
rootSchema: _updateBadgeRequest,
|
|
126
|
+
depSchemas: {},
|
|
127
|
+
fqdnTransformation: {
|
|
128
|
+
paths: [...['badge']],
|
|
129
|
+
transformation: _fromVeloEntity,
|
|
130
|
+
},
|
|
131
|
+
customTransformation: requestTransformation,
|
|
132
|
+
});
|
|
133
|
+
const { fromJSON } = serializer({
|
|
134
|
+
rootSchema: _updateBadgeResponse,
|
|
135
|
+
depSchemas: {},
|
|
136
|
+
fqdnTransformation: {
|
|
137
|
+
paths: [...['badge']],
|
|
138
|
+
transformation: _toVeloEntity,
|
|
139
|
+
},
|
|
140
|
+
customTransformation: responseTransformation,
|
|
141
|
+
});
|
|
142
|
+
const payload = toAmbassadorRequest([_id, badge]);
|
|
143
|
+
const reqOpts = ambassadorWixBadgesV3Badge.updateBadge(payload);
|
|
144
|
+
__log(`"UpdateBadge" sending request with: ${__inspect(reqOpts)}`);
|
|
145
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
146
|
+
try {
|
|
147
|
+
const result = yield httpClient.request(reqOpts);
|
|
148
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
149
|
+
return fromJSON(result.data);
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
153
|
+
'_id',
|
|
154
|
+
'badge',
|
|
155
|
+
]);
|
|
156
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
157
|
+
throw transformedError;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Retrieves up to 1000 badges, given the requested paging.
|
|
163
|
+
* Default `paging.limit` is 100, `paging.offset` - 0.
|
|
164
|
+
* For more information, see
|
|
165
|
+
* [API Query Language: The Paging Section](https://dev.wix.com/api/rest/getting-started/api-query-language#getting-started_api-query-language_the-paging-section).
|
|
166
|
+
* @public
|
|
167
|
+
* @documentationMaturity preview
|
|
168
|
+
*/
|
|
169
|
+
export function listBadges(options) {
|
|
170
|
+
var _a, _b, _c;
|
|
171
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
172
|
+
const requestTransformation = { paging: '$[0].paging' };
|
|
173
|
+
const responseTransformation = '$';
|
|
174
|
+
// @ts-ignore
|
|
175
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
176
|
+
const { toAmbassadorRequest } = serializer({
|
|
177
|
+
rootSchema: _listBadgesRequest,
|
|
178
|
+
depSchemas: {},
|
|
179
|
+
fqdnTransformation: {
|
|
180
|
+
paths: [],
|
|
181
|
+
transformation: _fromVeloEntity,
|
|
182
|
+
},
|
|
183
|
+
customTransformation: requestTransformation,
|
|
184
|
+
});
|
|
185
|
+
const { fromJSON } = serializer({
|
|
186
|
+
rootSchema: _listBadgesResponse,
|
|
187
|
+
depSchemas: {},
|
|
188
|
+
fqdnTransformation: {
|
|
189
|
+
paths: [...['Array#badges']],
|
|
190
|
+
transformation: _toVeloEntity,
|
|
191
|
+
},
|
|
192
|
+
customTransformation: responseTransformation,
|
|
193
|
+
});
|
|
194
|
+
const payload = toAmbassadorRequest([options]);
|
|
195
|
+
const reqOpts = ambassadorWixBadgesV3Badge.listBadges(payload);
|
|
196
|
+
__log(`"ListBadges" sending request with: ${__inspect(reqOpts)}`);
|
|
197
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
198
|
+
try {
|
|
199
|
+
const result = yield httpClient.request(reqOpts);
|
|
200
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
201
|
+
return fromJSON(result.data);
|
|
202
|
+
}
|
|
203
|
+
catch (err) {
|
|
204
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
205
|
+
'options',
|
|
206
|
+
]);
|
|
207
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
208
|
+
throw transformedError;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Retrieves up to 1000 badges, given the requested query options, paging, and sorting.
|
|
214
|
+
* Default `paging.limit` is 100, `paging.offset` - 0.
|
|
215
|
+
* For more information, see
|
|
216
|
+
* [API Query Language: The Paging Section](https://dev.wix.com/api/rest/getting-started/api-query-language#getting-started_api-query-language_the-paging-section).
|
|
217
|
+
* @public
|
|
218
|
+
* @documentationMaturity preview
|
|
219
|
+
*/
|
|
220
|
+
export function queryBadges(options) {
|
|
221
|
+
var _a, _b, _c;
|
|
222
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
223
|
+
const requestTransformation = {
|
|
224
|
+
filter: '$[0].filter',
|
|
225
|
+
sort: '$[0].sort',
|
|
226
|
+
paging: '$[0].paging',
|
|
227
|
+
};
|
|
228
|
+
const responseTransformation = '$';
|
|
229
|
+
// @ts-ignore
|
|
230
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
231
|
+
const { toAmbassadorRequest } = serializer({
|
|
232
|
+
rootSchema: _queryBadgesRequest,
|
|
233
|
+
depSchemas: {},
|
|
234
|
+
fqdnTransformation: {
|
|
235
|
+
paths: [],
|
|
236
|
+
transformation: _fromVeloEntity,
|
|
237
|
+
},
|
|
238
|
+
customTransformation: requestTransformation,
|
|
239
|
+
});
|
|
240
|
+
const { fromJSON } = serializer({
|
|
241
|
+
rootSchema: _queryBadgesResponse,
|
|
242
|
+
depSchemas: {},
|
|
243
|
+
fqdnTransformation: {
|
|
244
|
+
paths: [...['Array#badges']],
|
|
245
|
+
transformation: _toVeloEntity,
|
|
246
|
+
},
|
|
247
|
+
customTransformation: responseTransformation,
|
|
248
|
+
});
|
|
249
|
+
const payload = toAmbassadorRequest([options]);
|
|
250
|
+
const reqOpts = ambassadorWixBadgesV3Badge.queryBadges(payload);
|
|
251
|
+
__log(`"QueryBadges" sending request with: ${__inspect(reqOpts)}`);
|
|
252
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
253
|
+
try {
|
|
254
|
+
const result = yield httpClient.request(reqOpts);
|
|
255
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
256
|
+
return fromJSON(result.data);
|
|
257
|
+
}
|
|
258
|
+
catch (err) {
|
|
259
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
260
|
+
'options',
|
|
261
|
+
]);
|
|
262
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
263
|
+
throw transformedError;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Retrieves a badge.
|
|
269
|
+
* @param _id - Badge ID.
|
|
270
|
+
* @public
|
|
271
|
+
* @documentationMaturity preview
|
|
272
|
+
* @requiredField _id
|
|
273
|
+
*/
|
|
274
|
+
export function getBadge(_id) {
|
|
275
|
+
var _a, _b, _c;
|
|
276
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
277
|
+
const requestTransformation = { id: '$[0]' };
|
|
278
|
+
const responseTransformation = '$';
|
|
279
|
+
// @ts-ignore
|
|
280
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
281
|
+
const { toAmbassadorRequest } = serializer({
|
|
282
|
+
rootSchema: _getBadgeRequest,
|
|
283
|
+
depSchemas: {},
|
|
284
|
+
fqdnTransformation: {
|
|
285
|
+
paths: [],
|
|
286
|
+
transformation: _fromVeloEntity,
|
|
287
|
+
},
|
|
288
|
+
customTransformation: requestTransformation,
|
|
289
|
+
});
|
|
290
|
+
const { fromJSON } = serializer({
|
|
291
|
+
rootSchema: _getBadgeResponse,
|
|
292
|
+
depSchemas: {},
|
|
293
|
+
fqdnTransformation: {
|
|
294
|
+
paths: [...['badge']],
|
|
295
|
+
transformation: _toVeloEntity,
|
|
296
|
+
},
|
|
297
|
+
customTransformation: responseTransformation,
|
|
298
|
+
});
|
|
299
|
+
const payload = toAmbassadorRequest([_id]);
|
|
300
|
+
const reqOpts = ambassadorWixBadgesV3Badge.getBadge(payload);
|
|
301
|
+
__log(`"GetBadge" sending request with: ${__inspect(reqOpts)}`);
|
|
302
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
303
|
+
try {
|
|
304
|
+
const result = yield httpClient.request(reqOpts);
|
|
305
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
306
|
+
return fromJSON(result.data);
|
|
307
|
+
}
|
|
308
|
+
catch (err) {
|
|
309
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
310
|
+
'_id',
|
|
311
|
+
]);
|
|
312
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
313
|
+
throw transformedError;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Deletes a badge.
|
|
319
|
+
* @param _id - Badge ID.
|
|
320
|
+
* @public
|
|
321
|
+
* @documentationMaturity preview
|
|
322
|
+
* @requiredField _id
|
|
323
|
+
*/
|
|
324
|
+
export function deleteBadge(_id) {
|
|
325
|
+
var _a, _b, _c;
|
|
326
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
327
|
+
const requestTransformation = { id: '$[0]' };
|
|
328
|
+
const responseTransformation = '$';
|
|
329
|
+
// @ts-ignore
|
|
330
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
331
|
+
const { toAmbassadorRequest } = serializer({
|
|
332
|
+
rootSchema: _deleteBadgeRequest,
|
|
333
|
+
depSchemas: {},
|
|
334
|
+
fqdnTransformation: {
|
|
335
|
+
paths: [],
|
|
336
|
+
transformation: _fromVeloEntity,
|
|
337
|
+
},
|
|
338
|
+
customTransformation: requestTransformation,
|
|
339
|
+
});
|
|
340
|
+
const { fromJSON } = serializer({
|
|
341
|
+
rootSchema: _deleteBadgeResponse,
|
|
342
|
+
depSchemas: {},
|
|
343
|
+
fqdnTransformation: {
|
|
344
|
+
paths: [],
|
|
345
|
+
transformation: _toVeloEntity,
|
|
346
|
+
},
|
|
347
|
+
customTransformation: responseTransformation,
|
|
348
|
+
});
|
|
349
|
+
const payload = toAmbassadorRequest([_id]);
|
|
350
|
+
const reqOpts = ambassadorWixBadgesV3Badge.deleteBadge(payload);
|
|
351
|
+
__log(`"DeleteBadge" sending request with: ${__inspect(reqOpts)}`);
|
|
352
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
353
|
+
try {
|
|
354
|
+
const result = yield httpClient.request(reqOpts);
|
|
355
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
356
|
+
return fromJSON(result.data);
|
|
357
|
+
}
|
|
358
|
+
catch (err) {
|
|
359
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
360
|
+
'_id',
|
|
361
|
+
]);
|
|
362
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
363
|
+
throw transformedError;
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Assigns a badge to the specified members.
|
|
369
|
+
* The members inherit the badge's permissions when they receive the badge, if applicable.
|
|
370
|
+
* Badge permissions are added to previous member permissions (they don't replace existing permissions).
|
|
371
|
+
* @param _id - Badge ID.
|
|
372
|
+
* @param memberIds - List of member IDs to assign to the badge.
|
|
373
|
+
* @public
|
|
374
|
+
* @documentationMaturity preview
|
|
375
|
+
* @requiredField _id
|
|
376
|
+
* @requiredField memberIds
|
|
377
|
+
*/
|
|
378
|
+
export function assignBadge(_id, memberIds) {
|
|
379
|
+
var _a, _b, _c;
|
|
380
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
381
|
+
const requestTransformation = { id: '$[0]', memberIds: '$[1]' };
|
|
382
|
+
const responseTransformation = '$';
|
|
383
|
+
// @ts-ignore
|
|
384
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
385
|
+
const { toAmbassadorRequest } = serializer({
|
|
386
|
+
rootSchema: _assignBadgeRequest,
|
|
387
|
+
depSchemas: {},
|
|
388
|
+
fqdnTransformation: {
|
|
389
|
+
paths: [],
|
|
390
|
+
transformation: _fromVeloEntity,
|
|
391
|
+
},
|
|
392
|
+
customTransformation: requestTransformation,
|
|
393
|
+
});
|
|
394
|
+
const { fromJSON } = serializer({
|
|
395
|
+
rootSchema: _assignBadgeResponse,
|
|
396
|
+
depSchemas: {},
|
|
397
|
+
fqdnTransformation: {
|
|
398
|
+
paths: [],
|
|
399
|
+
transformation: _toVeloEntity,
|
|
400
|
+
},
|
|
401
|
+
customTransformation: responseTransformation,
|
|
402
|
+
});
|
|
403
|
+
const payload = toAmbassadorRequest([_id, memberIds]);
|
|
404
|
+
const reqOpts = ambassadorWixBadgesV3Badge.assignBadge(payload);
|
|
405
|
+
__log(`"AssignBadge" sending request with: ${__inspect(reqOpts)}`);
|
|
406
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
407
|
+
try {
|
|
408
|
+
const result = yield httpClient.request(reqOpts);
|
|
409
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
410
|
+
return fromJSON(result.data);
|
|
411
|
+
}
|
|
412
|
+
catch (err) {
|
|
413
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
414
|
+
'_id',
|
|
415
|
+
'memberIds',
|
|
416
|
+
]);
|
|
417
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
418
|
+
throw transformedError;
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Removes the requested members from a badge.
|
|
424
|
+
* Members removed from a badge lose the badge's permissions, if applicable.
|
|
425
|
+
* @param _id - Badge ID.
|
|
426
|
+
* @param memberIds - List of members to remove.
|
|
427
|
+
* @public
|
|
428
|
+
* @documentationMaturity preview
|
|
429
|
+
* @requiredField _id
|
|
430
|
+
* @requiredField memberIds
|
|
431
|
+
*/
|
|
432
|
+
export function unassignBadge(_id, memberIds) {
|
|
433
|
+
var _a, _b, _c;
|
|
434
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
435
|
+
const requestTransformation = { id: '$[0]', memberIds: '$[1]' };
|
|
436
|
+
const responseTransformation = '$';
|
|
437
|
+
// @ts-ignore
|
|
438
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
439
|
+
const { toAmbassadorRequest } = serializer({
|
|
440
|
+
rootSchema: _unassignBadgeRequest,
|
|
441
|
+
depSchemas: {},
|
|
442
|
+
fqdnTransformation: {
|
|
443
|
+
paths: [],
|
|
444
|
+
transformation: _fromVeloEntity,
|
|
445
|
+
},
|
|
446
|
+
customTransformation: requestTransformation,
|
|
447
|
+
});
|
|
448
|
+
const { fromJSON } = serializer({
|
|
449
|
+
rootSchema: _unassignBadgeResponse,
|
|
450
|
+
depSchemas: {},
|
|
451
|
+
fqdnTransformation: {
|
|
452
|
+
paths: [],
|
|
453
|
+
transformation: _toVeloEntity,
|
|
454
|
+
},
|
|
455
|
+
customTransformation: responseTransformation,
|
|
456
|
+
});
|
|
457
|
+
const payload = toAmbassadorRequest([_id, memberIds]);
|
|
458
|
+
const reqOpts = ambassadorWixBadgesV3Badge.unassignBadge(payload);
|
|
459
|
+
__log(`"UnassignBadge" sending request with: ${__inspect(reqOpts)}`);
|
|
460
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
461
|
+
try {
|
|
462
|
+
const result = yield httpClient.request(reqOpts);
|
|
463
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
464
|
+
return fromJSON(result.data);
|
|
465
|
+
}
|
|
466
|
+
catch (err) {
|
|
467
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
468
|
+
'_id',
|
|
469
|
+
'memberIds',
|
|
470
|
+
]);
|
|
471
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
472
|
+
throw transformedError;
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Retrieves up to 1000 site members
|
|
478
|
+
* who have a specified badge.
|
|
479
|
+
* Default `paging.limit` is 100, `paging.offset` - 0.
|
|
480
|
+
* For more details on how to use paging, see documentation
|
|
481
|
+
* [here](https://dev.wix.com/api/rest/getting-started/pagination).
|
|
482
|
+
* @param _id - Badge ID.
|
|
483
|
+
* @public
|
|
484
|
+
* @documentationMaturity preview
|
|
485
|
+
* @requiredField _id
|
|
486
|
+
*/
|
|
487
|
+
export function listMembers(_id, options) {
|
|
488
|
+
var _a, _b, _c;
|
|
489
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
490
|
+
const requestTransformation = { id: '$[0]', paging: '$[1].paging' };
|
|
491
|
+
const responseTransformation = '$';
|
|
492
|
+
// @ts-ignore
|
|
493
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
494
|
+
const { toAmbassadorRequest } = serializer({
|
|
495
|
+
rootSchema: _listMembersRequest,
|
|
496
|
+
depSchemas: {},
|
|
497
|
+
fqdnTransformation: {
|
|
498
|
+
paths: [],
|
|
499
|
+
transformation: _fromVeloEntity,
|
|
500
|
+
},
|
|
501
|
+
customTransformation: requestTransformation,
|
|
502
|
+
});
|
|
503
|
+
const { fromJSON } = serializer({
|
|
504
|
+
rootSchema: _listMembersResponse,
|
|
505
|
+
depSchemas: {},
|
|
506
|
+
fqdnTransformation: {
|
|
507
|
+
paths: [],
|
|
508
|
+
transformation: _toVeloEntity,
|
|
509
|
+
},
|
|
510
|
+
customTransformation: responseTransformation,
|
|
511
|
+
});
|
|
512
|
+
const payload = toAmbassadorRequest([_id, options]);
|
|
513
|
+
const reqOpts = ambassadorWixBadgesV3Badge.listMembers(payload);
|
|
514
|
+
__log(`"ListMembers" sending request with: ${__inspect(reqOpts)}`);
|
|
515
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
516
|
+
try {
|
|
517
|
+
const result = yield httpClient.request(reqOpts);
|
|
518
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
519
|
+
return fromJSON(result.data);
|
|
520
|
+
}
|
|
521
|
+
catch (err) {
|
|
522
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
523
|
+
'_id',
|
|
524
|
+
'options',
|
|
525
|
+
]);
|
|
526
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
527
|
+
throw transformedError;
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Retrieves badges assigned to the requested members.
|
|
533
|
+
* @param memberIds - List of members.
|
|
534
|
+
* @public
|
|
535
|
+
* @documentationMaturity preview
|
|
536
|
+
* @requiredField memberIds
|
|
537
|
+
*/
|
|
538
|
+
export function listMembersBadgeIds(memberIds) {
|
|
539
|
+
var _a, _b, _c;
|
|
540
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
541
|
+
const requestTransformation = { memberIds: '$[0]' };
|
|
542
|
+
const responseTransformation = '$';
|
|
543
|
+
// @ts-ignore
|
|
544
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
545
|
+
const { toAmbassadorRequest } = serializer({
|
|
546
|
+
rootSchema: _listMembersBadgeIdsRequest,
|
|
547
|
+
depSchemas: {},
|
|
548
|
+
fqdnTransformation: {
|
|
549
|
+
paths: [],
|
|
550
|
+
transformation: _fromVeloEntity,
|
|
551
|
+
},
|
|
552
|
+
customTransformation: requestTransformation,
|
|
553
|
+
});
|
|
554
|
+
const { fromJSON } = serializer({
|
|
555
|
+
rootSchema: _listMembersBadgeIdsResponse,
|
|
556
|
+
depSchemas: {},
|
|
557
|
+
fqdnTransformation: {
|
|
558
|
+
paths: [],
|
|
559
|
+
transformation: _toVeloEntity,
|
|
560
|
+
},
|
|
561
|
+
customTransformation: responseTransformation,
|
|
562
|
+
});
|
|
563
|
+
const payload = toAmbassadorRequest([memberIds]);
|
|
564
|
+
const reqOpts = ambassadorWixBadgesV3Badge.listMembersBadgeIds(payload);
|
|
565
|
+
__log(`"ListMembersBadgeIds" sending request with: ${__inspect(reqOpts)}`);
|
|
566
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
567
|
+
try {
|
|
568
|
+
const result = yield httpClient.request(reqOpts);
|
|
569
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
570
|
+
return fromJSON(result.data);
|
|
571
|
+
}
|
|
572
|
+
catch (err) {
|
|
573
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
574
|
+
'memberIds',
|
|
575
|
+
]);
|
|
576
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
577
|
+
throw transformedError;
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Retrieves member count per badge.
|
|
583
|
+
* @public
|
|
584
|
+
* @documentationMaturity preview
|
|
585
|
+
*/
|
|
586
|
+
export function getMemberCountsPerBadge() {
|
|
587
|
+
var _a, _b, _c;
|
|
588
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
589
|
+
const requestTransformation = {};
|
|
590
|
+
const responseTransformation = '$';
|
|
591
|
+
// @ts-ignore
|
|
592
|
+
const { httpClient, sideEffects } = arguments[0];
|
|
593
|
+
const { toAmbassadorRequest } = serializer({
|
|
594
|
+
rootSchema: _getMemberCountsPerBadgeRequest,
|
|
595
|
+
depSchemas: {},
|
|
596
|
+
fqdnTransformation: {
|
|
597
|
+
paths: [],
|
|
598
|
+
transformation: _fromVeloEntity,
|
|
599
|
+
},
|
|
600
|
+
customTransformation: requestTransformation,
|
|
601
|
+
});
|
|
602
|
+
const { fromJSON } = serializer({
|
|
603
|
+
rootSchema: _getMemberCountsPerBadgeResponse,
|
|
604
|
+
depSchemas: {},
|
|
605
|
+
fqdnTransformation: {
|
|
606
|
+
paths: [],
|
|
607
|
+
transformation: _toVeloEntity,
|
|
608
|
+
},
|
|
609
|
+
customTransformation: responseTransformation,
|
|
610
|
+
});
|
|
611
|
+
const payload = toAmbassadorRequest([]);
|
|
612
|
+
const reqOpts = ambassadorWixBadgesV3Badge.getMemberCountsPerBadge(payload);
|
|
613
|
+
__log(`"GetMemberCountsPerBadge" sending request with: ${__inspect(reqOpts)}`);
|
|
614
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
615
|
+
try {
|
|
616
|
+
const result = yield httpClient.request(reqOpts);
|
|
617
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
618
|
+
return fromJSON(result.data);
|
|
619
|
+
}
|
|
620
|
+
catch (err) {
|
|
621
|
+
const transformedError = transformError(err, requestTransformation, []);
|
|
622
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
623
|
+
throw transformedError;
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Updates badges' display order.
|
|
629
|
+
* @param badgeIds - Ordered badge IDs.
|
|
630
|
+
* @public
|
|
631
|
+
* @documentationMaturity preview
|
|
632
|
+
* @requiredField badgeIds
|
|
633
|
+
*/
|
|
634
|
+
export function updateBadgesDisplayOrder(badgeIds) {
|
|
635
|
+
var _a, _b, _c;
|
|
636
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
637
|
+
const requestTransformation = { badgeIds: '$[0]' };
|
|
638
|
+
const responseTransformation = '$';
|
|
639
|
+
// @ts-ignore
|
|
640
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
641
|
+
const { toAmbassadorRequest } = serializer({
|
|
642
|
+
rootSchema: _updateBadgesDisplayOrderRequest,
|
|
643
|
+
depSchemas: {},
|
|
644
|
+
fqdnTransformation: {
|
|
645
|
+
paths: [],
|
|
646
|
+
transformation: _fromVeloEntity,
|
|
647
|
+
},
|
|
648
|
+
customTransformation: requestTransformation,
|
|
649
|
+
});
|
|
650
|
+
const { fromJSON } = serializer({
|
|
651
|
+
rootSchema: _updateBadgesDisplayOrderResponse,
|
|
652
|
+
depSchemas: {},
|
|
653
|
+
fqdnTransformation: {
|
|
654
|
+
paths: [...['Array#badges']],
|
|
655
|
+
transformation: _toVeloEntity,
|
|
656
|
+
},
|
|
657
|
+
customTransformation: responseTransformation,
|
|
658
|
+
});
|
|
659
|
+
const payload = toAmbassadorRequest([badgeIds]);
|
|
660
|
+
const reqOpts = ambassadorWixBadgesV3Badge.updateBadgesDisplayOrder(payload);
|
|
661
|
+
__log(`"UpdateBadgesDisplayOrder" sending request with: ${__inspect(reqOpts)}`);
|
|
662
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
663
|
+
try {
|
|
664
|
+
const result = yield httpClient.request(reqOpts);
|
|
665
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
666
|
+
return fromJSON(result.data);
|
|
667
|
+
}
|
|
668
|
+
catch (err) {
|
|
669
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
670
|
+
'badgeIds',
|
|
671
|
+
]);
|
|
672
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
673
|
+
throw transformedError;
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
//# sourceMappingURL=badges-v3-badge.universal.js.map
|