@ofauth/onlyfans-sdk 2.2.3
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/README.md +242 -0
- package/dist/index.d.mts +8189 -0
- package/dist/index.d.ts +8189 -0
- package/dist/index.js +2587 -0
- package/dist/index.mjs +2535 -0
- package/package.json +31 -0
- package/src/client.ts +10013 -0
- package/src/index.ts +4 -0
- package/src/runtime.ts +183 -0
- package/src/webhooks.ts +447 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2535 @@
|
|
|
1
|
+
// src/runtime.ts
|
|
2
|
+
var BASE_PATH = "https://api-next.ofauth.com";
|
|
3
|
+
var OFAuthAPIError = class extends Error {
|
|
4
|
+
constructor(response, body) {
|
|
5
|
+
super(body?.message || `HTTP ${response.status}: ${response.statusText}`);
|
|
6
|
+
this.name = "OFAuthAPIError";
|
|
7
|
+
this.status = response.status;
|
|
8
|
+
this.code = body?.code;
|
|
9
|
+
this.details = body?.details;
|
|
10
|
+
this.response = response;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
function buildQueryString(params) {
|
|
14
|
+
const entries = [];
|
|
15
|
+
for (const [key, value] of Object.entries(params)) {
|
|
16
|
+
if (value === void 0 || value === null) continue;
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
for (const v of value) {
|
|
19
|
+
entries.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(v))}`);
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
entries.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return entries.length > 0 ? `?${entries.join("&")}` : "";
|
|
26
|
+
}
|
|
27
|
+
async function request(config, reqConfig) {
|
|
28
|
+
const fetchFn = config.fetchApi || fetch;
|
|
29
|
+
const basePath = config.basePath || BASE_PATH;
|
|
30
|
+
const connectionId = reqConfig.connectionId || config.connectionId;
|
|
31
|
+
const url = basePath + reqConfig.path + (reqConfig.query ? buildQueryString(reqConfig.query) : "");
|
|
32
|
+
const headers = {
|
|
33
|
+
"apiKey": config.apiKey,
|
|
34
|
+
...reqConfig.headers
|
|
35
|
+
};
|
|
36
|
+
if (connectionId) {
|
|
37
|
+
headers["x-connection-id"] = connectionId;
|
|
38
|
+
}
|
|
39
|
+
if (reqConfig.body && typeof reqConfig.body === "object" && !(reqConfig.body instanceof FormData) && !(reqConfig.body instanceof Blob)) {
|
|
40
|
+
headers["Content-Type"] = "application/json";
|
|
41
|
+
}
|
|
42
|
+
const response = await fetchFn(url, {
|
|
43
|
+
method: reqConfig.method,
|
|
44
|
+
headers,
|
|
45
|
+
body: reqConfig.body instanceof FormData || reqConfig.body instanceof Blob ? reqConfig.body : reqConfig.body ? JSON.stringify(reqConfig.body) : void 0
|
|
46
|
+
});
|
|
47
|
+
if (!response.ok) {
|
|
48
|
+
let errorBody;
|
|
49
|
+
try {
|
|
50
|
+
errorBody = await response.json();
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
throw new OFAuthAPIError(response, errorBody);
|
|
54
|
+
}
|
|
55
|
+
const contentType = response.headers.get("content-type");
|
|
56
|
+
if (contentType?.includes("application/json")) {
|
|
57
|
+
return response.json();
|
|
58
|
+
}
|
|
59
|
+
if (response.status === 204) return {};
|
|
60
|
+
return response.text();
|
|
61
|
+
}
|
|
62
|
+
async function proxy(config, opts) {
|
|
63
|
+
const fetchFn = config.fetchApi || fetch;
|
|
64
|
+
const basePath = config.basePath || BASE_PATH;
|
|
65
|
+
let targetPath = opts.path;
|
|
66
|
+
if (targetPath.startsWith("/api2/v2")) {
|
|
67
|
+
targetPath = targetPath.slice(8);
|
|
68
|
+
} else if (targetPath.startsWith("api2/v2")) {
|
|
69
|
+
targetPath = "/" + targetPath.slice(7);
|
|
70
|
+
}
|
|
71
|
+
if (!targetPath.startsWith("/")) {
|
|
72
|
+
targetPath = "/" + targetPath;
|
|
73
|
+
}
|
|
74
|
+
let url = basePath + "/v2/access/proxy" + targetPath;
|
|
75
|
+
if (opts.query) {
|
|
76
|
+
url += buildQueryString(opts.query);
|
|
77
|
+
}
|
|
78
|
+
const headers = {
|
|
79
|
+
"apiKey": config.apiKey
|
|
80
|
+
};
|
|
81
|
+
const connectionId = opts.connectionId || config.connectionId;
|
|
82
|
+
if (connectionId) {
|
|
83
|
+
headers["x-connection-id"] = connectionId;
|
|
84
|
+
}
|
|
85
|
+
if (opts.body && typeof opts.body === "object" && !(opts.body instanceof FormData) && !(opts.body instanceof Blob)) {
|
|
86
|
+
headers["Content-Type"] = "application/json";
|
|
87
|
+
}
|
|
88
|
+
const response = await fetchFn(url, {
|
|
89
|
+
method: opts.method,
|
|
90
|
+
headers,
|
|
91
|
+
body: opts.body instanceof FormData || opts.body instanceof Blob ? opts.body : opts.body ? JSON.stringify(opts.body) : void 0
|
|
92
|
+
});
|
|
93
|
+
if (!response.ok) {
|
|
94
|
+
let errorBody;
|
|
95
|
+
try {
|
|
96
|
+
errorBody = await response.json();
|
|
97
|
+
} catch {
|
|
98
|
+
}
|
|
99
|
+
throw new OFAuthAPIError(response, errorBody);
|
|
100
|
+
}
|
|
101
|
+
const contentType = response.headers.get("content-type");
|
|
102
|
+
if (contentType?.includes("application/json")) {
|
|
103
|
+
return response.json();
|
|
104
|
+
}
|
|
105
|
+
if (response.status === 204) return {};
|
|
106
|
+
return response.text();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/client.ts
|
|
110
|
+
var AccountConnectionsNamespace = class {
|
|
111
|
+
constructor(config) {
|
|
112
|
+
this._config = config;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Disconnect connection
|
|
116
|
+
*/
|
|
117
|
+
delete(params) {
|
|
118
|
+
return request(this._config, {
|
|
119
|
+
path: `/v2/account/connections/${encodeURIComponent(String(params.connectionId))}`,
|
|
120
|
+
method: "DELETE"
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* List connections
|
|
125
|
+
*/
|
|
126
|
+
list(params) {
|
|
127
|
+
return request(this._config, {
|
|
128
|
+
path: "/v2/account/connections",
|
|
129
|
+
method: "GET",
|
|
130
|
+
query: {
|
|
131
|
+
"status": params.status,
|
|
132
|
+
"imported": params.imported,
|
|
133
|
+
"limit": params.limit,
|
|
134
|
+
"offset": params.offset
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* List connections
|
|
140
|
+
*
|
|
141
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
142
|
+
*/
|
|
143
|
+
async *iterate(params) {
|
|
144
|
+
let offset = 0;
|
|
145
|
+
let fetched = 0;
|
|
146
|
+
const limit = params?.pageSize ?? 20;
|
|
147
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
148
|
+
while (fetched < maxItems) {
|
|
149
|
+
const response = await this.list({
|
|
150
|
+
...params,
|
|
151
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
152
|
+
offset
|
|
153
|
+
});
|
|
154
|
+
for (const item of response.list) {
|
|
155
|
+
if (fetched >= maxItems) return;
|
|
156
|
+
yield item;
|
|
157
|
+
fetched++;
|
|
158
|
+
}
|
|
159
|
+
if (!response.hasMore) return;
|
|
160
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Invalidate connection
|
|
165
|
+
*/
|
|
166
|
+
invalidate(params) {
|
|
167
|
+
return request(this._config, {
|
|
168
|
+
path: `/v2/account/connections/${encodeURIComponent(String(params.connectionId))}/invalidate`,
|
|
169
|
+
method: "POST"
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get connection settings
|
|
174
|
+
*/
|
|
175
|
+
getSettings(params) {
|
|
176
|
+
return request(this._config, {
|
|
177
|
+
path: `/v2/account/connections/${encodeURIComponent(String(params.connectionId))}/settings`,
|
|
178
|
+
method: "GET"
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Update connection settings
|
|
183
|
+
*/
|
|
184
|
+
updateSettings(params) {
|
|
185
|
+
return request(this._config, {
|
|
186
|
+
path: `/v2/account/connections/${encodeURIComponent(String(params.connectionId))}/settings`,
|
|
187
|
+
method: "PATCH",
|
|
188
|
+
body: params.body
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Import connection
|
|
193
|
+
*/
|
|
194
|
+
createImport(params) {
|
|
195
|
+
return request(this._config, {
|
|
196
|
+
path: "/v2/account/connections/import",
|
|
197
|
+
method: "POST",
|
|
198
|
+
body: params.body
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Update imported connection session
|
|
203
|
+
*/
|
|
204
|
+
updateImport(params) {
|
|
205
|
+
return request(this._config, {
|
|
206
|
+
path: `/v2/account/connections/import/${encodeURIComponent(String(params.connectionId))}`,
|
|
207
|
+
method: "PATCH",
|
|
208
|
+
body: params.body
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
var AccountNamespace = class {
|
|
213
|
+
constructor(config) {
|
|
214
|
+
this._config = config;
|
|
215
|
+
this.connections = new AccountConnectionsNamespace(config);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Whoami
|
|
219
|
+
*/
|
|
220
|
+
whoami() {
|
|
221
|
+
return request(this._config, {
|
|
222
|
+
path: "/v2/account/whoami",
|
|
223
|
+
method: "GET"
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Get organization settings
|
|
228
|
+
*/
|
|
229
|
+
getSettings() {
|
|
230
|
+
return request(this._config, {
|
|
231
|
+
path: "/v2/account/settings",
|
|
232
|
+
method: "GET"
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Update organization settings
|
|
237
|
+
*/
|
|
238
|
+
updateSettings(params) {
|
|
239
|
+
return request(this._config, {
|
|
240
|
+
path: "/v2/account/settings",
|
|
241
|
+
method: "PATCH",
|
|
242
|
+
body: params.body
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
var AccessSelfNamespace = class {
|
|
247
|
+
constructor(config) {
|
|
248
|
+
this._config = config;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Get current user
|
|
252
|
+
*/
|
|
253
|
+
get() {
|
|
254
|
+
return request(this._config, {
|
|
255
|
+
path: "/v2/access/self",
|
|
256
|
+
method: "GET"
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Update current user profile
|
|
261
|
+
*/
|
|
262
|
+
update(params) {
|
|
263
|
+
return request(this._config, {
|
|
264
|
+
path: "/v2/access/self",
|
|
265
|
+
method: "PATCH",
|
|
266
|
+
body: params.body
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* List notifications
|
|
271
|
+
*/
|
|
272
|
+
listNotifications(params) {
|
|
273
|
+
return request(this._config, {
|
|
274
|
+
path: "/v2/access/self/notifications",
|
|
275
|
+
method: "GET",
|
|
276
|
+
query: {
|
|
277
|
+
"limit": params.limit,
|
|
278
|
+
"offset": params.offset,
|
|
279
|
+
"type": params.type,
|
|
280
|
+
"relatedUsername": params.relatedUsername
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* List notifications
|
|
286
|
+
*
|
|
287
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
288
|
+
*/
|
|
289
|
+
async *iterateNotifications(params) {
|
|
290
|
+
let offset = 0;
|
|
291
|
+
let fetched = 0;
|
|
292
|
+
const limit = params?.pageSize ?? 20;
|
|
293
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
294
|
+
while (fetched < maxItems) {
|
|
295
|
+
const response = await this.listNotifications({
|
|
296
|
+
...params,
|
|
297
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
298
|
+
offset
|
|
299
|
+
});
|
|
300
|
+
for (const item of response.list) {
|
|
301
|
+
if (fetched >= maxItems) return;
|
|
302
|
+
yield item;
|
|
303
|
+
fetched++;
|
|
304
|
+
}
|
|
305
|
+
if (!response.hasMore) return;
|
|
306
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* List release forms
|
|
311
|
+
*/
|
|
312
|
+
listReleaseForms(params) {
|
|
313
|
+
return request(this._config, {
|
|
314
|
+
path: "/v2/access/self/release-forms",
|
|
315
|
+
method: "GET",
|
|
316
|
+
query: {
|
|
317
|
+
"limit": params.limit,
|
|
318
|
+
"offset": params.offset,
|
|
319
|
+
"filter": params.filter,
|
|
320
|
+
"sortBy": params.sortBy,
|
|
321
|
+
"sortDirection": params.sortDirection,
|
|
322
|
+
"search": params.search
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* List release forms
|
|
328
|
+
*
|
|
329
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
330
|
+
*/
|
|
331
|
+
async *iterateReleaseForms(params) {
|
|
332
|
+
let offset = 0;
|
|
333
|
+
let fetched = 0;
|
|
334
|
+
const limit = params?.pageSize ?? 20;
|
|
335
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
336
|
+
while (fetched < maxItems) {
|
|
337
|
+
const response = await this.listReleaseForms({
|
|
338
|
+
...params,
|
|
339
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
340
|
+
offset
|
|
341
|
+
});
|
|
342
|
+
for (const item of response.list) {
|
|
343
|
+
if (fetched >= maxItems) return;
|
|
344
|
+
yield item;
|
|
345
|
+
fetched++;
|
|
346
|
+
}
|
|
347
|
+
if (!response.hasMore) return;
|
|
348
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* List tagged friend users
|
|
353
|
+
*/
|
|
354
|
+
listTaggedFriendUsers(params) {
|
|
355
|
+
return request(this._config, {
|
|
356
|
+
path: "/v2/access/self/tagged-friend-users",
|
|
357
|
+
method: "GET",
|
|
358
|
+
query: {
|
|
359
|
+
"limit": params.limit,
|
|
360
|
+
"offset": params.offset,
|
|
361
|
+
"filter": params.filter,
|
|
362
|
+
"sortBy": params.sortBy,
|
|
363
|
+
"sortDirection": params.sortDirection,
|
|
364
|
+
"search": params.search
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* List tagged friend users
|
|
370
|
+
*
|
|
371
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
372
|
+
*/
|
|
373
|
+
async *iterateTaggedFriendUsers(params) {
|
|
374
|
+
let offset = 0;
|
|
375
|
+
let fetched = 0;
|
|
376
|
+
const limit = params?.pageSize ?? 20;
|
|
377
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
378
|
+
while (fetched < maxItems) {
|
|
379
|
+
const response = await this.listTaggedFriendUsers({
|
|
380
|
+
...params,
|
|
381
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
382
|
+
offset
|
|
383
|
+
});
|
|
384
|
+
for (const item of response.list) {
|
|
385
|
+
if (fetched >= maxItems) return;
|
|
386
|
+
yield item;
|
|
387
|
+
fetched++;
|
|
388
|
+
}
|
|
389
|
+
if (!response.hasMore) return;
|
|
390
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
var AccessEarningsNamespace = class {
|
|
395
|
+
constructor(config) {
|
|
396
|
+
this._config = config;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Get earnings chart
|
|
400
|
+
*/
|
|
401
|
+
getChart(params) {
|
|
402
|
+
return request(this._config, {
|
|
403
|
+
path: "/v2/access/earnings/chart",
|
|
404
|
+
method: "GET",
|
|
405
|
+
query: {
|
|
406
|
+
"startDate": params.startDate,
|
|
407
|
+
"endDate": params.endDate,
|
|
408
|
+
"by": params.by,
|
|
409
|
+
"withTotal": params.withTotal,
|
|
410
|
+
"monthlyTotal": params.monthlyTotal
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* List transactions
|
|
416
|
+
*/
|
|
417
|
+
listTransactions(params) {
|
|
418
|
+
return request(this._config, {
|
|
419
|
+
path: "/v2/access/earnings/transactions",
|
|
420
|
+
method: "GET",
|
|
421
|
+
query: {
|
|
422
|
+
"startDate": params.startDate,
|
|
423
|
+
"marker": params.marker,
|
|
424
|
+
"type": params.type,
|
|
425
|
+
"tipsSource": params.tipsSource
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* List transactions
|
|
431
|
+
*
|
|
432
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
433
|
+
*/
|
|
434
|
+
async *iterateTransactions(params) {
|
|
435
|
+
let marker;
|
|
436
|
+
let fetched = 0;
|
|
437
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
438
|
+
while (fetched < maxItems) {
|
|
439
|
+
const response = await this.listTransactions({
|
|
440
|
+
...params,
|
|
441
|
+
marker
|
|
442
|
+
});
|
|
443
|
+
for (const item of response.list) {
|
|
444
|
+
if (fetched >= maxItems) return;
|
|
445
|
+
yield item;
|
|
446
|
+
fetched++;
|
|
447
|
+
}
|
|
448
|
+
if (!response.hasMore) return;
|
|
449
|
+
marker = response.marker;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* List chargebacks
|
|
454
|
+
*/
|
|
455
|
+
listChargebacks(params) {
|
|
456
|
+
return request(this._config, {
|
|
457
|
+
path: "/v2/access/earnings/chargebacks",
|
|
458
|
+
method: "GET",
|
|
459
|
+
query: {
|
|
460
|
+
"limit": params.limit,
|
|
461
|
+
"offset": params.offset,
|
|
462
|
+
"startDate": params.startDate,
|
|
463
|
+
"endDate": params.endDate
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* List chargebacks
|
|
469
|
+
*
|
|
470
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
471
|
+
*/
|
|
472
|
+
async *iterateChargebacks(params) {
|
|
473
|
+
let offset = 0;
|
|
474
|
+
let fetched = 0;
|
|
475
|
+
const limit = params?.pageSize ?? 20;
|
|
476
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
477
|
+
while (fetched < maxItems) {
|
|
478
|
+
const response = await this.listChargebacks({
|
|
479
|
+
...params,
|
|
480
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
481
|
+
offset
|
|
482
|
+
});
|
|
483
|
+
for (const item of response.list) {
|
|
484
|
+
if (fetched >= maxItems) return;
|
|
485
|
+
yield item;
|
|
486
|
+
fetched++;
|
|
487
|
+
}
|
|
488
|
+
if (!response.hasMore) return;
|
|
489
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
var AccessAnalyticsPostsNamespace = class {
|
|
494
|
+
constructor(config) {
|
|
495
|
+
this._config = config;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Post stats
|
|
499
|
+
*/
|
|
500
|
+
get(params) {
|
|
501
|
+
return request(this._config, {
|
|
502
|
+
path: `/v2/access/analytics/posts/${encodeURIComponent(String(params.postId))}`,
|
|
503
|
+
method: "GET"
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Posts chart
|
|
508
|
+
*/
|
|
509
|
+
getChart(params) {
|
|
510
|
+
return request(this._config, {
|
|
511
|
+
path: "/v2/access/analytics/posts/chart",
|
|
512
|
+
method: "GET",
|
|
513
|
+
query: {
|
|
514
|
+
"startDate": params.startDate,
|
|
515
|
+
"endDate": params.endDate,
|
|
516
|
+
"withTotal": params.withTotal,
|
|
517
|
+
"by": params.by
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Top posts
|
|
523
|
+
*/
|
|
524
|
+
getTop(params) {
|
|
525
|
+
return request(this._config, {
|
|
526
|
+
path: "/v2/access/analytics/posts/top",
|
|
527
|
+
method: "GET",
|
|
528
|
+
query: {
|
|
529
|
+
"by": params.by,
|
|
530
|
+
"startDate": params.startDate,
|
|
531
|
+
"endDate": params.endDate,
|
|
532
|
+
"limit": params.limit,
|
|
533
|
+
"offset": params.offset
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
var AccessAnalyticsStreamsNamespace = class {
|
|
539
|
+
constructor(config) {
|
|
540
|
+
this._config = config;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Streams chart
|
|
544
|
+
*/
|
|
545
|
+
getChart(params) {
|
|
546
|
+
return request(this._config, {
|
|
547
|
+
path: "/v2/access/analytics/streams/chart",
|
|
548
|
+
method: "GET",
|
|
549
|
+
query: {
|
|
550
|
+
"startDate": params.startDate,
|
|
551
|
+
"endDate": params.endDate,
|
|
552
|
+
"withTotal": params.withTotal,
|
|
553
|
+
"by": params.by
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Top streams
|
|
559
|
+
*/
|
|
560
|
+
getTop(params) {
|
|
561
|
+
return request(this._config, {
|
|
562
|
+
path: "/v2/access/analytics/streams/top",
|
|
563
|
+
method: "GET",
|
|
564
|
+
query: {
|
|
565
|
+
"by": params.by,
|
|
566
|
+
"startDate": params.startDate,
|
|
567
|
+
"endDate": params.endDate,
|
|
568
|
+
"limit": params.limit,
|
|
569
|
+
"offset": params.offset
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
var AccessAnalyticsStoriesNamespace = class {
|
|
575
|
+
constructor(config) {
|
|
576
|
+
this._config = config;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Stories chart
|
|
580
|
+
*/
|
|
581
|
+
getChart(params) {
|
|
582
|
+
return request(this._config, {
|
|
583
|
+
path: "/v2/access/analytics/stories/chart",
|
|
584
|
+
method: "GET",
|
|
585
|
+
query: {
|
|
586
|
+
"startDate": params.startDate,
|
|
587
|
+
"endDate": params.endDate,
|
|
588
|
+
"withTotal": params.withTotal,
|
|
589
|
+
"by": params.by
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Top stories
|
|
595
|
+
*/
|
|
596
|
+
getTop(params) {
|
|
597
|
+
return request(this._config, {
|
|
598
|
+
path: "/v2/access/analytics/stories/top",
|
|
599
|
+
method: "GET",
|
|
600
|
+
query: {
|
|
601
|
+
"by": params.by,
|
|
602
|
+
"startDate": params.startDate,
|
|
603
|
+
"endDate": params.endDate,
|
|
604
|
+
"limit": params.limit,
|
|
605
|
+
"offset": params.offset
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
var AccessAnalyticsMassMessagesNamespace = class {
|
|
611
|
+
constructor(config) {
|
|
612
|
+
this._config = config;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Mass messages chart
|
|
616
|
+
*/
|
|
617
|
+
getChart(params) {
|
|
618
|
+
return request(this._config, {
|
|
619
|
+
path: "/v2/access/analytics/mass-messages/chart",
|
|
620
|
+
method: "GET",
|
|
621
|
+
query: {
|
|
622
|
+
"startDate": params.startDate,
|
|
623
|
+
"endDate": params.endDate,
|
|
624
|
+
"withTotal": params.withTotal
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Mass messages purchased
|
|
630
|
+
*/
|
|
631
|
+
getPurchased(params) {
|
|
632
|
+
return request(this._config, {
|
|
633
|
+
path: "/v2/access/analytics/mass-messages/purchased",
|
|
634
|
+
method: "GET",
|
|
635
|
+
query: {
|
|
636
|
+
"limit": params.limit,
|
|
637
|
+
"offset": params.offset
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Mass message buyers
|
|
643
|
+
*/
|
|
644
|
+
listBuyers(params) {
|
|
645
|
+
return request(this._config, {
|
|
646
|
+
path: `/v2/access/analytics/mass-messages/${encodeURIComponent(String(params.massMessageId))}/buyers`,
|
|
647
|
+
method: "GET",
|
|
648
|
+
query: {
|
|
649
|
+
"limit": params.limit,
|
|
650
|
+
"offset": params.offset,
|
|
651
|
+
"marker": params.marker
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Mass message buyers
|
|
657
|
+
*
|
|
658
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
659
|
+
*/
|
|
660
|
+
async *iterateBuyers(params) {
|
|
661
|
+
let marker;
|
|
662
|
+
let fetched = 0;
|
|
663
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
664
|
+
while (fetched < maxItems) {
|
|
665
|
+
const response = await this.listBuyers({
|
|
666
|
+
...params,
|
|
667
|
+
marker
|
|
668
|
+
});
|
|
669
|
+
for (const item of response.list) {
|
|
670
|
+
if (fetched >= maxItems) return;
|
|
671
|
+
yield item;
|
|
672
|
+
fetched++;
|
|
673
|
+
}
|
|
674
|
+
if (!response.hasMore) return;
|
|
675
|
+
marker = response.marker;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
var AccessAnalyticsPromotionsNamespace = class {
|
|
680
|
+
constructor(config) {
|
|
681
|
+
this._config = config;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Promotions chart
|
|
685
|
+
*/
|
|
686
|
+
getChart(params) {
|
|
687
|
+
return request(this._config, {
|
|
688
|
+
path: "/v2/access/analytics/promotions/chart",
|
|
689
|
+
method: "GET",
|
|
690
|
+
query: {
|
|
691
|
+
"startDate": params.startDate,
|
|
692
|
+
"endDate": params.endDate,
|
|
693
|
+
"withTotal": params.withTotal
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Top promotions
|
|
699
|
+
*/
|
|
700
|
+
getTop(params) {
|
|
701
|
+
return request(this._config, {
|
|
702
|
+
path: "/v2/access/analytics/promotions/top",
|
|
703
|
+
method: "GET",
|
|
704
|
+
query: {
|
|
705
|
+
"limit": params.limit,
|
|
706
|
+
"offset": params.offset,
|
|
707
|
+
"startDate": params.startDate,
|
|
708
|
+
"endDate": params.endDate
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
var AccessAnalyticsTrialsNamespace = class {
|
|
714
|
+
constructor(config) {
|
|
715
|
+
this._config = config;
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Trials chart
|
|
719
|
+
*/
|
|
720
|
+
getChart(params) {
|
|
721
|
+
return request(this._config, {
|
|
722
|
+
path: "/v2/access/analytics/trials/chart",
|
|
723
|
+
method: "GET",
|
|
724
|
+
query: {
|
|
725
|
+
"startDate": params.startDate,
|
|
726
|
+
"endDate": params.endDate,
|
|
727
|
+
"withTotal": params.withTotal
|
|
728
|
+
}
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Top trials
|
|
733
|
+
*/
|
|
734
|
+
getTop(params) {
|
|
735
|
+
return request(this._config, {
|
|
736
|
+
path: "/v2/access/analytics/trials/top",
|
|
737
|
+
method: "GET",
|
|
738
|
+
query: {
|
|
739
|
+
"limit": params.limit,
|
|
740
|
+
"offset": params.offset,
|
|
741
|
+
"startDate": params.startDate,
|
|
742
|
+
"endDate": params.endDate
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
var AccessAnalyticsCampaignsNamespace = class {
|
|
748
|
+
constructor(config) {
|
|
749
|
+
this._config = config;
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Campaigns chart
|
|
753
|
+
*/
|
|
754
|
+
getChart(params) {
|
|
755
|
+
return request(this._config, {
|
|
756
|
+
path: "/v2/access/analytics/campaigns/chart",
|
|
757
|
+
method: "GET",
|
|
758
|
+
query: {
|
|
759
|
+
"startDate": params.startDate,
|
|
760
|
+
"endDate": params.endDate,
|
|
761
|
+
"withTotal": params.withTotal
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Top campaigns
|
|
767
|
+
*/
|
|
768
|
+
getTop(params) {
|
|
769
|
+
return request(this._config, {
|
|
770
|
+
path: "/v2/access/analytics/campaigns/top",
|
|
771
|
+
method: "GET",
|
|
772
|
+
query: {
|
|
773
|
+
"limit": params.limit,
|
|
774
|
+
"offset": params.offset,
|
|
775
|
+
"startDate": params.startDate,
|
|
776
|
+
"endDate": params.endDate
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Top campaigns
|
|
782
|
+
*
|
|
783
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
784
|
+
*/
|
|
785
|
+
async *iterateTop(params) {
|
|
786
|
+
let offset = 0;
|
|
787
|
+
let fetched = 0;
|
|
788
|
+
const limit = params?.pageSize ?? 20;
|
|
789
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
790
|
+
while (fetched < maxItems) {
|
|
791
|
+
const response = await this.getTop({
|
|
792
|
+
...params,
|
|
793
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
794
|
+
offset
|
|
795
|
+
});
|
|
796
|
+
for (const item of response.list) {
|
|
797
|
+
if (fetched >= maxItems) return;
|
|
798
|
+
yield item;
|
|
799
|
+
fetched++;
|
|
800
|
+
}
|
|
801
|
+
if (!response.hasMore) return;
|
|
802
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
var AccessAnalyticsVisitorCountriesNamespace = class {
|
|
807
|
+
constructor(config) {
|
|
808
|
+
this._config = config;
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Visitor countries chart
|
|
812
|
+
*/
|
|
813
|
+
getChart(params) {
|
|
814
|
+
return request(this._config, {
|
|
815
|
+
path: "/v2/access/analytics/visitor-countries/chart",
|
|
816
|
+
method: "GET",
|
|
817
|
+
query: {
|
|
818
|
+
"startDate": params.startDate,
|
|
819
|
+
"endDate": params.endDate,
|
|
820
|
+
"by": params.by
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Top visitor countries
|
|
826
|
+
*/
|
|
827
|
+
getTop(params) {
|
|
828
|
+
return request(this._config, {
|
|
829
|
+
path: "/v2/access/analytics/visitor-countries/top",
|
|
830
|
+
method: "GET",
|
|
831
|
+
query: {
|
|
832
|
+
"startDate": params.startDate,
|
|
833
|
+
"endDate": params.endDate,
|
|
834
|
+
"by": params.by
|
|
835
|
+
}
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
var AccessAnalyticsNamespace = class {
|
|
840
|
+
constructor(config) {
|
|
841
|
+
this._config = config;
|
|
842
|
+
this.posts = new AccessAnalyticsPostsNamespace(config);
|
|
843
|
+
this.streams = new AccessAnalyticsStreamsNamespace(config);
|
|
844
|
+
this.stories = new AccessAnalyticsStoriesNamespace(config);
|
|
845
|
+
this.massMessages = new AccessAnalyticsMassMessagesNamespace(config);
|
|
846
|
+
this.promotions = new AccessAnalyticsPromotionsNamespace(config);
|
|
847
|
+
this.trials = new AccessAnalyticsTrialsNamespace(config);
|
|
848
|
+
this.campaigns = new AccessAnalyticsCampaignsNamespace(config);
|
|
849
|
+
this.visitorCountries = new AccessAnalyticsVisitorCountriesNamespace(config);
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
var AccessUsersListsNamespace = class {
|
|
853
|
+
constructor(config) {
|
|
854
|
+
this._config = config;
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* List user lists
|
|
858
|
+
*/
|
|
859
|
+
list(params) {
|
|
860
|
+
return request(this._config, {
|
|
861
|
+
path: "/v2/access/users/lists",
|
|
862
|
+
method: "GET",
|
|
863
|
+
query: {
|
|
864
|
+
"limit": params.limit,
|
|
865
|
+
"offset": params.offset,
|
|
866
|
+
"query": params.query
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* List user lists
|
|
872
|
+
*
|
|
873
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
874
|
+
*/
|
|
875
|
+
async *iterate(params) {
|
|
876
|
+
let offset = 0;
|
|
877
|
+
let fetched = 0;
|
|
878
|
+
const limit = params?.pageSize ?? 20;
|
|
879
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
880
|
+
while (fetched < maxItems) {
|
|
881
|
+
const response = await this.list({
|
|
882
|
+
...params,
|
|
883
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
884
|
+
offset
|
|
885
|
+
});
|
|
886
|
+
for (const item of response.list) {
|
|
887
|
+
if (fetched >= maxItems) return;
|
|
888
|
+
yield item;
|
|
889
|
+
fetched++;
|
|
890
|
+
}
|
|
891
|
+
if (!response.hasMore) return;
|
|
892
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Create user list
|
|
897
|
+
*/
|
|
898
|
+
create(params) {
|
|
899
|
+
return request(this._config, {
|
|
900
|
+
path: "/v2/access/users/lists",
|
|
901
|
+
method: "POST",
|
|
902
|
+
body: params.body
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Get user list
|
|
907
|
+
*/
|
|
908
|
+
get(params) {
|
|
909
|
+
return request(this._config, {
|
|
910
|
+
path: `/v2/access/users/lists/${encodeURIComponent(String(params.listId))}`,
|
|
911
|
+
method: "GET"
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* Update user list
|
|
916
|
+
*/
|
|
917
|
+
update(params) {
|
|
918
|
+
return request(this._config, {
|
|
919
|
+
path: `/v2/access/users/lists/${encodeURIComponent(String(params.listId))}`,
|
|
920
|
+
method: "PATCH",
|
|
921
|
+
body: params.body
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Delete user list
|
|
926
|
+
*/
|
|
927
|
+
delete(params) {
|
|
928
|
+
return request(this._config, {
|
|
929
|
+
path: `/v2/access/users/lists/${encodeURIComponent(String(params.listId))}`,
|
|
930
|
+
method: "DELETE"
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* Add user to multiple lists
|
|
935
|
+
*/
|
|
936
|
+
create2(params) {
|
|
937
|
+
return request(this._config, {
|
|
938
|
+
path: `/v2/access/users/${encodeURIComponent(String(params.userId))}/lists`,
|
|
939
|
+
method: "POST",
|
|
940
|
+
body: params.body
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* List users in user list
|
|
945
|
+
*/
|
|
946
|
+
listUsers(params) {
|
|
947
|
+
return request(this._config, {
|
|
948
|
+
path: `/v2/access/users/lists/${encodeURIComponent(String(params.listId))}/users`,
|
|
949
|
+
method: "GET",
|
|
950
|
+
query: {
|
|
951
|
+
"limit": params.limit,
|
|
952
|
+
"offset": params.offset
|
|
953
|
+
}
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* List users in user list
|
|
958
|
+
*
|
|
959
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
960
|
+
*/
|
|
961
|
+
async *iterateUsers(params) {
|
|
962
|
+
let offset = 0;
|
|
963
|
+
let fetched = 0;
|
|
964
|
+
const limit = params?.pageSize ?? 20;
|
|
965
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
966
|
+
while (fetched < maxItems) {
|
|
967
|
+
const response = await this.listUsers({
|
|
968
|
+
...params,
|
|
969
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
970
|
+
offset
|
|
971
|
+
});
|
|
972
|
+
for (const item of response.list) {
|
|
973
|
+
if (fetched >= maxItems) return;
|
|
974
|
+
yield item;
|
|
975
|
+
fetched++;
|
|
976
|
+
}
|
|
977
|
+
if (!response.hasMore) return;
|
|
978
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* Add user to list
|
|
983
|
+
*/
|
|
984
|
+
createUsers(params) {
|
|
985
|
+
return request(this._config, {
|
|
986
|
+
path: `/v2/access/users/lists/${encodeURIComponent(String(params.listId))}/users/${encodeURIComponent(String(params.userId))}`,
|
|
987
|
+
method: "POST"
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* Remove user from user list
|
|
992
|
+
*/
|
|
993
|
+
deleteUsers(params) {
|
|
994
|
+
return request(this._config, {
|
|
995
|
+
path: `/v2/access/users/lists/${encodeURIComponent(String(params.listId))}/users/${encodeURIComponent(String(params.userId))}`,
|
|
996
|
+
method: "DELETE"
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
var AccessUsersNamespace = class {
|
|
1001
|
+
constructor(config) {
|
|
1002
|
+
this._config = config;
|
|
1003
|
+
this.lists = new AccessUsersListsNamespace(config);
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Get user
|
|
1007
|
+
*/
|
|
1008
|
+
get(params) {
|
|
1009
|
+
return request(this._config, {
|
|
1010
|
+
path: `/v2/access/users/${encodeURIComponent(String(params.userId))}`,
|
|
1011
|
+
method: "GET"
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* List user posts
|
|
1016
|
+
*/
|
|
1017
|
+
listPosts(params) {
|
|
1018
|
+
return request(this._config, {
|
|
1019
|
+
path: `/v2/access/users/${encodeURIComponent(String(params.userId))}/posts`,
|
|
1020
|
+
method: "GET",
|
|
1021
|
+
query: {
|
|
1022
|
+
"limit": params.limit,
|
|
1023
|
+
"sortBy": params.sortBy,
|
|
1024
|
+
"sortDirection": params.sortDirection,
|
|
1025
|
+
"pinned": params.pinned,
|
|
1026
|
+
"includePostCounts": params.includePostCounts,
|
|
1027
|
+
"beforePublishTime": params.beforePublishTime
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* List restricted users
|
|
1033
|
+
*/
|
|
1034
|
+
getRestrict(params) {
|
|
1035
|
+
return request(this._config, {
|
|
1036
|
+
path: "/v2/access/users/restrict",
|
|
1037
|
+
method: "GET",
|
|
1038
|
+
query: {
|
|
1039
|
+
"limit": params.limit,
|
|
1040
|
+
"offset": params.offset
|
|
1041
|
+
}
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* List restricted users
|
|
1046
|
+
*
|
|
1047
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1048
|
+
*/
|
|
1049
|
+
async *iterateRestrict(params) {
|
|
1050
|
+
let offset = 0;
|
|
1051
|
+
let fetched = 0;
|
|
1052
|
+
const limit = params?.pageSize ?? 20;
|
|
1053
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
1054
|
+
while (fetched < maxItems) {
|
|
1055
|
+
const response = await this.getRestrict({
|
|
1056
|
+
...params,
|
|
1057
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
1058
|
+
offset
|
|
1059
|
+
});
|
|
1060
|
+
for (const item of response.list) {
|
|
1061
|
+
if (fetched >= maxItems) return;
|
|
1062
|
+
yield item;
|
|
1063
|
+
fetched++;
|
|
1064
|
+
}
|
|
1065
|
+
if (!response.hasMore) return;
|
|
1066
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* Restrict user
|
|
1071
|
+
*/
|
|
1072
|
+
restrict(params) {
|
|
1073
|
+
return request(this._config, {
|
|
1074
|
+
path: `/v2/access/users/${encodeURIComponent(String(params.userId))}/restrict`,
|
|
1075
|
+
method: "POST"
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Unrestrict user
|
|
1080
|
+
*/
|
|
1081
|
+
restrict2(params) {
|
|
1082
|
+
return request(this._config, {
|
|
1083
|
+
path: `/v2/access/users/${encodeURIComponent(String(params.userId))}/restrict`,
|
|
1084
|
+
method: "DELETE"
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
/**
|
|
1088
|
+
* List blocked users
|
|
1089
|
+
*/
|
|
1090
|
+
getBlocked(params) {
|
|
1091
|
+
return request(this._config, {
|
|
1092
|
+
path: "/v2/access/users/blocked",
|
|
1093
|
+
method: "GET",
|
|
1094
|
+
query: {
|
|
1095
|
+
"limit": params.limit,
|
|
1096
|
+
"offset": params.offset
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* List blocked users
|
|
1102
|
+
*
|
|
1103
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1104
|
+
*/
|
|
1105
|
+
async *iterateBlocked(params) {
|
|
1106
|
+
let offset = 0;
|
|
1107
|
+
let fetched = 0;
|
|
1108
|
+
const limit = params?.pageSize ?? 20;
|
|
1109
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
1110
|
+
while (fetched < maxItems) {
|
|
1111
|
+
const response = await this.getBlocked({
|
|
1112
|
+
...params,
|
|
1113
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
1114
|
+
offset
|
|
1115
|
+
});
|
|
1116
|
+
for (const item of response.list) {
|
|
1117
|
+
if (fetched >= maxItems) return;
|
|
1118
|
+
yield item;
|
|
1119
|
+
fetched++;
|
|
1120
|
+
}
|
|
1121
|
+
if (!response.hasMore) return;
|
|
1122
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* List users by IDs
|
|
1127
|
+
*/
|
|
1128
|
+
getList(params) {
|
|
1129
|
+
return request(this._config, {
|
|
1130
|
+
path: "/v2/access/users/list",
|
|
1131
|
+
method: "GET",
|
|
1132
|
+
query: {
|
|
1133
|
+
"userIds": params.userIds
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Search performers
|
|
1139
|
+
*/
|
|
1140
|
+
search(params) {
|
|
1141
|
+
return request(this._config, {
|
|
1142
|
+
path: "/v2/access/users/search",
|
|
1143
|
+
method: "GET",
|
|
1144
|
+
query: {
|
|
1145
|
+
"limit": params.limit,
|
|
1146
|
+
"offset": params.offset,
|
|
1147
|
+
"query": params.query
|
|
1148
|
+
}
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
var AccessChatsNamespace = class {
|
|
1153
|
+
constructor(config) {
|
|
1154
|
+
this._config = config;
|
|
1155
|
+
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Chats list
|
|
1158
|
+
*/
|
|
1159
|
+
list(params) {
|
|
1160
|
+
return request(this._config, {
|
|
1161
|
+
path: "/v2/access/chats",
|
|
1162
|
+
method: "GET",
|
|
1163
|
+
query: {
|
|
1164
|
+
"limit": params.limit,
|
|
1165
|
+
"offset": params.offset,
|
|
1166
|
+
"order": params.order,
|
|
1167
|
+
"filter": params.filter,
|
|
1168
|
+
"query": params.query,
|
|
1169
|
+
"userListId": params.userListId
|
|
1170
|
+
}
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
/**
|
|
1174
|
+
* Chats list
|
|
1175
|
+
*
|
|
1176
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1177
|
+
*/
|
|
1178
|
+
async *iterate(params) {
|
|
1179
|
+
let offset = 0;
|
|
1180
|
+
let fetched = 0;
|
|
1181
|
+
const limit = params?.pageSize ?? 20;
|
|
1182
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
1183
|
+
while (fetched < maxItems) {
|
|
1184
|
+
const response = await this.list({
|
|
1185
|
+
...params,
|
|
1186
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
1187
|
+
offset
|
|
1188
|
+
});
|
|
1189
|
+
for (const item of response.list) {
|
|
1190
|
+
if (fetched >= maxItems) return;
|
|
1191
|
+
yield item;
|
|
1192
|
+
fetched++;
|
|
1193
|
+
}
|
|
1194
|
+
if (!response.hasMore) return;
|
|
1195
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* Chat messages
|
|
1200
|
+
*/
|
|
1201
|
+
listMessages(params) {
|
|
1202
|
+
return request(this._config, {
|
|
1203
|
+
path: `/v2/access/chats/${encodeURIComponent(String(params.userId))}/messages`,
|
|
1204
|
+
method: "GET",
|
|
1205
|
+
query: {
|
|
1206
|
+
"limit": params.limit,
|
|
1207
|
+
"offset": params.offset,
|
|
1208
|
+
"query": params.query
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1213
|
+
* Chat messages
|
|
1214
|
+
*
|
|
1215
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1216
|
+
*/
|
|
1217
|
+
async *iterateMessages(params) {
|
|
1218
|
+
let offset = 0;
|
|
1219
|
+
let fetched = 0;
|
|
1220
|
+
const limit = params?.pageSize ?? 20;
|
|
1221
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
1222
|
+
while (fetched < maxItems) {
|
|
1223
|
+
const response = await this.listMessages({
|
|
1224
|
+
...params,
|
|
1225
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
1226
|
+
offset
|
|
1227
|
+
});
|
|
1228
|
+
for (const item of response.list) {
|
|
1229
|
+
if (fetched >= maxItems) return;
|
|
1230
|
+
yield item;
|
|
1231
|
+
fetched++;
|
|
1232
|
+
}
|
|
1233
|
+
if (!response.hasMore) return;
|
|
1234
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Send chat message
|
|
1239
|
+
*/
|
|
1240
|
+
createMessages(params) {
|
|
1241
|
+
return request(this._config, {
|
|
1242
|
+
path: `/v2/access/chats/${encodeURIComponent(String(params.userId))}/messages`,
|
|
1243
|
+
method: "POST",
|
|
1244
|
+
body: params.body
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Unsend chat message
|
|
1249
|
+
*/
|
|
1250
|
+
deleteMessages(params) {
|
|
1251
|
+
return request(this._config, {
|
|
1252
|
+
path: `/v2/access/chats/${encodeURIComponent(String(params.userId))}/messages/${encodeURIComponent(String(params.messageId))}`,
|
|
1253
|
+
method: "DELETE",
|
|
1254
|
+
body: params.body
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Get chat media
|
|
1259
|
+
*/
|
|
1260
|
+
listMedia(params) {
|
|
1261
|
+
return request(this._config, {
|
|
1262
|
+
path: `/v2/access/chats/${encodeURIComponent(String(params.userId))}/media`,
|
|
1263
|
+
method: "GET",
|
|
1264
|
+
query: {
|
|
1265
|
+
"limit": params.limit,
|
|
1266
|
+
"offset": params.offset,
|
|
1267
|
+
"skip_users": params.skipUsers,
|
|
1268
|
+
"last_id": params.lastId,
|
|
1269
|
+
"opened": params.opened,
|
|
1270
|
+
"type": params.type
|
|
1271
|
+
}
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
/**
|
|
1275
|
+
* Get chat media
|
|
1276
|
+
*
|
|
1277
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1278
|
+
*/
|
|
1279
|
+
async *iterateMedia(params) {
|
|
1280
|
+
let offset = 0;
|
|
1281
|
+
let fetched = 0;
|
|
1282
|
+
const limit = params?.pageSize ?? 20;
|
|
1283
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
1284
|
+
while (fetched < maxItems) {
|
|
1285
|
+
const response = await this.listMedia({
|
|
1286
|
+
...params,
|
|
1287
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
1288
|
+
offset
|
|
1289
|
+
});
|
|
1290
|
+
for (const item of response.list) {
|
|
1291
|
+
if (fetched >= maxItems) return;
|
|
1292
|
+
yield item;
|
|
1293
|
+
fetched++;
|
|
1294
|
+
}
|
|
1295
|
+
if (!response.hasMore) return;
|
|
1296
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
var AccessSubscribersNamespace = class {
|
|
1301
|
+
constructor(config) {
|
|
1302
|
+
this._config = config;
|
|
1303
|
+
}
|
|
1304
|
+
/**
|
|
1305
|
+
* List subscribers
|
|
1306
|
+
*/
|
|
1307
|
+
list(params) {
|
|
1308
|
+
return request(this._config, {
|
|
1309
|
+
path: "/v2/access/subscribers",
|
|
1310
|
+
method: "GET",
|
|
1311
|
+
query: {
|
|
1312
|
+
"query": params.query,
|
|
1313
|
+
"filter": params.filter,
|
|
1314
|
+
"type": params.type,
|
|
1315
|
+
"startDate": params.startDate,
|
|
1316
|
+
"endDate": params.endDate,
|
|
1317
|
+
"latestType": params.latestType,
|
|
1318
|
+
"limit": params.limit,
|
|
1319
|
+
"offset": params.offset
|
|
1320
|
+
}
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* List subscribers
|
|
1325
|
+
*
|
|
1326
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1327
|
+
*/
|
|
1328
|
+
async *iterate(params) {
|
|
1329
|
+
let offset = 0;
|
|
1330
|
+
let fetched = 0;
|
|
1331
|
+
const limit = params?.pageSize ?? 20;
|
|
1332
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
1333
|
+
while (fetched < maxItems) {
|
|
1334
|
+
const response = await this.list({
|
|
1335
|
+
...params,
|
|
1336
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
1337
|
+
offset
|
|
1338
|
+
});
|
|
1339
|
+
for (const item of response.list) {
|
|
1340
|
+
if (fetched >= maxItems) return;
|
|
1341
|
+
yield item;
|
|
1342
|
+
fetched++;
|
|
1343
|
+
}
|
|
1344
|
+
if (!response.hasMore) return;
|
|
1345
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* Update subscriber note
|
|
1350
|
+
*/
|
|
1351
|
+
setNote(params) {
|
|
1352
|
+
return request(this._config, {
|
|
1353
|
+
path: `/v2/access/subscribers/${encodeURIComponent(String(params.userId))}/note`,
|
|
1354
|
+
method: "PUT",
|
|
1355
|
+
body: params.body
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Apply discount to subscriber
|
|
1360
|
+
*/
|
|
1361
|
+
setDiscount(params) {
|
|
1362
|
+
return request(this._config, {
|
|
1363
|
+
path: `/v2/access/subscribers/${encodeURIComponent(String(params.userId))}/discount`,
|
|
1364
|
+
method: "PUT",
|
|
1365
|
+
body: params.body
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
/**
|
|
1369
|
+
* Set custom name for subscriber
|
|
1370
|
+
*/
|
|
1371
|
+
setCustomName(params) {
|
|
1372
|
+
return request(this._config, {
|
|
1373
|
+
path: `/v2/access/subscribers/${encodeURIComponent(String(params.userId))}/custom-name`,
|
|
1374
|
+
method: "PUT",
|
|
1375
|
+
body: params.body
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
};
|
|
1379
|
+
var AccessSubscriptionsNamespace = class {
|
|
1380
|
+
constructor(config) {
|
|
1381
|
+
this._config = config;
|
|
1382
|
+
}
|
|
1383
|
+
/**
|
|
1384
|
+
* List subscriptions
|
|
1385
|
+
*/
|
|
1386
|
+
list(params) {
|
|
1387
|
+
return request(this._config, {
|
|
1388
|
+
path: "/v2/access/subscriptions",
|
|
1389
|
+
method: "GET",
|
|
1390
|
+
query: {
|
|
1391
|
+
"limit": params.limit,
|
|
1392
|
+
"offset": params.offset,
|
|
1393
|
+
"query": params.query,
|
|
1394
|
+
"filter": params.filter,
|
|
1395
|
+
"type": params.type
|
|
1396
|
+
}
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* List subscriptions
|
|
1401
|
+
*
|
|
1402
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1403
|
+
*/
|
|
1404
|
+
async *iterate(params) {
|
|
1405
|
+
let offset = 0;
|
|
1406
|
+
let fetched = 0;
|
|
1407
|
+
const limit = params?.pageSize ?? 20;
|
|
1408
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
1409
|
+
while (fetched < maxItems) {
|
|
1410
|
+
const response = await this.list({
|
|
1411
|
+
...params,
|
|
1412
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
1413
|
+
offset
|
|
1414
|
+
});
|
|
1415
|
+
for (const item of response.list) {
|
|
1416
|
+
if (fetched >= maxItems) return;
|
|
1417
|
+
yield item;
|
|
1418
|
+
fetched++;
|
|
1419
|
+
}
|
|
1420
|
+
if (!response.hasMore) return;
|
|
1421
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
/**
|
|
1425
|
+
* Get subscription
|
|
1426
|
+
*/
|
|
1427
|
+
get(params) {
|
|
1428
|
+
return request(this._config, {
|
|
1429
|
+
path: `/v2/access/subscriptions/${encodeURIComponent(String(params.subscriptionId))}`,
|
|
1430
|
+
method: "GET"
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* Get subscription counts
|
|
1435
|
+
*/
|
|
1436
|
+
getCount() {
|
|
1437
|
+
return request(this._config, {
|
|
1438
|
+
path: "/v2/access/subscriptions/count",
|
|
1439
|
+
method: "GET"
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* Get subscription history
|
|
1444
|
+
*/
|
|
1445
|
+
getHistory(params) {
|
|
1446
|
+
return request(this._config, {
|
|
1447
|
+
path: `/v2/access/subscriptions/${encodeURIComponent(String(params.subscriptionId))}/history`,
|
|
1448
|
+
method: "GET",
|
|
1449
|
+
query: {
|
|
1450
|
+
"all": params.all
|
|
1451
|
+
}
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1454
|
+
};
|
|
1455
|
+
var AccessPromotionsTrackingLinksNamespace = class {
|
|
1456
|
+
constructor(config) {
|
|
1457
|
+
this._config = config;
|
|
1458
|
+
}
|
|
1459
|
+
/**
|
|
1460
|
+
* List tracking links
|
|
1461
|
+
*/
|
|
1462
|
+
list(params) {
|
|
1463
|
+
return request(this._config, {
|
|
1464
|
+
path: "/v2/access/promotions/tracking-links",
|
|
1465
|
+
method: "GET",
|
|
1466
|
+
query: {
|
|
1467
|
+
"limit": params.limit,
|
|
1468
|
+
"offset": params.offset,
|
|
1469
|
+
"pagination": params.pagination,
|
|
1470
|
+
"with_deleted": params.withDeleted,
|
|
1471
|
+
"sorting_deleted": params.sortingDeleted,
|
|
1472
|
+
"stats": params.stats
|
|
1473
|
+
}
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
/**
|
|
1477
|
+
* List tracking links
|
|
1478
|
+
*
|
|
1479
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1480
|
+
*/
|
|
1481
|
+
async *iterate(params) {
|
|
1482
|
+
let offset = 0;
|
|
1483
|
+
let fetched = 0;
|
|
1484
|
+
const limit = params?.pageSize ?? 20;
|
|
1485
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
1486
|
+
while (fetched < maxItems) {
|
|
1487
|
+
const response = await this.list({
|
|
1488
|
+
...params,
|
|
1489
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
1490
|
+
offset
|
|
1491
|
+
});
|
|
1492
|
+
for (const item of response.list) {
|
|
1493
|
+
if (fetched >= maxItems) return;
|
|
1494
|
+
yield item;
|
|
1495
|
+
fetched++;
|
|
1496
|
+
}
|
|
1497
|
+
if (!response.hasMore) return;
|
|
1498
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1502
|
+
* Create tracking link
|
|
1503
|
+
*/
|
|
1504
|
+
create(params) {
|
|
1505
|
+
return request(this._config, {
|
|
1506
|
+
path: "/v2/access/promotions/tracking-links",
|
|
1507
|
+
method: "POST",
|
|
1508
|
+
body: params.body
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* Get tracking link
|
|
1513
|
+
*/
|
|
1514
|
+
get(params) {
|
|
1515
|
+
return request(this._config, {
|
|
1516
|
+
path: `/v2/access/promotions/tracking-links/${encodeURIComponent(String(params.trackingLinkId))}`,
|
|
1517
|
+
method: "GET"
|
|
1518
|
+
});
|
|
1519
|
+
}
|
|
1520
|
+
/**
|
|
1521
|
+
* Update tracking link
|
|
1522
|
+
*/
|
|
1523
|
+
replace(params) {
|
|
1524
|
+
return request(this._config, {
|
|
1525
|
+
path: `/v2/access/promotions/tracking-links/${encodeURIComponent(String(params.trackingLinkId))}`,
|
|
1526
|
+
method: "PUT",
|
|
1527
|
+
body: params.body
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* Delete tracking link
|
|
1532
|
+
*/
|
|
1533
|
+
delete(params) {
|
|
1534
|
+
return request(this._config, {
|
|
1535
|
+
path: `/v2/access/promotions/tracking-links/${encodeURIComponent(String(params.trackingLinkId))}`,
|
|
1536
|
+
method: "DELETE"
|
|
1537
|
+
});
|
|
1538
|
+
}
|
|
1539
|
+
/**
|
|
1540
|
+
* Share tracking link access
|
|
1541
|
+
*/
|
|
1542
|
+
createShareAccess(params) {
|
|
1543
|
+
return request(this._config, {
|
|
1544
|
+
path: "/v2/access/promotions/tracking-links/share-access",
|
|
1545
|
+
method: "POST",
|
|
1546
|
+
body: params.body
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
/**
|
|
1550
|
+
* Revoke tracking link access
|
|
1551
|
+
*/
|
|
1552
|
+
deleteShareAccess(params) {
|
|
1553
|
+
return request(this._config, {
|
|
1554
|
+
path: "/v2/access/promotions/tracking-links/share-access",
|
|
1555
|
+
method: "DELETE",
|
|
1556
|
+
body: params.body
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
/**
|
|
1560
|
+
* Get tracking link claimers
|
|
1561
|
+
*/
|
|
1562
|
+
listClaimers(params) {
|
|
1563
|
+
return request(this._config, {
|
|
1564
|
+
path: `/v2/access/promotions/tracking-links/${encodeURIComponent(String(params.trackingLinkId))}/claimers`,
|
|
1565
|
+
method: "GET"
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
};
|
|
1569
|
+
var AccessPromotionsTrialLinksNamespace = class {
|
|
1570
|
+
constructor(config) {
|
|
1571
|
+
this._config = config;
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* List trial links
|
|
1575
|
+
*/
|
|
1576
|
+
list(params) {
|
|
1577
|
+
return request(this._config, {
|
|
1578
|
+
path: "/v2/access/promotions/trial-links",
|
|
1579
|
+
method: "GET",
|
|
1580
|
+
query: {
|
|
1581
|
+
"limit": params.limit,
|
|
1582
|
+
"offset": params.offset
|
|
1583
|
+
}
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* Create trial link
|
|
1588
|
+
*/
|
|
1589
|
+
create(params) {
|
|
1590
|
+
return request(this._config, {
|
|
1591
|
+
path: "/v2/access/promotions/trial-links",
|
|
1592
|
+
method: "POST",
|
|
1593
|
+
body: params.body
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
/**
|
|
1597
|
+
* Get trial link
|
|
1598
|
+
*/
|
|
1599
|
+
get(params) {
|
|
1600
|
+
return request(this._config, {
|
|
1601
|
+
path: `/v2/access/promotions/trial-links/${encodeURIComponent(String(params.trialLinkId))}`,
|
|
1602
|
+
method: "GET"
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
/**
|
|
1606
|
+
* Update trial link
|
|
1607
|
+
*/
|
|
1608
|
+
replace(params) {
|
|
1609
|
+
return request(this._config, {
|
|
1610
|
+
path: `/v2/access/promotions/trial-links/${encodeURIComponent(String(params.trialLinkId))}`,
|
|
1611
|
+
method: "PUT",
|
|
1612
|
+
body: params.body
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
/**
|
|
1616
|
+
* Delete trial link
|
|
1617
|
+
*/
|
|
1618
|
+
delete(params) {
|
|
1619
|
+
return request(this._config, {
|
|
1620
|
+
path: `/v2/access/promotions/trial-links/${encodeURIComponent(String(params.trialLinkId))}`,
|
|
1621
|
+
method: "DELETE"
|
|
1622
|
+
});
|
|
1623
|
+
}
|
|
1624
|
+
/**
|
|
1625
|
+
* Share trial link access
|
|
1626
|
+
*/
|
|
1627
|
+
createShareAccess(params) {
|
|
1628
|
+
return request(this._config, {
|
|
1629
|
+
path: "/v2/access/promotions/trial-links/share-access",
|
|
1630
|
+
method: "POST",
|
|
1631
|
+
body: params.body
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
/**
|
|
1635
|
+
* Revoke trial link access
|
|
1636
|
+
*/
|
|
1637
|
+
deleteShareAccess(params) {
|
|
1638
|
+
return request(this._config, {
|
|
1639
|
+
path: "/v2/access/promotions/trial-links/share-access",
|
|
1640
|
+
method: "DELETE",
|
|
1641
|
+
body: params.body
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1645
|
+
var AccessPromotionsNamespace = class {
|
|
1646
|
+
constructor(config) {
|
|
1647
|
+
this._config = config;
|
|
1648
|
+
this.trackingLinks = new AccessPromotionsTrackingLinksNamespace(config);
|
|
1649
|
+
this.trialLinks = new AccessPromotionsTrialLinksNamespace(config);
|
|
1650
|
+
}
|
|
1651
|
+
/**
|
|
1652
|
+
* List promotions
|
|
1653
|
+
*/
|
|
1654
|
+
list(params) {
|
|
1655
|
+
return request(this._config, {
|
|
1656
|
+
path: "/v2/access/promotions",
|
|
1657
|
+
method: "GET",
|
|
1658
|
+
query: {
|
|
1659
|
+
"limit": params.limit,
|
|
1660
|
+
"offset": params.offset
|
|
1661
|
+
}
|
|
1662
|
+
});
|
|
1663
|
+
}
|
|
1664
|
+
/**
|
|
1665
|
+
* Create promotion
|
|
1666
|
+
*/
|
|
1667
|
+
create(params) {
|
|
1668
|
+
return request(this._config, {
|
|
1669
|
+
path: "/v2/access/promotions",
|
|
1670
|
+
method: "POST",
|
|
1671
|
+
body: params.body
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
/**
|
|
1675
|
+
* Get promotion
|
|
1676
|
+
*/
|
|
1677
|
+
get(params) {
|
|
1678
|
+
return request(this._config, {
|
|
1679
|
+
path: `/v2/access/promotions/${encodeURIComponent(String(params.promotionId))}`,
|
|
1680
|
+
method: "GET"
|
|
1681
|
+
});
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Update promotion
|
|
1685
|
+
*/
|
|
1686
|
+
replace(params) {
|
|
1687
|
+
return request(this._config, {
|
|
1688
|
+
path: `/v2/access/promotions/${encodeURIComponent(String(params.promotionId))}`,
|
|
1689
|
+
method: "PUT",
|
|
1690
|
+
body: params.body
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
/**
|
|
1694
|
+
* Delete promotion
|
|
1695
|
+
*/
|
|
1696
|
+
delete(params) {
|
|
1697
|
+
return request(this._config, {
|
|
1698
|
+
path: `/v2/access/promotions/${encodeURIComponent(String(params.promotionId))}`,
|
|
1699
|
+
method: "DELETE"
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
/**
|
|
1703
|
+
* List bundles
|
|
1704
|
+
*/
|
|
1705
|
+
listBundles(params) {
|
|
1706
|
+
return request(this._config, {
|
|
1707
|
+
path: "/v2/access/promotions/bundles",
|
|
1708
|
+
method: "GET",
|
|
1709
|
+
query: {
|
|
1710
|
+
"limit": params.limit,
|
|
1711
|
+
"offset": params.offset
|
|
1712
|
+
}
|
|
1713
|
+
});
|
|
1714
|
+
}
|
|
1715
|
+
/**
|
|
1716
|
+
* Create bundle
|
|
1717
|
+
*/
|
|
1718
|
+
createBundles(params) {
|
|
1719
|
+
return request(this._config, {
|
|
1720
|
+
path: "/v2/access/promotions/bundles",
|
|
1721
|
+
method: "POST",
|
|
1722
|
+
body: params.body
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* Get bundle
|
|
1727
|
+
*/
|
|
1728
|
+
getBundles(params) {
|
|
1729
|
+
return request(this._config, {
|
|
1730
|
+
path: `/v2/access/promotions/bundles/${encodeURIComponent(String(params.bundleId))}`,
|
|
1731
|
+
method: "GET"
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* Update bundle
|
|
1736
|
+
*/
|
|
1737
|
+
replaceBundles(params) {
|
|
1738
|
+
return request(this._config, {
|
|
1739
|
+
path: `/v2/access/promotions/bundles/${encodeURIComponent(String(params.bundleId))}`,
|
|
1740
|
+
method: "PUT",
|
|
1741
|
+
body: params.body
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* Delete bundle
|
|
1746
|
+
*/
|
|
1747
|
+
deleteBundles(params) {
|
|
1748
|
+
return request(this._config, {
|
|
1749
|
+
path: `/v2/access/promotions/bundles/${encodeURIComponent(String(params.bundleId))}`,
|
|
1750
|
+
method: "DELETE"
|
|
1751
|
+
});
|
|
1752
|
+
}
|
|
1753
|
+
/**
|
|
1754
|
+
* Finish promotion
|
|
1755
|
+
*/
|
|
1756
|
+
finish(params) {
|
|
1757
|
+
return request(this._config, {
|
|
1758
|
+
path: `/v2/access/promotions/${encodeURIComponent(String(params.promotionId))}/finish`,
|
|
1759
|
+
method: "POST"
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
};
|
|
1763
|
+
var AccessVaultListsNamespace = class {
|
|
1764
|
+
constructor(config) {
|
|
1765
|
+
this._config = config;
|
|
1766
|
+
}
|
|
1767
|
+
/**
|
|
1768
|
+
* List vault folders
|
|
1769
|
+
*/
|
|
1770
|
+
list(params) {
|
|
1771
|
+
return request(this._config, {
|
|
1772
|
+
path: "/v2/access/vault/lists",
|
|
1773
|
+
method: "GET",
|
|
1774
|
+
query: {
|
|
1775
|
+
"limit": params.limit,
|
|
1776
|
+
"offset": params.offset,
|
|
1777
|
+
"query": params.query
|
|
1778
|
+
}
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* List vault folders
|
|
1783
|
+
*
|
|
1784
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1785
|
+
*/
|
|
1786
|
+
async *iterate(params) {
|
|
1787
|
+
let offset = 0;
|
|
1788
|
+
let fetched = 0;
|
|
1789
|
+
const limit = params?.pageSize ?? 20;
|
|
1790
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
1791
|
+
while (fetched < maxItems) {
|
|
1792
|
+
const response = await this.list({
|
|
1793
|
+
...params,
|
|
1794
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
1795
|
+
offset
|
|
1796
|
+
});
|
|
1797
|
+
for (const item of response.list) {
|
|
1798
|
+
if (fetched >= maxItems) return;
|
|
1799
|
+
yield item;
|
|
1800
|
+
fetched++;
|
|
1801
|
+
}
|
|
1802
|
+
if (!response.hasMore) return;
|
|
1803
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
1807
|
+
* Create vault list
|
|
1808
|
+
*/
|
|
1809
|
+
create(params) {
|
|
1810
|
+
return request(this._config, {
|
|
1811
|
+
path: "/v2/access/vault/lists",
|
|
1812
|
+
method: "POST",
|
|
1813
|
+
body: params.body
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
/**
|
|
1817
|
+
* Update vault list
|
|
1818
|
+
*/
|
|
1819
|
+
update(params) {
|
|
1820
|
+
return request(this._config, {
|
|
1821
|
+
path: `/v2/access/vault/lists/${encodeURIComponent(String(params.listId))}`,
|
|
1822
|
+
method: "PATCH",
|
|
1823
|
+
body: params.body
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
/**
|
|
1827
|
+
* Delete vault list
|
|
1828
|
+
*/
|
|
1829
|
+
delete(params) {
|
|
1830
|
+
return request(this._config, {
|
|
1831
|
+
path: `/v2/access/vault/lists/${encodeURIComponent(String(params.listId))}`,
|
|
1832
|
+
method: "DELETE"
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1835
|
+
/**
|
|
1836
|
+
* List media in vault list
|
|
1837
|
+
*/
|
|
1838
|
+
listMedia(params) {
|
|
1839
|
+
return request(this._config, {
|
|
1840
|
+
path: `/v2/access/vault/lists/${encodeURIComponent(String(params.listId))}/media`,
|
|
1841
|
+
method: "GET",
|
|
1842
|
+
query: {
|
|
1843
|
+
"limit": params.limit,
|
|
1844
|
+
"offset": params.offset,
|
|
1845
|
+
"sortBy": params.sortBy,
|
|
1846
|
+
"sortDirection": params.sortDirection,
|
|
1847
|
+
"query": params.query,
|
|
1848
|
+
"mediaType": params.mediaType
|
|
1849
|
+
}
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1852
|
+
/**
|
|
1853
|
+
* List media in vault list
|
|
1854
|
+
*
|
|
1855
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1856
|
+
*/
|
|
1857
|
+
async *iterateMedia(params) {
|
|
1858
|
+
let offset = 0;
|
|
1859
|
+
let fetched = 0;
|
|
1860
|
+
const limit = params?.pageSize ?? 20;
|
|
1861
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
1862
|
+
while (fetched < maxItems) {
|
|
1863
|
+
const response = await this.listMedia({
|
|
1864
|
+
...params,
|
|
1865
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
1866
|
+
offset
|
|
1867
|
+
});
|
|
1868
|
+
for (const item of response.list) {
|
|
1869
|
+
if (fetched >= maxItems) return;
|
|
1870
|
+
yield item;
|
|
1871
|
+
fetched++;
|
|
1872
|
+
}
|
|
1873
|
+
if (!response.hasMore) return;
|
|
1874
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
/**
|
|
1878
|
+
* Add media to vault list
|
|
1879
|
+
*/
|
|
1880
|
+
createMedia(params) {
|
|
1881
|
+
return request(this._config, {
|
|
1882
|
+
path: `/v2/access/vault/lists/${encodeURIComponent(String(params.listId))}/media`,
|
|
1883
|
+
method: "POST",
|
|
1884
|
+
body: params.body
|
|
1885
|
+
});
|
|
1886
|
+
}
|
|
1887
|
+
};
|
|
1888
|
+
var AccessVaultNamespace = class {
|
|
1889
|
+
constructor(config) {
|
|
1890
|
+
this._config = config;
|
|
1891
|
+
this.lists = new AccessVaultListsNamespace(config);
|
|
1892
|
+
}
|
|
1893
|
+
/**
|
|
1894
|
+
* List vault media
|
|
1895
|
+
*/
|
|
1896
|
+
listMedia(params) {
|
|
1897
|
+
return request(this._config, {
|
|
1898
|
+
path: "/v2/access/vault/media",
|
|
1899
|
+
method: "GET",
|
|
1900
|
+
query: {
|
|
1901
|
+
"limit": params.limit,
|
|
1902
|
+
"offset": params.offset,
|
|
1903
|
+
"sortBy": params.sortBy,
|
|
1904
|
+
"sortDirection": params.sortDirection,
|
|
1905
|
+
"listId": params.listId,
|
|
1906
|
+
"query": params.query,
|
|
1907
|
+
"mediaType": params.mediaType
|
|
1908
|
+
}
|
|
1909
|
+
});
|
|
1910
|
+
}
|
|
1911
|
+
/**
|
|
1912
|
+
* List vault media
|
|
1913
|
+
*
|
|
1914
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1915
|
+
*/
|
|
1916
|
+
async *iterateMedia(params) {
|
|
1917
|
+
let offset = 0;
|
|
1918
|
+
let fetched = 0;
|
|
1919
|
+
const limit = params?.pageSize ?? 20;
|
|
1920
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
1921
|
+
while (fetched < maxItems) {
|
|
1922
|
+
const response = await this.listMedia({
|
|
1923
|
+
...params,
|
|
1924
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
1925
|
+
offset
|
|
1926
|
+
});
|
|
1927
|
+
for (const item of response.list) {
|
|
1928
|
+
if (fetched >= maxItems) return;
|
|
1929
|
+
yield item;
|
|
1930
|
+
fetched++;
|
|
1931
|
+
}
|
|
1932
|
+
if (!response.hasMore) return;
|
|
1933
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
};
|
|
1937
|
+
var AccessUploadsNamespace = class {
|
|
1938
|
+
constructor(config) {
|
|
1939
|
+
this._config = config;
|
|
1940
|
+
}
|
|
1941
|
+
/**
|
|
1942
|
+
* Upload single-part media and finalize (No need to call /complete after upload if using this endpoint)
|
|
1943
|
+
*/
|
|
1944
|
+
replace(params) {
|
|
1945
|
+
return request(this._config, {
|
|
1946
|
+
path: `/v2/access/uploads/${encodeURIComponent(String(params.mediaUploadId))}`,
|
|
1947
|
+
method: "PUT"
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1950
|
+
/**
|
|
1951
|
+
* Check if media already exists in vault
|
|
1952
|
+
*/
|
|
1953
|
+
check(params) {
|
|
1954
|
+
return request(this._config, {
|
|
1955
|
+
path: "/v2/access/uploads/check",
|
|
1956
|
+
method: "POST",
|
|
1957
|
+
body: params.body
|
|
1958
|
+
});
|
|
1959
|
+
}
|
|
1960
|
+
/**
|
|
1961
|
+
* Initialize media upload
|
|
1962
|
+
*/
|
|
1963
|
+
init(params) {
|
|
1964
|
+
return request(this._config, {
|
|
1965
|
+
path: "/v2/access/uploads/init",
|
|
1966
|
+
method: "POST",
|
|
1967
|
+
body: params.body
|
|
1968
|
+
});
|
|
1969
|
+
}
|
|
1970
|
+
/**
|
|
1971
|
+
* Upload chunk to managed media upload
|
|
1972
|
+
*/
|
|
1973
|
+
replaceParts(params) {
|
|
1974
|
+
return request(this._config, {
|
|
1975
|
+
path: `/v2/access/uploads/${encodeURIComponent(String(params.mediaUploadId))}/parts/${encodeURIComponent(String(params.partNumber))}`,
|
|
1976
|
+
method: "PUT"
|
|
1977
|
+
});
|
|
1978
|
+
}
|
|
1979
|
+
/**
|
|
1980
|
+
* Finalize media upload
|
|
1981
|
+
*/
|
|
1982
|
+
complete(params) {
|
|
1983
|
+
return request(this._config, {
|
|
1984
|
+
path: "/v2/access/uploads/complete",
|
|
1985
|
+
method: "POST",
|
|
1986
|
+
body: params.body
|
|
1987
|
+
});
|
|
1988
|
+
}
|
|
1989
|
+
};
|
|
1990
|
+
var AccessNamespace = class {
|
|
1991
|
+
constructor(config) {
|
|
1992
|
+
this._config = config;
|
|
1993
|
+
this.self = new AccessSelfNamespace(config);
|
|
1994
|
+
this.earnings = new AccessEarningsNamespace(config);
|
|
1995
|
+
this.analytics = new AccessAnalyticsNamespace(config);
|
|
1996
|
+
this.users = new AccessUsersNamespace(config);
|
|
1997
|
+
this.chats = new AccessChatsNamespace(config);
|
|
1998
|
+
this.subscribers = new AccessSubscribersNamespace(config);
|
|
1999
|
+
this.subscriptions = new AccessSubscriptionsNamespace(config);
|
|
2000
|
+
this.promotions = new AccessPromotionsNamespace(config);
|
|
2001
|
+
this.vault = new AccessVaultNamespace(config);
|
|
2002
|
+
this.uploads = new AccessUploadsNamespace(config);
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* List own posts
|
|
2006
|
+
*/
|
|
2007
|
+
listPosts(params) {
|
|
2008
|
+
return request(this._config, {
|
|
2009
|
+
path: "/v2/access/posts",
|
|
2010
|
+
method: "GET",
|
|
2011
|
+
query: {
|
|
2012
|
+
"limit": params.limit,
|
|
2013
|
+
"sortBy": params.sortBy,
|
|
2014
|
+
"sortDirection": params.sortDirection,
|
|
2015
|
+
"pinned": params.pinned,
|
|
2016
|
+
"includePostCounts": params.includePostCounts,
|
|
2017
|
+
"beforePublishTime": params.beforePublishTime
|
|
2018
|
+
}
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
2021
|
+
/**
|
|
2022
|
+
* Create post
|
|
2023
|
+
*/
|
|
2024
|
+
createPosts(params) {
|
|
2025
|
+
return request(this._config, {
|
|
2026
|
+
path: "/v2/access/posts",
|
|
2027
|
+
method: "POST",
|
|
2028
|
+
body: params.body
|
|
2029
|
+
});
|
|
2030
|
+
}
|
|
2031
|
+
/**
|
|
2032
|
+
* Get post
|
|
2033
|
+
*/
|
|
2034
|
+
getPosts(params) {
|
|
2035
|
+
return request(this._config, {
|
|
2036
|
+
path: `/v2/access/posts/${encodeURIComponent(String(params.postId))}`,
|
|
2037
|
+
method: "GET"
|
|
2038
|
+
});
|
|
2039
|
+
}
|
|
2040
|
+
/**
|
|
2041
|
+
* Edit post
|
|
2042
|
+
*/
|
|
2043
|
+
replacePosts(params) {
|
|
2044
|
+
return request(this._config, {
|
|
2045
|
+
path: `/v2/access/posts/${encodeURIComponent(String(params.postId))}`,
|
|
2046
|
+
method: "PUT",
|
|
2047
|
+
body: params.body
|
|
2048
|
+
});
|
|
2049
|
+
}
|
|
2050
|
+
/**
|
|
2051
|
+
* Delete post
|
|
2052
|
+
*/
|
|
2053
|
+
deletePosts(params) {
|
|
2054
|
+
return request(this._config, {
|
|
2055
|
+
path: `/v2/access/posts/${encodeURIComponent(String(params.postId))}`,
|
|
2056
|
+
method: "DELETE"
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
/**
|
|
2060
|
+
* List mass messages
|
|
2061
|
+
*/
|
|
2062
|
+
listMassMessages(params) {
|
|
2063
|
+
return request(this._config, {
|
|
2064
|
+
path: "/v2/access/mass-messages",
|
|
2065
|
+
method: "GET",
|
|
2066
|
+
query: {
|
|
2067
|
+
"limit": params.limit,
|
|
2068
|
+
"offset": params.offset,
|
|
2069
|
+
"type": params.type
|
|
2070
|
+
}
|
|
2071
|
+
});
|
|
2072
|
+
}
|
|
2073
|
+
/**
|
|
2074
|
+
* List mass messages
|
|
2075
|
+
*
|
|
2076
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
2077
|
+
*/
|
|
2078
|
+
async *iterateMassMessages(params) {
|
|
2079
|
+
let offset = 0;
|
|
2080
|
+
let fetched = 0;
|
|
2081
|
+
const limit = params?.pageSize ?? 20;
|
|
2082
|
+
const maxItems = params?.maxItems ?? Infinity;
|
|
2083
|
+
while (fetched < maxItems) {
|
|
2084
|
+
const response = await this.listMassMessages({
|
|
2085
|
+
...params,
|
|
2086
|
+
limit: Math.min(limit, maxItems - fetched),
|
|
2087
|
+
offset
|
|
2088
|
+
});
|
|
2089
|
+
for (const item of response.list) {
|
|
2090
|
+
if (fetched >= maxItems) return;
|
|
2091
|
+
yield item;
|
|
2092
|
+
fetched++;
|
|
2093
|
+
}
|
|
2094
|
+
if (!response.hasMore) return;
|
|
2095
|
+
offset = response.nextOffset ?? offset + response.list.length;
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
/**
|
|
2099
|
+
* Create mass message
|
|
2100
|
+
*/
|
|
2101
|
+
createMassMessages(params) {
|
|
2102
|
+
return request(this._config, {
|
|
2103
|
+
path: "/v2/access/mass-messages",
|
|
2104
|
+
method: "POST",
|
|
2105
|
+
body: params.body
|
|
2106
|
+
});
|
|
2107
|
+
}
|
|
2108
|
+
/**
|
|
2109
|
+
* Get mass message
|
|
2110
|
+
*/
|
|
2111
|
+
getMassMessages(params) {
|
|
2112
|
+
return request(this._config, {
|
|
2113
|
+
path: `/v2/access/mass-messages/${encodeURIComponent(String(params.massMessageId))}`,
|
|
2114
|
+
method: "GET"
|
|
2115
|
+
});
|
|
2116
|
+
}
|
|
2117
|
+
/**
|
|
2118
|
+
* Update mass message
|
|
2119
|
+
*/
|
|
2120
|
+
replaceMassMessages(params) {
|
|
2121
|
+
return request(this._config, {
|
|
2122
|
+
path: `/v2/access/mass-messages/${encodeURIComponent(String(params.massMessageId))}`,
|
|
2123
|
+
method: "PUT",
|
|
2124
|
+
body: params.body
|
|
2125
|
+
});
|
|
2126
|
+
}
|
|
2127
|
+
/**
|
|
2128
|
+
* Delete mass message
|
|
2129
|
+
*/
|
|
2130
|
+
deleteMassMessages(params) {
|
|
2131
|
+
return request(this._config, {
|
|
2132
|
+
path: `/v2/access/mass-messages/${encodeURIComponent(String(params.massMessageId))}`,
|
|
2133
|
+
method: "DELETE"
|
|
2134
|
+
});
|
|
2135
|
+
}
|
|
2136
|
+
};
|
|
2137
|
+
var LinkNamespace = class {
|
|
2138
|
+
constructor(config) {
|
|
2139
|
+
this._config = config;
|
|
2140
|
+
}
|
|
2141
|
+
/**
|
|
2142
|
+
* Get login status
|
|
2143
|
+
*/
|
|
2144
|
+
get(params) {
|
|
2145
|
+
return request(this._config, {
|
|
2146
|
+
path: `/v2/link/${encodeURIComponent(String(params.clientSecret))}`,
|
|
2147
|
+
method: "GET"
|
|
2148
|
+
});
|
|
2149
|
+
}
|
|
2150
|
+
/**
|
|
2151
|
+
* Delete login session
|
|
2152
|
+
*/
|
|
2153
|
+
delete(params) {
|
|
2154
|
+
return request(this._config, {
|
|
2155
|
+
path: `/v2/link/${encodeURIComponent(String(params.clientSecret))}`,
|
|
2156
|
+
method: "DELETE"
|
|
2157
|
+
});
|
|
2158
|
+
}
|
|
2159
|
+
/**
|
|
2160
|
+
* Initialize a Link session
|
|
2161
|
+
*/
|
|
2162
|
+
init(params) {
|
|
2163
|
+
return request(this._config, {
|
|
2164
|
+
path: "/v2/link/init",
|
|
2165
|
+
method: "POST",
|
|
2166
|
+
body: params.body
|
|
2167
|
+
});
|
|
2168
|
+
}
|
|
2169
|
+
};
|
|
2170
|
+
var DynamicRulesNamespace = class {
|
|
2171
|
+
constructor(config) {
|
|
2172
|
+
this._config = config;
|
|
2173
|
+
}
|
|
2174
|
+
/**
|
|
2175
|
+
* Get dynamic rules
|
|
2176
|
+
*/
|
|
2177
|
+
list() {
|
|
2178
|
+
return request(this._config, {
|
|
2179
|
+
path: "/v2/dynamic-rules",
|
|
2180
|
+
method: "GET"
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
2183
|
+
/**
|
|
2184
|
+
* Generate sign headers for a request
|
|
2185
|
+
*/
|
|
2186
|
+
sign(params) {
|
|
2187
|
+
return request(this._config, {
|
|
2188
|
+
path: "/v2/dynamic-rules/sign",
|
|
2189
|
+
method: "POST",
|
|
2190
|
+
body: params.body
|
|
2191
|
+
});
|
|
2192
|
+
}
|
|
2193
|
+
/**
|
|
2194
|
+
* Get dynamic rules status
|
|
2195
|
+
*/
|
|
2196
|
+
getStatus() {
|
|
2197
|
+
return request(this._config, {
|
|
2198
|
+
path: "/v2/dynamic-rules/status",
|
|
2199
|
+
method: "GET"
|
|
2200
|
+
});
|
|
2201
|
+
}
|
|
2202
|
+
};
|
|
2203
|
+
var VaultPlusStoreNamespace = class {
|
|
2204
|
+
constructor(config) {
|
|
2205
|
+
this._config = config;
|
|
2206
|
+
}
|
|
2207
|
+
/**
|
|
2208
|
+
* Store all media from a vault list
|
|
2209
|
+
*/
|
|
2210
|
+
createList(params) {
|
|
2211
|
+
return request(this._config, {
|
|
2212
|
+
path: `/v2/vault-plus/store/list/${encodeURIComponent(String(params.listId))}`,
|
|
2213
|
+
method: "POST",
|
|
2214
|
+
connectionId: params.connectionId
|
|
2215
|
+
});
|
|
2216
|
+
}
|
|
2217
|
+
/**
|
|
2218
|
+
* Get storage status for a connection
|
|
2219
|
+
*/
|
|
2220
|
+
getStatus(params) {
|
|
2221
|
+
return request(this._config, {
|
|
2222
|
+
path: "/v2/vault-plus/store/status",
|
|
2223
|
+
method: "GET",
|
|
2224
|
+
connectionId: params.connectionId
|
|
2225
|
+
});
|
|
2226
|
+
}
|
|
2227
|
+
/**
|
|
2228
|
+
* Get organization vault stats
|
|
2229
|
+
*/
|
|
2230
|
+
getStats() {
|
|
2231
|
+
return request(this._config, {
|
|
2232
|
+
path: "/v2/vault-plus/store/stats",
|
|
2233
|
+
method: "GET"
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
2236
|
+
};
|
|
2237
|
+
var VaultPlusNamespace = class {
|
|
2238
|
+
constructor(config) {
|
|
2239
|
+
this._config = config;
|
|
2240
|
+
this.store = new VaultPlusStoreNamespace(config);
|
|
2241
|
+
}
|
|
2242
|
+
/**
|
|
2243
|
+
* Get media item with all quality variants
|
|
2244
|
+
*/
|
|
2245
|
+
get(params) {
|
|
2246
|
+
return request(this._config, {
|
|
2247
|
+
path: `/v2/vault-plus/${encodeURIComponent(String(params.mediaId))}`,
|
|
2248
|
+
method: "GET",
|
|
2249
|
+
connectionId: params.connectionId
|
|
2250
|
+
});
|
|
2251
|
+
}
|
|
2252
|
+
/**
|
|
2253
|
+
* Delete a stored media item
|
|
2254
|
+
*/
|
|
2255
|
+
delete(params) {
|
|
2256
|
+
return request(this._config, {
|
|
2257
|
+
path: `/v2/vault-plus/${encodeURIComponent(String(params.mediaId))}`,
|
|
2258
|
+
method: "DELETE",
|
|
2259
|
+
connectionId: params.connectionId
|
|
2260
|
+
});
|
|
2261
|
+
}
|
|
2262
|
+
/**
|
|
2263
|
+
* Get multiple media items with all quality variants
|
|
2264
|
+
*/
|
|
2265
|
+
createBatch(params) {
|
|
2266
|
+
return request(this._config, {
|
|
2267
|
+
path: "/v2/vault-plus/batch",
|
|
2268
|
+
method: "POST",
|
|
2269
|
+
body: params.body,
|
|
2270
|
+
connectionId: params.connectionId
|
|
2271
|
+
});
|
|
2272
|
+
}
|
|
2273
|
+
/**
|
|
2274
|
+
* List stored media for a connection
|
|
2275
|
+
*/
|
|
2276
|
+
getList(params) {
|
|
2277
|
+
return request(this._config, {
|
|
2278
|
+
path: "/v2/vault-plus/list",
|
|
2279
|
+
method: "GET",
|
|
2280
|
+
query: {
|
|
2281
|
+
"status": params.status,
|
|
2282
|
+
"source": params.source,
|
|
2283
|
+
"contentType": params.contentType,
|
|
2284
|
+
"limit": params.limit,
|
|
2285
|
+
"cursor": params.cursor
|
|
2286
|
+
},
|
|
2287
|
+
connectionId: params.connectionId
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
/**
|
|
2291
|
+
* Remove all stored media for a connection
|
|
2292
|
+
*/
|
|
2293
|
+
purge(params) {
|
|
2294
|
+
return request(this._config, {
|
|
2295
|
+
path: "/v2/vault-plus/purge",
|
|
2296
|
+
method: "DELETE",
|
|
2297
|
+
connectionId: params.connectionId
|
|
2298
|
+
});
|
|
2299
|
+
}
|
|
2300
|
+
};
|
|
2301
|
+
var OFAuthClient = class {
|
|
2302
|
+
constructor(config) {
|
|
2303
|
+
this._config = config;
|
|
2304
|
+
this.account = new AccountNamespace(config);
|
|
2305
|
+
this.access = new AccessNamespace(config);
|
|
2306
|
+
this.link = new LinkNamespace(config);
|
|
2307
|
+
this.dynamicRules = new DynamicRulesNamespace(config);
|
|
2308
|
+
this.vaultPlus = new VaultPlusNamespace(config);
|
|
2309
|
+
}
|
|
2310
|
+
/**
|
|
2311
|
+
* Make a proxied request to the OnlyFans API
|
|
2312
|
+
*/
|
|
2313
|
+
proxy(opts) {
|
|
2314
|
+
return proxy(this._config, opts);
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
function createOFAuthClient(config) {
|
|
2318
|
+
return new OFAuthClient(config);
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
// src/webhooks.ts
|
|
2322
|
+
import * as crypto from "crypto";
|
|
2323
|
+
var WebhookVerificationError = class extends Error {
|
|
2324
|
+
constructor(message, code) {
|
|
2325
|
+
super(message);
|
|
2326
|
+
this.code = code;
|
|
2327
|
+
this.name = "WebhookVerificationError";
|
|
2328
|
+
}
|
|
2329
|
+
};
|
|
2330
|
+
function isWebhookVerificationError(error) {
|
|
2331
|
+
return error instanceof WebhookVerificationError;
|
|
2332
|
+
}
|
|
2333
|
+
function extractWebhookHeaders(headers) {
|
|
2334
|
+
const get = (name) => {
|
|
2335
|
+
if (headers instanceof Headers) return headers.get(name);
|
|
2336
|
+
return headers[name] || headers[name.toLowerCase()] || null;
|
|
2337
|
+
};
|
|
2338
|
+
const svixId = get("svix-id");
|
|
2339
|
+
const svixTimestamp = get("svix-timestamp");
|
|
2340
|
+
const svixSignature = get("svix-signature");
|
|
2341
|
+
if (!svixId || !svixTimestamp || !svixSignature) {
|
|
2342
|
+
throw new WebhookVerificationError(
|
|
2343
|
+
"Missing required webhook headers (svix-id, svix-timestamp, svix-signature)",
|
|
2344
|
+
"MISSING_HEADERS"
|
|
2345
|
+
);
|
|
2346
|
+
}
|
|
2347
|
+
return {
|
|
2348
|
+
"svix-id": svixId,
|
|
2349
|
+
"svix-timestamp": svixTimestamp,
|
|
2350
|
+
"svix-signature": svixSignature
|
|
2351
|
+
};
|
|
2352
|
+
}
|
|
2353
|
+
function verifyWebhookSignature(payload, headers, options) {
|
|
2354
|
+
const { secret, tolerance = 300 } = options;
|
|
2355
|
+
const ts = parseInt(headers["svix-timestamp"], 10);
|
|
2356
|
+
if (isNaN(ts)) {
|
|
2357
|
+
throw new WebhookVerificationError("Invalid timestamp format", "INVALID_TIMESTAMP");
|
|
2358
|
+
}
|
|
2359
|
+
if (Math.abs(Math.floor(Date.now() / 1e3) - ts) > tolerance) {
|
|
2360
|
+
throw new WebhookVerificationError("Webhook timestamp too old", "TIMESTAMP_TOO_OLD");
|
|
2361
|
+
}
|
|
2362
|
+
const cleanSecret = secret.startsWith("whsec_") ? secret.slice(6) : secret;
|
|
2363
|
+
const key = Buffer.from(cleanSecret, "base64");
|
|
2364
|
+
const signed = `${headers["svix-id"]}.${headers["svix-timestamp"]}.${payload}`;
|
|
2365
|
+
const expected = crypto.createHmac("sha256", key).update(signed).digest("base64");
|
|
2366
|
+
const sigs = headers["svix-signature"].split(" ").map((s) => {
|
|
2367
|
+
const [version, signature] = s.split(",");
|
|
2368
|
+
return { version, signature };
|
|
2369
|
+
}).filter((s) => s.version === "v1");
|
|
2370
|
+
if (sigs.length === 0) {
|
|
2371
|
+
throw new WebhookVerificationError("No valid v1 signatures found", "NO_VALID_SIGNATURES");
|
|
2372
|
+
}
|
|
2373
|
+
const isValid = sigs.some((s) => {
|
|
2374
|
+
try {
|
|
2375
|
+
return crypto.timingSafeEqual(
|
|
2376
|
+
Buffer.from(expected, "base64"),
|
|
2377
|
+
Buffer.from(s.signature, "base64")
|
|
2378
|
+
);
|
|
2379
|
+
} catch {
|
|
2380
|
+
return false;
|
|
2381
|
+
}
|
|
2382
|
+
});
|
|
2383
|
+
if (!isValid) {
|
|
2384
|
+
throw new WebhookVerificationError("Signature verification failed", "SIGNATURE_MISMATCH");
|
|
2385
|
+
}
|
|
2386
|
+
return true;
|
|
2387
|
+
}
|
|
2388
|
+
async function verifyWebhookRequest(request2, secret, tolerance) {
|
|
2389
|
+
const headers = extractWebhookHeaders(request2.headers);
|
|
2390
|
+
const payload = await request2.text();
|
|
2391
|
+
verifyWebhookSignature(payload, headers, { secret, tolerance });
|
|
2392
|
+
try {
|
|
2393
|
+
return JSON.parse(payload);
|
|
2394
|
+
} catch {
|
|
2395
|
+
throw new WebhookVerificationError("Failed to parse webhook payload as JSON", "INVALID_JSON");
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
function verifyWebhookPayload(payload, headers, secret, tolerance) {
|
|
2399
|
+
const payloadStr = typeof payload === "string" ? payload : payload.toString("utf8");
|
|
2400
|
+
const webhookHeaders = extractWebhookHeaders(headers);
|
|
2401
|
+
verifyWebhookSignature(payloadStr, webhookHeaders, { secret, tolerance });
|
|
2402
|
+
try {
|
|
2403
|
+
return JSON.parse(payloadStr);
|
|
2404
|
+
} catch {
|
|
2405
|
+
throw new WebhookVerificationError("Failed to parse webhook payload as JSON", "INVALID_JSON");
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
var WebhookRouter = class {
|
|
2409
|
+
constructor(config) {
|
|
2410
|
+
this.handlers = {};
|
|
2411
|
+
this.secret = config.secret;
|
|
2412
|
+
this.tolerance = config.tolerance ?? 300;
|
|
2413
|
+
if (config.handlers) this.handlers = { ...config.handlers };
|
|
2414
|
+
this.defaultHandler = config.defaultHandler;
|
|
2415
|
+
this.errorHandler = config.errorHandler;
|
|
2416
|
+
}
|
|
2417
|
+
/** Register a handler for a specific event type */
|
|
2418
|
+
on(eventType, handler) {
|
|
2419
|
+
this.handlers[eventType] = handler;
|
|
2420
|
+
return this;
|
|
2421
|
+
}
|
|
2422
|
+
/** Register a default handler for unmatched event types */
|
|
2423
|
+
onDefault(handler) {
|
|
2424
|
+
this.defaultHandler = handler;
|
|
2425
|
+
return this;
|
|
2426
|
+
}
|
|
2427
|
+
/** Register an error handler */
|
|
2428
|
+
onError(handler) {
|
|
2429
|
+
this.errorHandler = handler;
|
|
2430
|
+
return this;
|
|
2431
|
+
}
|
|
2432
|
+
/** Handle a `Request` object (Cloudflare Workers, Deno, Bun, Node 18+) */
|
|
2433
|
+
async handleRequest(request2) {
|
|
2434
|
+
try {
|
|
2435
|
+
const event = await verifyWebhookRequest(
|
|
2436
|
+
request2,
|
|
2437
|
+
this.secret,
|
|
2438
|
+
this.tolerance
|
|
2439
|
+
);
|
|
2440
|
+
await this.processEvent(event);
|
|
2441
|
+
} catch (error) {
|
|
2442
|
+
if (this.errorHandler) this.errorHandler(error);
|
|
2443
|
+
else throw error;
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
/** Handle a raw payload + headers (Express.js, Fastify, etc.) */
|
|
2447
|
+
async handlePayload(payload, headers) {
|
|
2448
|
+
try {
|
|
2449
|
+
const event = verifyWebhookPayload(
|
|
2450
|
+
payload,
|
|
2451
|
+
headers,
|
|
2452
|
+
this.secret,
|
|
2453
|
+
this.tolerance
|
|
2454
|
+
);
|
|
2455
|
+
await this.processEvent(event);
|
|
2456
|
+
} catch (error) {
|
|
2457
|
+
if (this.errorHandler) this.errorHandler(error);
|
|
2458
|
+
else throw error;
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
/** Update the webhook secret at runtime */
|
|
2462
|
+
updateSecret(secret) {
|
|
2463
|
+
this.secret = secret;
|
|
2464
|
+
}
|
|
2465
|
+
/** Update the timestamp tolerance at runtime */
|
|
2466
|
+
updateTolerance(tolerance) {
|
|
2467
|
+
this.tolerance = tolerance;
|
|
2468
|
+
}
|
|
2469
|
+
async processEvent(event) {
|
|
2470
|
+
try {
|
|
2471
|
+
const handler = this.handlers[event.eventType] || this.defaultHandler;
|
|
2472
|
+
if (!handler) {
|
|
2473
|
+
console.warn(`No handler registered for webhook event type: ${event.eventType}`);
|
|
2474
|
+
return;
|
|
2475
|
+
}
|
|
2476
|
+
await handler(event);
|
|
2477
|
+
} catch (error) {
|
|
2478
|
+
if (this.errorHandler) this.errorHandler(error, event);
|
|
2479
|
+
else throw error;
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
};
|
|
2483
|
+
function createWebhookRouter(config) {
|
|
2484
|
+
return new WebhookRouter(config);
|
|
2485
|
+
}
|
|
2486
|
+
function createFetchWebhookHandler(router) {
|
|
2487
|
+
return async (request2) => {
|
|
2488
|
+
try {
|
|
2489
|
+
await router.handleRequest(request2);
|
|
2490
|
+
return new Response("OK", { status: 200 });
|
|
2491
|
+
} catch (error) {
|
|
2492
|
+
if (isWebhookVerificationError(error)) {
|
|
2493
|
+
return new Response(
|
|
2494
|
+
JSON.stringify({ error: error.message, code: error.code }),
|
|
2495
|
+
{ status: 401, headers: { "Content-Type": "application/json" } }
|
|
2496
|
+
);
|
|
2497
|
+
}
|
|
2498
|
+
console.error("Webhook processing error:", error);
|
|
2499
|
+
return new Response("Internal server error", { status: 500 });
|
|
2500
|
+
}
|
|
2501
|
+
};
|
|
2502
|
+
}
|
|
2503
|
+
function createExpressWebhookMiddleware(router) {
|
|
2504
|
+
return async (req, res, next) => {
|
|
2505
|
+
try {
|
|
2506
|
+
await router.handlePayload(req.body, req.headers);
|
|
2507
|
+
res.status(200).send("OK");
|
|
2508
|
+
} catch (error) {
|
|
2509
|
+
if (isWebhookVerificationError(error)) {
|
|
2510
|
+
res.status(401).json({ error: error.message, code: error.code });
|
|
2511
|
+
} else {
|
|
2512
|
+
res.status(500).json({ error: "Internal server error" });
|
|
2513
|
+
next(error);
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
};
|
|
2517
|
+
}
|
|
2518
|
+
export {
|
|
2519
|
+
BASE_PATH,
|
|
2520
|
+
OFAuthAPIError,
|
|
2521
|
+
OFAuthClient,
|
|
2522
|
+
WebhookRouter,
|
|
2523
|
+
WebhookVerificationError,
|
|
2524
|
+
createExpressWebhookMiddleware,
|
|
2525
|
+
createFetchWebhookHandler,
|
|
2526
|
+
createOFAuthClient,
|
|
2527
|
+
createWebhookRouter,
|
|
2528
|
+
extractWebhookHeaders,
|
|
2529
|
+
isWebhookVerificationError,
|
|
2530
|
+
proxy,
|
|
2531
|
+
request,
|
|
2532
|
+
verifyWebhookPayload,
|
|
2533
|
+
verifyWebhookRequest,
|
|
2534
|
+
verifyWebhookSignature
|
|
2535
|
+
};
|