@ofauth/onlyfans-sdk 2.2.3 → 3.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/dist/index.d.mts +304 -386
- package/dist/index.d.ts +304 -386
- package/dist/index.js +168 -174
- package/dist/index.mjs +168 -174
- package/package.json +2 -2
- package/src/client.ts +578 -592
- package/src/runtime.ts +48 -19
- package/src/runtime.unit.test.ts +39 -0
package/dist/index.js
CHANGED
|
@@ -61,6 +61,11 @@ var OFAuthAPIError = class extends Error {
|
|
|
61
61
|
this.response = response;
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
+
function isJsonContentType(contentType) {
|
|
65
|
+
if (!contentType) return false;
|
|
66
|
+
const lower = contentType.toLowerCase();
|
|
67
|
+
return lower.includes("application/json") || lower.includes("+json");
|
|
68
|
+
}
|
|
64
69
|
function buildQueryString(params) {
|
|
65
70
|
const entries = [];
|
|
66
71
|
for (const [key, value] of Object.entries(params)) {
|
|
@@ -75,6 +80,26 @@ function buildQueryString(params) {
|
|
|
75
80
|
}
|
|
76
81
|
return entries.length > 0 ? `?${entries.join("&")}` : "";
|
|
77
82
|
}
|
|
83
|
+
async function readErrorBody(response) {
|
|
84
|
+
const contentType = response.headers.get("content-type");
|
|
85
|
+
if (isJsonContentType(contentType)) {
|
|
86
|
+
const json = await response.json();
|
|
87
|
+
const obj = typeof json === "object" && json !== null ? json : null;
|
|
88
|
+
return {
|
|
89
|
+
message: typeof obj?.message === "string" ? obj.message : void 0,
|
|
90
|
+
code: typeof obj?.code === "string" ? obj.code : void 0,
|
|
91
|
+
details: obj?.details
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return await response.text();
|
|
95
|
+
}
|
|
96
|
+
async function readSuccessBody(response) {
|
|
97
|
+
const contentType = response.headers.get("content-type");
|
|
98
|
+
if (isJsonContentType(contentType)) {
|
|
99
|
+
return await response.json();
|
|
100
|
+
}
|
|
101
|
+
return await response.text();
|
|
102
|
+
}
|
|
78
103
|
async function request(config, reqConfig) {
|
|
79
104
|
const fetchFn = config.fetchApi || fetch;
|
|
80
105
|
const basePath = config.basePath || BASE_PATH;
|
|
@@ -96,19 +121,16 @@ async function request(config, reqConfig) {
|
|
|
96
121
|
body: reqConfig.body instanceof FormData || reqConfig.body instanceof Blob ? reqConfig.body : reqConfig.body ? JSON.stringify(reqConfig.body) : void 0
|
|
97
122
|
});
|
|
98
123
|
if (!response.ok) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const contentType = response.headers.get("content-type");
|
|
107
|
-
if (contentType?.includes("application/json")) {
|
|
108
|
-
return response.json();
|
|
124
|
+
const body = await readErrorBody(response);
|
|
125
|
+
const obj = typeof body === "object" && body !== null ? body : void 0;
|
|
126
|
+
throw new OFAuthAPIError(response, {
|
|
127
|
+
message: (typeof obj?.message === "string" ? obj.message : void 0) ?? (typeof body === "string" ? body : void 0),
|
|
128
|
+
code: typeof obj?.code === "string" ? obj.code : void 0,
|
|
129
|
+
details: obj?.details
|
|
130
|
+
});
|
|
109
131
|
}
|
|
110
132
|
if (response.status === 204) return {};
|
|
111
|
-
return response
|
|
133
|
+
return await readSuccessBody(response);
|
|
112
134
|
}
|
|
113
135
|
async function proxy(config, opts) {
|
|
114
136
|
const fetchFn = config.fetchApi || fetch;
|
|
@@ -142,19 +164,16 @@ async function proxy(config, opts) {
|
|
|
142
164
|
body: opts.body instanceof FormData || opts.body instanceof Blob ? opts.body : opts.body ? JSON.stringify(opts.body) : void 0
|
|
143
165
|
});
|
|
144
166
|
if (!response.ok) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const contentType = response.headers.get("content-type");
|
|
153
|
-
if (contentType?.includes("application/json")) {
|
|
154
|
-
return response.json();
|
|
167
|
+
const body = await readErrorBody(response);
|
|
168
|
+
const obj = typeof body === "object" && body !== null ? body : void 0;
|
|
169
|
+
throw new OFAuthAPIError(response, {
|
|
170
|
+
message: (typeof obj?.message === "string" ? obj.message : void 0) ?? (typeof body === "string" ? body : void 0),
|
|
171
|
+
code: typeof obj?.code === "string" ? obj.code : void 0,
|
|
172
|
+
details: obj?.details
|
|
173
|
+
});
|
|
155
174
|
}
|
|
156
175
|
if (response.status === 204) return {};
|
|
157
|
-
return response
|
|
176
|
+
return await readSuccessBody(response);
|
|
158
177
|
}
|
|
159
178
|
|
|
160
179
|
// src/client.ts
|
|
@@ -188,9 +207,9 @@ var AccountConnectionsNamespace = class {
|
|
|
188
207
|
}
|
|
189
208
|
/**
|
|
190
209
|
* List connections
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
210
|
+
*
|
|
211
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
212
|
+
*/
|
|
194
213
|
async *iterate(params) {
|
|
195
214
|
let offset = 0;
|
|
196
215
|
let fetched = 0;
|
|
@@ -208,7 +227,8 @@ var AccountConnectionsNamespace = class {
|
|
|
208
227
|
fetched++;
|
|
209
228
|
}
|
|
210
229
|
if (!response.hasMore) return;
|
|
211
|
-
|
|
230
|
+
const nextOffset = response.nextOffset;
|
|
231
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
212
232
|
}
|
|
213
233
|
}
|
|
214
234
|
/**
|
|
@@ -334,9 +354,9 @@ var AccessSelfNamespace = class {
|
|
|
334
354
|
}
|
|
335
355
|
/**
|
|
336
356
|
* List notifications
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
357
|
+
*
|
|
358
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
359
|
+
*/
|
|
340
360
|
async *iterateNotifications(params) {
|
|
341
361
|
let offset = 0;
|
|
342
362
|
let fetched = 0;
|
|
@@ -354,7 +374,8 @@ var AccessSelfNamespace = class {
|
|
|
354
374
|
fetched++;
|
|
355
375
|
}
|
|
356
376
|
if (!response.hasMore) return;
|
|
357
|
-
|
|
377
|
+
const nextOffset = response.nextOffset;
|
|
378
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
358
379
|
}
|
|
359
380
|
}
|
|
360
381
|
/**
|
|
@@ -376,9 +397,9 @@ var AccessSelfNamespace = class {
|
|
|
376
397
|
}
|
|
377
398
|
/**
|
|
378
399
|
* List release forms
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
400
|
+
*
|
|
401
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
402
|
+
*/
|
|
382
403
|
async *iterateReleaseForms(params) {
|
|
383
404
|
let offset = 0;
|
|
384
405
|
let fetched = 0;
|
|
@@ -396,7 +417,8 @@ var AccessSelfNamespace = class {
|
|
|
396
417
|
fetched++;
|
|
397
418
|
}
|
|
398
419
|
if (!response.hasMore) return;
|
|
399
|
-
|
|
420
|
+
const nextOffset = response.nextOffset;
|
|
421
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
400
422
|
}
|
|
401
423
|
}
|
|
402
424
|
/**
|
|
@@ -418,9 +440,9 @@ var AccessSelfNamespace = class {
|
|
|
418
440
|
}
|
|
419
441
|
/**
|
|
420
442
|
* List tagged friend users
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
443
|
+
*
|
|
444
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
445
|
+
*/
|
|
424
446
|
async *iterateTaggedFriendUsers(params) {
|
|
425
447
|
let offset = 0;
|
|
426
448
|
let fetched = 0;
|
|
@@ -438,7 +460,8 @@ var AccessSelfNamespace = class {
|
|
|
438
460
|
fetched++;
|
|
439
461
|
}
|
|
440
462
|
if (!response.hasMore) return;
|
|
441
|
-
|
|
463
|
+
const nextOffset = response.nextOffset;
|
|
464
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
442
465
|
}
|
|
443
466
|
}
|
|
444
467
|
};
|
|
@@ -479,9 +502,9 @@ var AccessEarningsNamespace = class {
|
|
|
479
502
|
}
|
|
480
503
|
/**
|
|
481
504
|
* List transactions
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
505
|
+
*
|
|
506
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
507
|
+
*/
|
|
485
508
|
async *iterateTransactions(params) {
|
|
486
509
|
let marker;
|
|
487
510
|
let fetched = 0;
|
|
@@ -497,7 +520,7 @@ var AccessEarningsNamespace = class {
|
|
|
497
520
|
fetched++;
|
|
498
521
|
}
|
|
499
522
|
if (!response.hasMore) return;
|
|
500
|
-
marker = response.
|
|
523
|
+
marker = response.nextMarker == null ? void 0 : String(response.nextMarker);
|
|
501
524
|
}
|
|
502
525
|
}
|
|
503
526
|
/**
|
|
@@ -508,28 +531,25 @@ var AccessEarningsNamespace = class {
|
|
|
508
531
|
path: "/v2/access/earnings/chargebacks",
|
|
509
532
|
method: "GET",
|
|
510
533
|
query: {
|
|
511
|
-
"limit": params.limit,
|
|
512
|
-
"offset": params.offset,
|
|
513
534
|
"startDate": params.startDate,
|
|
514
|
-
"endDate": params.endDate
|
|
535
|
+
"endDate": params.endDate,
|
|
536
|
+
"marker": params.marker
|
|
515
537
|
}
|
|
516
538
|
});
|
|
517
539
|
}
|
|
518
540
|
/**
|
|
519
541
|
* List chargebacks
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
542
|
+
*
|
|
543
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
544
|
+
*/
|
|
523
545
|
async *iterateChargebacks(params) {
|
|
524
|
-
let
|
|
546
|
+
let marker;
|
|
525
547
|
let fetched = 0;
|
|
526
|
-
const limit = params?.pageSize ?? 20;
|
|
527
548
|
const maxItems = params?.maxItems ?? Infinity;
|
|
528
549
|
while (fetched < maxItems) {
|
|
529
550
|
const response = await this.listChargebacks({
|
|
530
551
|
...params,
|
|
531
|
-
|
|
532
|
-
offset
|
|
552
|
+
marker
|
|
533
553
|
});
|
|
534
554
|
for (const item of response.list) {
|
|
535
555
|
if (fetched >= maxItems) return;
|
|
@@ -537,7 +557,7 @@ var AccessEarningsNamespace = class {
|
|
|
537
557
|
fetched++;
|
|
538
558
|
}
|
|
539
559
|
if (!response.hasMore) return;
|
|
540
|
-
|
|
560
|
+
marker = response.nextMarker == null ? void 0 : String(response.nextMarker);
|
|
541
561
|
}
|
|
542
562
|
}
|
|
543
563
|
};
|
|
@@ -676,6 +696,20 @@ var AccessAnalyticsMassMessagesNamespace = class {
|
|
|
676
696
|
}
|
|
677
697
|
});
|
|
678
698
|
}
|
|
699
|
+
/**
|
|
700
|
+
* Sent mass messages
|
|
701
|
+
*/
|
|
702
|
+
getSent(params) {
|
|
703
|
+
return request(this._config, {
|
|
704
|
+
path: "/v2/access/analytics/mass-messages/sent",
|
|
705
|
+
method: "GET",
|
|
706
|
+
query: {
|
|
707
|
+
"startDate": params.startDate,
|
|
708
|
+
"endDate": params.endDate,
|
|
709
|
+
"limit": params.limit
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
}
|
|
679
713
|
/**
|
|
680
714
|
* Mass messages purchased
|
|
681
715
|
*/
|
|
@@ -705,9 +739,9 @@ var AccessAnalyticsMassMessagesNamespace = class {
|
|
|
705
739
|
}
|
|
706
740
|
/**
|
|
707
741
|
* Mass message buyers
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
742
|
+
*
|
|
743
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
744
|
+
*/
|
|
711
745
|
async *iterateBuyers(params) {
|
|
712
746
|
let marker;
|
|
713
747
|
let fetched = 0;
|
|
@@ -723,7 +757,7 @@ var AccessAnalyticsMassMessagesNamespace = class {
|
|
|
723
757
|
fetched++;
|
|
724
758
|
}
|
|
725
759
|
if (!response.hasMore) return;
|
|
726
|
-
marker = response.
|
|
760
|
+
marker = response.nextMarker == null ? void 0 : String(response.nextMarker);
|
|
727
761
|
}
|
|
728
762
|
}
|
|
729
763
|
};
|
|
@@ -830,9 +864,9 @@ var AccessAnalyticsCampaignsNamespace = class {
|
|
|
830
864
|
}
|
|
831
865
|
/**
|
|
832
866
|
* Top campaigns
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
867
|
+
*
|
|
868
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
869
|
+
*/
|
|
836
870
|
async *iterateTop(params) {
|
|
837
871
|
let offset = 0;
|
|
838
872
|
let fetched = 0;
|
|
@@ -850,7 +884,8 @@ var AccessAnalyticsCampaignsNamespace = class {
|
|
|
850
884
|
fetched++;
|
|
851
885
|
}
|
|
852
886
|
if (!response.hasMore) return;
|
|
853
|
-
|
|
887
|
+
const nextOffset = response.nextOffset;
|
|
888
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
854
889
|
}
|
|
855
890
|
}
|
|
856
891
|
};
|
|
@@ -920,9 +955,9 @@ var AccessUsersListsNamespace = class {
|
|
|
920
955
|
}
|
|
921
956
|
/**
|
|
922
957
|
* List user lists
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
958
|
+
*
|
|
959
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
960
|
+
*/
|
|
926
961
|
async *iterate(params) {
|
|
927
962
|
let offset = 0;
|
|
928
963
|
let fetched = 0;
|
|
@@ -940,7 +975,8 @@ var AccessUsersListsNamespace = class {
|
|
|
940
975
|
fetched++;
|
|
941
976
|
}
|
|
942
977
|
if (!response.hasMore) return;
|
|
943
|
-
|
|
978
|
+
const nextOffset = response.nextOffset;
|
|
979
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
944
980
|
}
|
|
945
981
|
}
|
|
946
982
|
/**
|
|
@@ -1006,9 +1042,9 @@ var AccessUsersListsNamespace = class {
|
|
|
1006
1042
|
}
|
|
1007
1043
|
/**
|
|
1008
1044
|
* List users in user list
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1045
|
+
*
|
|
1046
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1047
|
+
*/
|
|
1012
1048
|
async *iterateUsers(params) {
|
|
1013
1049
|
let offset = 0;
|
|
1014
1050
|
let fetched = 0;
|
|
@@ -1026,7 +1062,8 @@ var AccessUsersListsNamespace = class {
|
|
|
1026
1062
|
fetched++;
|
|
1027
1063
|
}
|
|
1028
1064
|
if (!response.hasMore) return;
|
|
1029
|
-
|
|
1065
|
+
const nextOffset = response.nextOffset;
|
|
1066
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
1030
1067
|
}
|
|
1031
1068
|
}
|
|
1032
1069
|
/**
|
|
@@ -1094,9 +1131,9 @@ var AccessUsersNamespace = class {
|
|
|
1094
1131
|
}
|
|
1095
1132
|
/**
|
|
1096
1133
|
* List restricted users
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1134
|
+
*
|
|
1135
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1136
|
+
*/
|
|
1100
1137
|
async *iterateRestrict(params) {
|
|
1101
1138
|
let offset = 0;
|
|
1102
1139
|
let fetched = 0;
|
|
@@ -1114,7 +1151,8 @@ var AccessUsersNamespace = class {
|
|
|
1114
1151
|
fetched++;
|
|
1115
1152
|
}
|
|
1116
1153
|
if (!response.hasMore) return;
|
|
1117
|
-
|
|
1154
|
+
const nextOffset = response.nextOffset;
|
|
1155
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
1118
1156
|
}
|
|
1119
1157
|
}
|
|
1120
1158
|
/**
|
|
@@ -1150,9 +1188,9 @@ var AccessUsersNamespace = class {
|
|
|
1150
1188
|
}
|
|
1151
1189
|
/**
|
|
1152
1190
|
* List blocked users
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1191
|
+
*
|
|
1192
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1193
|
+
*/
|
|
1156
1194
|
async *iterateBlocked(params) {
|
|
1157
1195
|
let offset = 0;
|
|
1158
1196
|
let fetched = 0;
|
|
@@ -1170,7 +1208,8 @@ var AccessUsersNamespace = class {
|
|
|
1170
1208
|
fetched++;
|
|
1171
1209
|
}
|
|
1172
1210
|
if (!response.hasMore) return;
|
|
1173
|
-
|
|
1211
|
+
const nextOffset = response.nextOffset;
|
|
1212
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
1174
1213
|
}
|
|
1175
1214
|
}
|
|
1176
1215
|
/**
|
|
@@ -1223,9 +1262,9 @@ var AccessChatsNamespace = class {
|
|
|
1223
1262
|
}
|
|
1224
1263
|
/**
|
|
1225
1264
|
* Chats list
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1265
|
+
*
|
|
1266
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1267
|
+
*/
|
|
1229
1268
|
async *iterate(params) {
|
|
1230
1269
|
let offset = 0;
|
|
1231
1270
|
let fetched = 0;
|
|
@@ -1243,7 +1282,8 @@ var AccessChatsNamespace = class {
|
|
|
1243
1282
|
fetched++;
|
|
1244
1283
|
}
|
|
1245
1284
|
if (!response.hasMore) return;
|
|
1246
|
-
|
|
1285
|
+
const nextOffset = response.nextOffset;
|
|
1286
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
1247
1287
|
}
|
|
1248
1288
|
}
|
|
1249
1289
|
/**
|
|
@@ -1256,15 +1296,18 @@ var AccessChatsNamespace = class {
|
|
|
1256
1296
|
query: {
|
|
1257
1297
|
"limit": params.limit,
|
|
1258
1298
|
"offset": params.offset,
|
|
1259
|
-
"query": params.query
|
|
1299
|
+
"query": params.query,
|
|
1300
|
+
"last_id": params.lastId,
|
|
1301
|
+
"first_id": params.firstId,
|
|
1302
|
+
"include_users": params.includeUsers
|
|
1260
1303
|
}
|
|
1261
1304
|
});
|
|
1262
1305
|
}
|
|
1263
1306
|
/**
|
|
1264
1307
|
* Chat messages
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1308
|
+
*
|
|
1309
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1310
|
+
*/
|
|
1268
1311
|
async *iterateMessages(params) {
|
|
1269
1312
|
let offset = 0;
|
|
1270
1313
|
let fetched = 0;
|
|
@@ -1282,7 +1325,8 @@ var AccessChatsNamespace = class {
|
|
|
1282
1325
|
fetched++;
|
|
1283
1326
|
}
|
|
1284
1327
|
if (!response.hasMore) return;
|
|
1285
|
-
|
|
1328
|
+
const nextOffset = response.nextOffset;
|
|
1329
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
1286
1330
|
}
|
|
1287
1331
|
}
|
|
1288
1332
|
/**
|
|
@@ -1324,9 +1368,9 @@ var AccessChatsNamespace = class {
|
|
|
1324
1368
|
}
|
|
1325
1369
|
/**
|
|
1326
1370
|
* Get chat media
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1371
|
+
*
|
|
1372
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1373
|
+
*/
|
|
1330
1374
|
async *iterateMedia(params) {
|
|
1331
1375
|
let offset = 0;
|
|
1332
1376
|
let fetched = 0;
|
|
@@ -1344,7 +1388,8 @@ var AccessChatsNamespace = class {
|
|
|
1344
1388
|
fetched++;
|
|
1345
1389
|
}
|
|
1346
1390
|
if (!response.hasMore) return;
|
|
1347
|
-
|
|
1391
|
+
const nextOffset = response.nextOffset;
|
|
1392
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
1348
1393
|
}
|
|
1349
1394
|
}
|
|
1350
1395
|
};
|
|
@@ -1373,9 +1418,9 @@ var AccessSubscribersNamespace = class {
|
|
|
1373
1418
|
}
|
|
1374
1419
|
/**
|
|
1375
1420
|
* List subscribers
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1421
|
+
*
|
|
1422
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1423
|
+
*/
|
|
1379
1424
|
async *iterate(params) {
|
|
1380
1425
|
let offset = 0;
|
|
1381
1426
|
let fetched = 0;
|
|
@@ -1393,7 +1438,8 @@ var AccessSubscribersNamespace = class {
|
|
|
1393
1438
|
fetched++;
|
|
1394
1439
|
}
|
|
1395
1440
|
if (!response.hasMore) return;
|
|
1396
|
-
|
|
1441
|
+
const nextOffset = response.nextOffset;
|
|
1442
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
1397
1443
|
}
|
|
1398
1444
|
}
|
|
1399
1445
|
/**
|
|
@@ -1449,9 +1495,9 @@ var AccessSubscriptionsNamespace = class {
|
|
|
1449
1495
|
}
|
|
1450
1496
|
/**
|
|
1451
1497
|
* List subscriptions
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1498
|
+
*
|
|
1499
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1500
|
+
*/
|
|
1455
1501
|
async *iterate(params) {
|
|
1456
1502
|
let offset = 0;
|
|
1457
1503
|
let fetched = 0;
|
|
@@ -1469,18 +1515,10 @@ var AccessSubscriptionsNamespace = class {
|
|
|
1469
1515
|
fetched++;
|
|
1470
1516
|
}
|
|
1471
1517
|
if (!response.hasMore) return;
|
|
1472
|
-
|
|
1518
|
+
const nextOffset = response.nextOffset;
|
|
1519
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
1473
1520
|
}
|
|
1474
1521
|
}
|
|
1475
|
-
/**
|
|
1476
|
-
* Get subscription
|
|
1477
|
-
*/
|
|
1478
|
-
get(params) {
|
|
1479
|
-
return request(this._config, {
|
|
1480
|
-
path: `/v2/access/subscriptions/${encodeURIComponent(String(params.subscriptionId))}`,
|
|
1481
|
-
method: "GET"
|
|
1482
|
-
});
|
|
1483
|
-
}
|
|
1484
1522
|
/**
|
|
1485
1523
|
* Get subscription counts
|
|
1486
1524
|
*/
|
|
@@ -1526,9 +1564,9 @@ var AccessPromotionsTrackingLinksNamespace = class {
|
|
|
1526
1564
|
}
|
|
1527
1565
|
/**
|
|
1528
1566
|
* List tracking links
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1567
|
+
*
|
|
1568
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1569
|
+
*/
|
|
1532
1570
|
async *iterate(params) {
|
|
1533
1571
|
let offset = 0;
|
|
1534
1572
|
let fetched = 0;
|
|
@@ -1546,7 +1584,8 @@ var AccessPromotionsTrackingLinksNamespace = class {
|
|
|
1546
1584
|
fetched++;
|
|
1547
1585
|
}
|
|
1548
1586
|
if (!response.hasMore) return;
|
|
1549
|
-
|
|
1587
|
+
const nextOffset = response.nextOffset;
|
|
1588
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
1550
1589
|
}
|
|
1551
1590
|
}
|
|
1552
1591
|
/**
|
|
@@ -1722,15 +1761,6 @@ var AccessPromotionsNamespace = class {
|
|
|
1722
1761
|
body: params.body
|
|
1723
1762
|
});
|
|
1724
1763
|
}
|
|
1725
|
-
/**
|
|
1726
|
-
* Get promotion
|
|
1727
|
-
*/
|
|
1728
|
-
get(params) {
|
|
1729
|
-
return request(this._config, {
|
|
1730
|
-
path: `/v2/access/promotions/${encodeURIComponent(String(params.promotionId))}`,
|
|
1731
|
-
method: "GET"
|
|
1732
|
-
});
|
|
1733
|
-
}
|
|
1734
1764
|
/**
|
|
1735
1765
|
* Update promotion
|
|
1736
1766
|
*/
|
|
@@ -1802,11 +1832,11 @@ var AccessPromotionsNamespace = class {
|
|
|
1802
1832
|
});
|
|
1803
1833
|
}
|
|
1804
1834
|
/**
|
|
1805
|
-
*
|
|
1835
|
+
* Stop promotion
|
|
1806
1836
|
*/
|
|
1807
|
-
|
|
1837
|
+
createStop(params) {
|
|
1808
1838
|
return request(this._config, {
|
|
1809
|
-
path: `/v2/access/promotions/${encodeURIComponent(String(params.promotionId))}/
|
|
1839
|
+
path: `/v2/access/promotions/${encodeURIComponent(String(params.promotionId))}/stop`,
|
|
1810
1840
|
method: "POST"
|
|
1811
1841
|
});
|
|
1812
1842
|
}
|
|
@@ -1831,9 +1861,9 @@ var AccessVaultListsNamespace = class {
|
|
|
1831
1861
|
}
|
|
1832
1862
|
/**
|
|
1833
1863
|
* List vault folders
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1864
|
+
*
|
|
1865
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1866
|
+
*/
|
|
1837
1867
|
async *iterate(params) {
|
|
1838
1868
|
let offset = 0;
|
|
1839
1869
|
let fetched = 0;
|
|
@@ -1851,7 +1881,8 @@ var AccessVaultListsNamespace = class {
|
|
|
1851
1881
|
fetched++;
|
|
1852
1882
|
}
|
|
1853
1883
|
if (!response.hasMore) return;
|
|
1854
|
-
|
|
1884
|
+
const nextOffset = response.nextOffset;
|
|
1885
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
1855
1886
|
}
|
|
1856
1887
|
}
|
|
1857
1888
|
/**
|
|
@@ -1902,9 +1933,9 @@ var AccessVaultListsNamespace = class {
|
|
|
1902
1933
|
}
|
|
1903
1934
|
/**
|
|
1904
1935
|
* List media in vault list
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1936
|
+
*
|
|
1937
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1938
|
+
*/
|
|
1908
1939
|
async *iterateMedia(params) {
|
|
1909
1940
|
let offset = 0;
|
|
1910
1941
|
let fetched = 0;
|
|
@@ -1922,7 +1953,8 @@ var AccessVaultListsNamespace = class {
|
|
|
1922
1953
|
fetched++;
|
|
1923
1954
|
}
|
|
1924
1955
|
if (!response.hasMore) return;
|
|
1925
|
-
|
|
1956
|
+
const nextOffset = response.nextOffset;
|
|
1957
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
1926
1958
|
}
|
|
1927
1959
|
}
|
|
1928
1960
|
/**
|
|
@@ -1961,9 +1993,9 @@ var AccessVaultNamespace = class {
|
|
|
1961
1993
|
}
|
|
1962
1994
|
/**
|
|
1963
1995
|
* List vault media
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1996
|
+
*
|
|
1997
|
+
* Returns an async iterator that automatically paginates through all results.
|
|
1998
|
+
*/
|
|
1967
1999
|
async *iterateMedia(params) {
|
|
1968
2000
|
let offset = 0;
|
|
1969
2001
|
let fetched = 0;
|
|
@@ -1981,7 +2013,8 @@ var AccessVaultNamespace = class {
|
|
|
1981
2013
|
fetched++;
|
|
1982
2014
|
}
|
|
1983
2015
|
if (!response.hasMore) return;
|
|
1984
|
-
|
|
2016
|
+
const nextOffset = response.nextOffset;
|
|
2017
|
+
offset = typeof nextOffset === "number" ? nextOffset : typeof nextOffset === "string" && nextOffset.trim() !== "" && Number.isFinite(Number(nextOffset)) ? Number(nextOffset) : offset + response.list.length;
|
|
1985
2018
|
}
|
|
1986
2019
|
}
|
|
1987
2020
|
};
|
|
@@ -2107,45 +2140,6 @@ var AccessNamespace = class {
|
|
|
2107
2140
|
method: "DELETE"
|
|
2108
2141
|
});
|
|
2109
2142
|
}
|
|
2110
|
-
/**
|
|
2111
|
-
* List mass messages
|
|
2112
|
-
*/
|
|
2113
|
-
listMassMessages(params) {
|
|
2114
|
-
return request(this._config, {
|
|
2115
|
-
path: "/v2/access/mass-messages",
|
|
2116
|
-
method: "GET",
|
|
2117
|
-
query: {
|
|
2118
|
-
"limit": params.limit,
|
|
2119
|
-
"offset": params.offset,
|
|
2120
|
-
"type": params.type
|
|
2121
|
-
}
|
|
2122
|
-
});
|
|
2123
|
-
}
|
|
2124
|
-
/**
|
|
2125
|
-
* List mass messages
|
|
2126
|
-
*
|
|
2127
|
-
* Returns an async iterator that automatically paginates through all results.
|
|
2128
|
-
*/
|
|
2129
|
-
async *iterateMassMessages(params) {
|
|
2130
|
-
let offset = 0;
|
|
2131
|
-
let fetched = 0;
|
|
2132
|
-
const limit = params?.pageSize ?? 20;
|
|
2133
|
-
const maxItems = params?.maxItems ?? Infinity;
|
|
2134
|
-
while (fetched < maxItems) {
|
|
2135
|
-
const response = await this.listMassMessages({
|
|
2136
|
-
...params,
|
|
2137
|
-
limit: Math.min(limit, maxItems - fetched),
|
|
2138
|
-
offset
|
|
2139
|
-
});
|
|
2140
|
-
for (const item of response.list) {
|
|
2141
|
-
if (fetched >= maxItems) return;
|
|
2142
|
-
yield item;
|
|
2143
|
-
fetched++;
|
|
2144
|
-
}
|
|
2145
|
-
if (!response.hasMore) return;
|
|
2146
|
-
offset = response.nextOffset ?? offset + response.list.length;
|
|
2147
|
-
}
|
|
2148
|
-
}
|
|
2149
2143
|
/**
|
|
2150
2144
|
* Create mass message
|
|
2151
2145
|
*/
|