@proxyrequest/sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/README.md +319 -0
- package/SECURITY.md +13 -0
- package/dist/index.cjs +1895 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1107 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +1107 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1836 -0
- package/dist/index.js.map +1 -0
- package/dist/models-ECy_bhdn.d.ts +132 -0
- package/dist/models-ECy_bhdn.d.ts.map +1 -0
- package/dist/models-VMmyyuf_.d.cts +132 -0
- package/dist/models-VMmyyuf_.d.cts.map +1 -0
- package/dist/models.cjs +0 -0
- package/dist/models.d.cts +2 -0
- package/dist/models.d.ts +2 -0
- package/dist/models.js +0 -0
- package/dist/openapi.cjs +0 -0
- package/dist/openapi.d.cts +2 -0
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +0 -0
- package/dist/schema-CvCxeox5.d.cts +9762 -0
- package/dist/schema-CvCxeox5.d.cts.map +1 -0
- package/dist/schema-CvCxeox5.d.ts +9762 -0
- package/dist/schema-CvCxeox5.d.ts.map +1 -0
- package/docs/errors-and-pagination.md +36 -0
- package/docs/getting-started.md +41 -0
- package/docs/releasing.md +25 -0
- package/docs/reseller-workflow.md +38 -0
- package/docs/webhooks.md +23 -0
- package/package.json +128 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1836 @@
|
|
|
1
|
+
import createClient from "openapi-fetch";
|
|
2
|
+
|
|
3
|
+
//#region src/errors.ts
|
|
4
|
+
const encoder$1 = new TextEncoder();
|
|
5
|
+
var ProxyRequestError = class extends Error {
|
|
6
|
+
name = "ProxyRequestError";
|
|
7
|
+
};
|
|
8
|
+
var ApiError = class ApiError extends ProxyRequestError {
|
|
9
|
+
name = "ApiError";
|
|
10
|
+
kind;
|
|
11
|
+
statusCode;
|
|
12
|
+
detail;
|
|
13
|
+
fieldErrors;
|
|
14
|
+
requestId;
|
|
15
|
+
retryAfter;
|
|
16
|
+
contentLanguage;
|
|
17
|
+
headers;
|
|
18
|
+
rawBody;
|
|
19
|
+
cause;
|
|
20
|
+
constructor(message, options) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.kind = options.kind;
|
|
23
|
+
this.statusCode = options.statusCode;
|
|
24
|
+
this.detail = options.detail;
|
|
25
|
+
this.fieldErrors = options.fieldErrors ?? {};
|
|
26
|
+
this.requestId = options.requestId;
|
|
27
|
+
this.retryAfter = options.retryAfter;
|
|
28
|
+
this.contentLanguage = options.contentLanguage;
|
|
29
|
+
this.headers = options.headers ?? {};
|
|
30
|
+
this.rawBody = options.rawBody ?? /* @__PURE__ */ new Uint8Array();
|
|
31
|
+
this.cause = options.cause;
|
|
32
|
+
}
|
|
33
|
+
static async fromResponse(response) {
|
|
34
|
+
const headers = headersToRecord(response.headers);
|
|
35
|
+
let rawBody = /* @__PURE__ */ new Uint8Array();
|
|
36
|
+
try {
|
|
37
|
+
rawBody = new Uint8Array(await response.clone().arrayBuffer());
|
|
38
|
+
} catch {}
|
|
39
|
+
return ApiError.fromPayload(response.status, rawBody, headers);
|
|
40
|
+
}
|
|
41
|
+
static fromPayload(statusCode, rawBody, headers = {}) {
|
|
42
|
+
const payload = decodeJson(rawBody);
|
|
43
|
+
const detail = errorDetail(payload);
|
|
44
|
+
const kind = kindForStatus(statusCode);
|
|
45
|
+
const requestId = header(headers, "x-request-id", "x-correlation-id");
|
|
46
|
+
const retryAfter = numberHeader(headers, "retry-after");
|
|
47
|
+
const contentLanguage = header(headers, "content-language");
|
|
48
|
+
return new ApiError(detail ?? `ProxyRequest API returned HTTP ${statusCode}.`, {
|
|
49
|
+
kind,
|
|
50
|
+
statusCode,
|
|
51
|
+
...detail === void 0 ? {} : { detail },
|
|
52
|
+
fieldErrors: fieldErrors(payload),
|
|
53
|
+
...requestId === void 0 ? {} : { requestId },
|
|
54
|
+
...retryAfter === void 0 ? {} : { retryAfter },
|
|
55
|
+
...contentLanguage === void 0 ? {} : { contentLanguage },
|
|
56
|
+
headers,
|
|
57
|
+
rawBody
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
static network(cause) {
|
|
61
|
+
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
62
|
+
return new ApiError(`ProxyRequest network request failed: ${detail}`, {
|
|
63
|
+
kind: "network",
|
|
64
|
+
cause
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
static unexpected(message, cause) {
|
|
68
|
+
return new ApiError(message, {
|
|
69
|
+
kind: "unexpected",
|
|
70
|
+
...cause === void 0 ? {} : { cause }
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var PaginationError = class extends ProxyRequestError {
|
|
75
|
+
name = "PaginationError";
|
|
76
|
+
};
|
|
77
|
+
var InvalidSignatureError = class extends ProxyRequestError {
|
|
78
|
+
name = "InvalidSignatureError";
|
|
79
|
+
};
|
|
80
|
+
function kindForStatus(statusCode) {
|
|
81
|
+
if (statusCode === 400 || statusCode === 422) return "validation";
|
|
82
|
+
if (statusCode === 401) return "authentication";
|
|
83
|
+
if (statusCode === 403) return "permission";
|
|
84
|
+
if (statusCode === 404) return "not_found";
|
|
85
|
+
if (statusCode === 409) return "conflict";
|
|
86
|
+
if (statusCode === 429) return "rate_limit";
|
|
87
|
+
if (statusCode >= 500) return "server";
|
|
88
|
+
return "unexpected";
|
|
89
|
+
}
|
|
90
|
+
function headersToRecord(headers) {
|
|
91
|
+
return Object.fromEntries([...headers.entries()].map(([key, value]) => [key.toLowerCase(), value]));
|
|
92
|
+
}
|
|
93
|
+
function header(headers, ...names) {
|
|
94
|
+
for (const name of names) {
|
|
95
|
+
const value = headers[name.toLowerCase()];
|
|
96
|
+
if (value !== void 0 && value !== "") return value;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function numberHeader(headers, name) {
|
|
100
|
+
const value = header(headers, name);
|
|
101
|
+
if (value === void 0) return void 0;
|
|
102
|
+
const number = Number(value);
|
|
103
|
+
return Number.isFinite(number) ? number : void 0;
|
|
104
|
+
}
|
|
105
|
+
function decodeJson(rawBody) {
|
|
106
|
+
if (rawBody.byteLength === 0) return void 0;
|
|
107
|
+
try {
|
|
108
|
+
return JSON.parse(new TextDecoder().decode(rawBody));
|
|
109
|
+
} catch {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function errorDetail(payload) {
|
|
114
|
+
if (typeof payload === "string" && payload.length > 0) return payload;
|
|
115
|
+
if (!isRecord(payload)) return void 0;
|
|
116
|
+
for (const key of [
|
|
117
|
+
"detail",
|
|
118
|
+
"message",
|
|
119
|
+
"error"
|
|
120
|
+
]) {
|
|
121
|
+
const value = payload[key];
|
|
122
|
+
if (typeof value === "string" && value.length > 0) return value;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function fieldErrors(payload) {
|
|
126
|
+
if (!isRecord(payload)) return {};
|
|
127
|
+
const source = isRecord(payload.errors) ? payload.errors : payload;
|
|
128
|
+
const result = {};
|
|
129
|
+
for (const [key, value] of Object.entries(source)) {
|
|
130
|
+
if ([
|
|
131
|
+
"detail",
|
|
132
|
+
"message",
|
|
133
|
+
"error",
|
|
134
|
+
"code"
|
|
135
|
+
].includes(key)) continue;
|
|
136
|
+
if (typeof value === "string") result[key] = [value];
|
|
137
|
+
if (Array.isArray(value) && value.every((item) => typeof item === "string")) result[key] = value;
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
function isRecord(value) {
|
|
142
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/files.ts
|
|
147
|
+
var FileDownload = class FileDownload {
|
|
148
|
+
content;
|
|
149
|
+
filename;
|
|
150
|
+
contentType;
|
|
151
|
+
constructor(content, filename, contentType) {
|
|
152
|
+
this.content = content;
|
|
153
|
+
this.filename = filename;
|
|
154
|
+
this.contentType = contentType;
|
|
155
|
+
}
|
|
156
|
+
static fromResponse(content, headers) {
|
|
157
|
+
const bytes = content instanceof Uint8Array ? content : new Uint8Array(content);
|
|
158
|
+
const contentType = (headers.get("content-type") ?? "application/octet-stream").split(";", 1)[0]?.trim();
|
|
159
|
+
return new FileDownload(bytes, filenameFromDisposition(headers.get("content-disposition")), contentType || "application/octet-stream");
|
|
160
|
+
}
|
|
161
|
+
arrayBuffer() {
|
|
162
|
+
return this.content.slice().buffer;
|
|
163
|
+
}
|
|
164
|
+
blob() {
|
|
165
|
+
return new Blob([this.arrayBuffer()], { type: this.contentType });
|
|
166
|
+
}
|
|
167
|
+
text() {
|
|
168
|
+
return new TextDecoder().decode(this.content);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
function filenameFromDisposition(disposition) {
|
|
172
|
+
if (disposition === null) return "download.bin";
|
|
173
|
+
const encoded = /filename\*=UTF-8''([^;]+)/iu.exec(disposition)?.[1];
|
|
174
|
+
if (encoded !== void 0) try {
|
|
175
|
+
return safeBasename(decodeURIComponent(encoded.trim()));
|
|
176
|
+
} catch {
|
|
177
|
+
return safeBasename(encoded.trim());
|
|
178
|
+
}
|
|
179
|
+
const plain = /filename=(?:"([^"]+)"|([^;]+))/iu.exec(disposition);
|
|
180
|
+
return safeBasename((plain?.[1] ?? plain?.[2] ?? "download.bin").trim());
|
|
181
|
+
}
|
|
182
|
+
function safeBasename(filename) {
|
|
183
|
+
return filename.replaceAll("\\", "/").split("/").at(-1)?.replaceAll("\0", "").trim() || "download.bin";
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/generated/resources.ts
|
|
188
|
+
var APIKeysResource = class {
|
|
189
|
+
#client;
|
|
190
|
+
constructor(client) {
|
|
191
|
+
this.#client = client;
|
|
192
|
+
}
|
|
193
|
+
/** List API keys */
|
|
194
|
+
async list(options = {}) {
|
|
195
|
+
return this.#client._call({
|
|
196
|
+
operationId: "api_keys_list",
|
|
197
|
+
method: "GET",
|
|
198
|
+
path: "/api-keys"
|
|
199
|
+
}, {
|
|
200
|
+
query: {
|
|
201
|
+
limit: options.limit,
|
|
202
|
+
offset: options.offset
|
|
203
|
+
},
|
|
204
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
205
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/** Create an API key */
|
|
209
|
+
async create(options = {}) {
|
|
210
|
+
return this.#client._call({
|
|
211
|
+
operationId: "api_keys_create",
|
|
212
|
+
method: "POST",
|
|
213
|
+
path: "/api-keys"
|
|
214
|
+
}, {
|
|
215
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
216
|
+
...options.body === void 0 ? {} : { body: options.body },
|
|
217
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/** Revoke an API key */
|
|
221
|
+
async delete(options) {
|
|
222
|
+
return this.#client._call({
|
|
223
|
+
operationId: "api_keys_destroy",
|
|
224
|
+
method: "DELETE",
|
|
225
|
+
path: "/api-keys/{id}"
|
|
226
|
+
}, {
|
|
227
|
+
path: { id: options.id },
|
|
228
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
229
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
var AffiliatesResource = class {
|
|
234
|
+
#client;
|
|
235
|
+
constructor(client) {
|
|
236
|
+
this.#client = client;
|
|
237
|
+
}
|
|
238
|
+
/** List referred customers */
|
|
239
|
+
async list(options = {}) {
|
|
240
|
+
return this.#client._call({
|
|
241
|
+
operationId: "affiliates_list",
|
|
242
|
+
method: "GET",
|
|
243
|
+
path: "/affiliates"
|
|
244
|
+
}, {
|
|
245
|
+
query: {
|
|
246
|
+
limit: options.limit,
|
|
247
|
+
offset: options.offset
|
|
248
|
+
},
|
|
249
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
250
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
/** List affiliate reward entries */
|
|
254
|
+
async listRewards(options = {}) {
|
|
255
|
+
return this.#client._call({
|
|
256
|
+
operationId: "affiliates_rewards_list",
|
|
257
|
+
method: "GET",
|
|
258
|
+
path: "/affiliates/rewards"
|
|
259
|
+
}, {
|
|
260
|
+
query: {
|
|
261
|
+
limit: options.limit,
|
|
262
|
+
offset: options.offset
|
|
263
|
+
},
|
|
264
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
265
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
/** Get affiliate earnings over time */
|
|
269
|
+
async getRewardsOverall(options = {}) {
|
|
270
|
+
return this.#client._call({
|
|
271
|
+
operationId: "affiliates_rewards_overall_retrieve",
|
|
272
|
+
method: "GET",
|
|
273
|
+
path: "/affiliates/rewards/overall"
|
|
274
|
+
}, {
|
|
275
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
276
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
var AnalyticsResource = class {
|
|
281
|
+
#client;
|
|
282
|
+
constructor(client) {
|
|
283
|
+
this.#client = client;
|
|
284
|
+
}
|
|
285
|
+
/** List data transactions */
|
|
286
|
+
async getTransactions(options) {
|
|
287
|
+
return this.#client._call({
|
|
288
|
+
operationId: "analytics_transactions_retrieve",
|
|
289
|
+
method: "GET",
|
|
290
|
+
path: "/analytics/{id}/transactions"
|
|
291
|
+
}, {
|
|
292
|
+
path: { id: options.id },
|
|
293
|
+
query: {
|
|
294
|
+
end: options.end,
|
|
295
|
+
limit: options.limit,
|
|
296
|
+
offset: options.offset,
|
|
297
|
+
recipient_id: options.recipientId,
|
|
298
|
+
sender_id: options.senderId,
|
|
299
|
+
start: options.start,
|
|
300
|
+
timezone: options.timezone,
|
|
301
|
+
type: options.type
|
|
302
|
+
},
|
|
303
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
304
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
/** List active proxy connections */
|
|
308
|
+
async getConnections(options = {}) {
|
|
309
|
+
return this.#client._call({
|
|
310
|
+
operationId: "analytics_connections_retrieve",
|
|
311
|
+
method: "GET",
|
|
312
|
+
path: "/analytics/connections"
|
|
313
|
+
}, {
|
|
314
|
+
query: {
|
|
315
|
+
limit: options.limit,
|
|
316
|
+
offset: options.offset,
|
|
317
|
+
package_id: options.packageId,
|
|
318
|
+
user_id: options.userId
|
|
319
|
+
},
|
|
320
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
321
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
/** List top destination domains */
|
|
325
|
+
async listDomains(options = {}) {
|
|
326
|
+
return this.#client._call({
|
|
327
|
+
operationId: "analytics_domains_retrieve",
|
|
328
|
+
method: "GET",
|
|
329
|
+
path: "/analytics/domains"
|
|
330
|
+
}, {
|
|
331
|
+
query: {
|
|
332
|
+
end: options.end,
|
|
333
|
+
hostname: options.hostname,
|
|
334
|
+
include_sub_users: options.includeSubUsers,
|
|
335
|
+
ledger_id: options.ledgerId,
|
|
336
|
+
limit: options.limit,
|
|
337
|
+
offset: options.offset,
|
|
338
|
+
ordering: options.ordering,
|
|
339
|
+
package_id: options.packageId,
|
|
340
|
+
search: options.search,
|
|
341
|
+
start: options.start,
|
|
342
|
+
timezone: options.timezone,
|
|
343
|
+
user_id: options.userId
|
|
344
|
+
},
|
|
345
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
346
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
/** List proxy request activity */
|
|
350
|
+
async listFeed(options = {}) {
|
|
351
|
+
return this.#client._call({
|
|
352
|
+
operationId: "analytics_feed_retrieve",
|
|
353
|
+
method: "GET",
|
|
354
|
+
path: "/analytics/feed"
|
|
355
|
+
}, {
|
|
356
|
+
query: {
|
|
357
|
+
city: options.city,
|
|
358
|
+
country: options.country,
|
|
359
|
+
end: options.end,
|
|
360
|
+
hostname: options.hostname,
|
|
361
|
+
ledger_id: options.ledgerId,
|
|
362
|
+
limit: options.limit,
|
|
363
|
+
offset: options.offset,
|
|
364
|
+
package_id: options.packageId,
|
|
365
|
+
protocol: options.protocol,
|
|
366
|
+
region: options.region,
|
|
367
|
+
search: options.search,
|
|
368
|
+
start: options.start,
|
|
369
|
+
timezone: options.timezone,
|
|
370
|
+
user_id: options.userId
|
|
371
|
+
},
|
|
372
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
373
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
/** List proxy error logs */
|
|
377
|
+
async listLogs(options = {}) {
|
|
378
|
+
return this.#client._call({
|
|
379
|
+
operationId: "analytics_logs_retrieve",
|
|
380
|
+
method: "GET",
|
|
381
|
+
path: "/analytics/logs"
|
|
382
|
+
}, {
|
|
383
|
+
query: {
|
|
384
|
+
city: options.city,
|
|
385
|
+
country: options.country,
|
|
386
|
+
end: options.end,
|
|
387
|
+
error_code: options.errorCode,
|
|
388
|
+
hostname: options.hostname,
|
|
389
|
+
ledger_id: options.ledgerId,
|
|
390
|
+
limit: options.limit,
|
|
391
|
+
offset: options.offset,
|
|
392
|
+
package_id: options.packageId,
|
|
393
|
+
protocol: options.protocol,
|
|
394
|
+
region: options.region,
|
|
395
|
+
start: options.start,
|
|
396
|
+
timezone: options.timezone,
|
|
397
|
+
user_id: options.userId
|
|
398
|
+
},
|
|
399
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
400
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
/** Get traffic totals over time */
|
|
404
|
+
async getOverall(options = {}) {
|
|
405
|
+
return this.#client._call({
|
|
406
|
+
operationId: "analytics_overall_retrieve",
|
|
407
|
+
method: "GET",
|
|
408
|
+
path: "/analytics/overall"
|
|
409
|
+
}, {
|
|
410
|
+
query: {
|
|
411
|
+
end: options.end,
|
|
412
|
+
include_sub_users: options.includeSubUsers,
|
|
413
|
+
limit: options.limit,
|
|
414
|
+
offset: options.offset,
|
|
415
|
+
package_id: options.packageId,
|
|
416
|
+
start: options.start,
|
|
417
|
+
timezone: options.timezone,
|
|
418
|
+
user_id: options.userId
|
|
419
|
+
},
|
|
420
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
421
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
var AuthorizationResource = class {
|
|
426
|
+
#client;
|
|
427
|
+
constructor(client) {
|
|
428
|
+
this.#client = client;
|
|
429
|
+
}
|
|
430
|
+
/** Sign in with email or username */
|
|
431
|
+
async login(options) {
|
|
432
|
+
return this.#client._call({
|
|
433
|
+
operationId: "login_create",
|
|
434
|
+
method: "POST",
|
|
435
|
+
path: "/login"
|
|
436
|
+
}, {
|
|
437
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
438
|
+
body: options.body,
|
|
439
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
/** Sign in with Google */
|
|
443
|
+
async loginWithGoogle(options) {
|
|
444
|
+
return this.#client._call({
|
|
445
|
+
operationId: "login_google_create",
|
|
446
|
+
method: "POST",
|
|
447
|
+
path: "/login/google"
|
|
448
|
+
}, {
|
|
449
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
450
|
+
body: options.body,
|
|
451
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
/** Send a password recovery email */
|
|
455
|
+
async recoverPassword(options) {
|
|
456
|
+
return this.#client._call({
|
|
457
|
+
operationId: "recover_password_create",
|
|
458
|
+
method: "POST",
|
|
459
|
+
path: "/recover-password"
|
|
460
|
+
}, {
|
|
461
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
462
|
+
body: options.body,
|
|
463
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
/** Refresh an access token */
|
|
467
|
+
async refresh(options) {
|
|
468
|
+
return this.#client._call({
|
|
469
|
+
operationId: "refresh_create",
|
|
470
|
+
method: "POST",
|
|
471
|
+
path: "/refresh"
|
|
472
|
+
}, {
|
|
473
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
474
|
+
body: options.body,
|
|
475
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
/** Create a customer account */
|
|
479
|
+
async signup(options) {
|
|
480
|
+
return this.#client._call({
|
|
481
|
+
operationId: "signup_create",
|
|
482
|
+
method: "POST",
|
|
483
|
+
path: "/signup"
|
|
484
|
+
}, {
|
|
485
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
486
|
+
body: options.body,
|
|
487
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
var CouponsResource = class {
|
|
492
|
+
#client;
|
|
493
|
+
constructor(client) {
|
|
494
|
+
this.#client = client;
|
|
495
|
+
}
|
|
496
|
+
/** List available coupons */
|
|
497
|
+
async list(options = {}) {
|
|
498
|
+
return this.#client._call({
|
|
499
|
+
operationId: "coupons_list",
|
|
500
|
+
method: "GET",
|
|
501
|
+
path: "/coupons"
|
|
502
|
+
}, {
|
|
503
|
+
query: {
|
|
504
|
+
code: options.code,
|
|
505
|
+
limit: options.limit,
|
|
506
|
+
offset: options.offset,
|
|
507
|
+
ordering: options.ordering,
|
|
508
|
+
search: options.search,
|
|
509
|
+
type: options.type
|
|
510
|
+
},
|
|
511
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
512
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
/** Create a coupon */
|
|
516
|
+
async create(options) {
|
|
517
|
+
return this.#client._call({
|
|
518
|
+
operationId: "coupons_create",
|
|
519
|
+
method: "POST",
|
|
520
|
+
path: "/coupons"
|
|
521
|
+
}, {
|
|
522
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
523
|
+
body: options.body,
|
|
524
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
/** Get a coupon */
|
|
528
|
+
async get(options) {
|
|
529
|
+
return this.#client._call({
|
|
530
|
+
operationId: "coupons_retrieve",
|
|
531
|
+
method: "GET",
|
|
532
|
+
path: "/coupons/{id}"
|
|
533
|
+
}, {
|
|
534
|
+
path: { id: options.id },
|
|
535
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
536
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
/** Replace a coupon */
|
|
540
|
+
async replace(options) {
|
|
541
|
+
return this.#client._call({
|
|
542
|
+
operationId: "coupons_update",
|
|
543
|
+
method: "PUT",
|
|
544
|
+
path: "/coupons/{id}"
|
|
545
|
+
}, {
|
|
546
|
+
path: { id: options.id },
|
|
547
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
548
|
+
body: options.body,
|
|
549
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
/** Update a coupon */
|
|
553
|
+
async update(options) {
|
|
554
|
+
return this.#client._call({
|
|
555
|
+
operationId: "coupons_partial_update",
|
|
556
|
+
method: "PATCH",
|
|
557
|
+
path: "/coupons/{id}"
|
|
558
|
+
}, {
|
|
559
|
+
path: { id: options.id },
|
|
560
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
561
|
+
...options.body === void 0 ? {} : { body: options.body },
|
|
562
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
/** Delete a coupon */
|
|
566
|
+
async delete(options) {
|
|
567
|
+
return this.#client._call({
|
|
568
|
+
operationId: "coupons_destroy",
|
|
569
|
+
method: "DELETE",
|
|
570
|
+
path: "/coupons/{id}"
|
|
571
|
+
}, {
|
|
572
|
+
path: { id: options.id },
|
|
573
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
574
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
/** List coupon redemptions */
|
|
578
|
+
async listRedeems(options) {
|
|
579
|
+
return this.#client._call({
|
|
580
|
+
operationId: "coupons_redeems_list",
|
|
581
|
+
method: "GET",
|
|
582
|
+
path: "/coupons/{id}/redeems"
|
|
583
|
+
}, {
|
|
584
|
+
path: { id: options.id },
|
|
585
|
+
query: {
|
|
586
|
+
code: options.code,
|
|
587
|
+
limit: options.limit,
|
|
588
|
+
offset: options.offset,
|
|
589
|
+
ordering: options.ordering,
|
|
590
|
+
type: options.type
|
|
591
|
+
},
|
|
592
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
593
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
/** Calculate a discounted price */
|
|
597
|
+
async calculatePrice(options) {
|
|
598
|
+
return this.#client._call({
|
|
599
|
+
operationId: "coupons_calculate_price_create",
|
|
600
|
+
method: "POST",
|
|
601
|
+
path: "/coupons/calculate-price"
|
|
602
|
+
}, {
|
|
603
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
604
|
+
body: options.body,
|
|
605
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
var InvoicesResource = class {
|
|
610
|
+
#client;
|
|
611
|
+
constructor(client) {
|
|
612
|
+
this.#client = client;
|
|
613
|
+
}
|
|
614
|
+
/** List invoices */
|
|
615
|
+
async list(options = {}) {
|
|
616
|
+
return this.#client._call({
|
|
617
|
+
operationId: "invoices_list",
|
|
618
|
+
method: "GET",
|
|
619
|
+
path: "/invoices"
|
|
620
|
+
}, {
|
|
621
|
+
query: {
|
|
622
|
+
gateway: options.gateway,
|
|
623
|
+
internal_id: options.internalId,
|
|
624
|
+
limit: options.limit,
|
|
625
|
+
offset: options.offset,
|
|
626
|
+
ordering: options.ordering,
|
|
627
|
+
package__id: options.packageId,
|
|
628
|
+
search: options.search,
|
|
629
|
+
status: options.status,
|
|
630
|
+
type: options.type,
|
|
631
|
+
user__email: options.userEmail,
|
|
632
|
+
user__id: options.userId
|
|
633
|
+
},
|
|
634
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
635
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
/** Create an invoice */
|
|
639
|
+
async create(options) {
|
|
640
|
+
return this.#client._call({
|
|
641
|
+
operationId: "invoices_create",
|
|
642
|
+
method: "POST",
|
|
643
|
+
path: "/invoices"
|
|
644
|
+
}, {
|
|
645
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
646
|
+
body: options.body,
|
|
647
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
/** Get an invoice */
|
|
651
|
+
async get(options) {
|
|
652
|
+
return this.#client._call({
|
|
653
|
+
operationId: "invoices_retrieve",
|
|
654
|
+
method: "GET",
|
|
655
|
+
path: "/invoices/{id}"
|
|
656
|
+
}, {
|
|
657
|
+
path: { id: options.id },
|
|
658
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
659
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
/** Delete an invoice */
|
|
663
|
+
async delete(options) {
|
|
664
|
+
return this.#client._call({
|
|
665
|
+
operationId: "invoices_destroy",
|
|
666
|
+
method: "DELETE",
|
|
667
|
+
path: "/invoices/{id}"
|
|
668
|
+
}, {
|
|
669
|
+
path: { id: options.id },
|
|
670
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
671
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
/** Download an invoice PDF */
|
|
675
|
+
async downloadPdf(options) {
|
|
676
|
+
return this.#client._call({
|
|
677
|
+
operationId: "invoices_download_pdf_retrieve",
|
|
678
|
+
method: "GET",
|
|
679
|
+
path: "/invoices/{id}/download/pdf",
|
|
680
|
+
binary: true
|
|
681
|
+
}, {
|
|
682
|
+
path: { id: options.id },
|
|
683
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
684
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
/** Get an invoice payment link */
|
|
688
|
+
async getPaymentLink(options) {
|
|
689
|
+
return this.#client._call({
|
|
690
|
+
operationId: "invoices_pay_retrieve",
|
|
691
|
+
method: "GET",
|
|
692
|
+
path: "/invoices/{id}/pay"
|
|
693
|
+
}, {
|
|
694
|
+
path: { id: options.id },
|
|
695
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
696
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
var LocationsResource = class {
|
|
701
|
+
#client;
|
|
702
|
+
constructor(client) {
|
|
703
|
+
this.#client = client;
|
|
704
|
+
}
|
|
705
|
+
/** List available autonomous systems */
|
|
706
|
+
async listAsns(options = {}) {
|
|
707
|
+
return this.#client._call({
|
|
708
|
+
operationId: "locations_asn_list",
|
|
709
|
+
method: "GET",
|
|
710
|
+
path: "/locations/asn"
|
|
711
|
+
}, {
|
|
712
|
+
query: {
|
|
713
|
+
code: options.code,
|
|
714
|
+
country__code: options.countryCode,
|
|
715
|
+
global: options.global,
|
|
716
|
+
limit: options.limit,
|
|
717
|
+
name: options.name,
|
|
718
|
+
offset: options.offset,
|
|
719
|
+
ordering: options.ordering,
|
|
720
|
+
package_id: options.packageId,
|
|
721
|
+
search: options.search
|
|
722
|
+
},
|
|
723
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
724
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
/** List available cities */
|
|
728
|
+
async listCities(options = {}) {
|
|
729
|
+
return this.#client._call({
|
|
730
|
+
operationId: "locations_cities_list",
|
|
731
|
+
method: "GET",
|
|
732
|
+
path: "/locations/cities"
|
|
733
|
+
}, {
|
|
734
|
+
query: {
|
|
735
|
+
code: options.code,
|
|
736
|
+
country__code: options.countryCode,
|
|
737
|
+
limit: options.limit,
|
|
738
|
+
name: options.name,
|
|
739
|
+
offset: options.offset,
|
|
740
|
+
ordering: options.ordering,
|
|
741
|
+
package_id: options.packageId,
|
|
742
|
+
region__code: options.regionCode,
|
|
743
|
+
search: options.search
|
|
744
|
+
},
|
|
745
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
746
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
/** Get a city */
|
|
750
|
+
async getCity(options) {
|
|
751
|
+
return this.#client._call({
|
|
752
|
+
operationId: "locations_cities_retrieve",
|
|
753
|
+
method: "GET",
|
|
754
|
+
path: "/locations/cities/{id}"
|
|
755
|
+
}, {
|
|
756
|
+
path: { id: options.id },
|
|
757
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
758
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
/** List available continents */
|
|
762
|
+
async listContinents(options = {}) {
|
|
763
|
+
return this.#client._call({
|
|
764
|
+
operationId: "locations_continents_list",
|
|
765
|
+
method: "GET",
|
|
766
|
+
path: "/locations/continents"
|
|
767
|
+
}, {
|
|
768
|
+
query: {
|
|
769
|
+
code: options.code,
|
|
770
|
+
limit: options.limit,
|
|
771
|
+
name: options.name,
|
|
772
|
+
offset: options.offset,
|
|
773
|
+
ordering: options.ordering,
|
|
774
|
+
package_id: options.packageId,
|
|
775
|
+
search: options.search
|
|
776
|
+
},
|
|
777
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
778
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
/** Get a continent */
|
|
782
|
+
async getContinent(options) {
|
|
783
|
+
return this.#client._call({
|
|
784
|
+
operationId: "locations_continents_retrieve",
|
|
785
|
+
method: "GET",
|
|
786
|
+
path: "/locations/continents/{id}"
|
|
787
|
+
}, {
|
|
788
|
+
path: { id: options.id },
|
|
789
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
790
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
/** List available countries */
|
|
794
|
+
async listCountries(options = {}) {
|
|
795
|
+
return this.#client._call({
|
|
796
|
+
operationId: "locations_countries_list",
|
|
797
|
+
method: "GET",
|
|
798
|
+
path: "/locations/countries"
|
|
799
|
+
}, {
|
|
800
|
+
query: {
|
|
801
|
+
code: options.code,
|
|
802
|
+
limit: options.limit,
|
|
803
|
+
name: options.name,
|
|
804
|
+
offset: options.offset,
|
|
805
|
+
ordering: options.ordering,
|
|
806
|
+
package_id: options.packageId,
|
|
807
|
+
search: options.search
|
|
808
|
+
},
|
|
809
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
810
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
/** Get a country */
|
|
814
|
+
async getCountry(options) {
|
|
815
|
+
return this.#client._call({
|
|
816
|
+
operationId: "locations_countries_retrieve",
|
|
817
|
+
method: "GET",
|
|
818
|
+
path: "/locations/countries/{id}"
|
|
819
|
+
}, {
|
|
820
|
+
path: { id: options.id },
|
|
821
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
822
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
/** List available internet service providers */
|
|
826
|
+
async listIsps(options = {}) {
|
|
827
|
+
return this.#client._call({
|
|
828
|
+
operationId: "locations_isps_list",
|
|
829
|
+
method: "GET",
|
|
830
|
+
path: "/locations/isps"
|
|
831
|
+
}, {
|
|
832
|
+
query: {
|
|
833
|
+
code: options.code,
|
|
834
|
+
country__code: options.countryCode,
|
|
835
|
+
limit: options.limit,
|
|
836
|
+
name: options.name,
|
|
837
|
+
offset: options.offset,
|
|
838
|
+
ordering: options.ordering,
|
|
839
|
+
package_id: options.packageId,
|
|
840
|
+
search: options.search
|
|
841
|
+
},
|
|
842
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
843
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
/** List available regions */
|
|
847
|
+
async listRegions(options = {}) {
|
|
848
|
+
return this.#client._call({
|
|
849
|
+
operationId: "locations_regions_list",
|
|
850
|
+
method: "GET",
|
|
851
|
+
path: "/locations/regions"
|
|
852
|
+
}, {
|
|
853
|
+
query: {
|
|
854
|
+
code: options.code,
|
|
855
|
+
country__code: options.countryCode,
|
|
856
|
+
limit: options.limit,
|
|
857
|
+
name: options.name,
|
|
858
|
+
offset: options.offset,
|
|
859
|
+
ordering: options.ordering,
|
|
860
|
+
package_id: options.packageId,
|
|
861
|
+
search: options.search
|
|
862
|
+
},
|
|
863
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
864
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
/** Get a region */
|
|
868
|
+
async getRegion(options) {
|
|
869
|
+
return this.#client._call({
|
|
870
|
+
operationId: "locations_regions_retrieve",
|
|
871
|
+
method: "GET",
|
|
872
|
+
path: "/locations/regions/{id}"
|
|
873
|
+
}, {
|
|
874
|
+
path: { id: options.id },
|
|
875
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
876
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
};
|
|
880
|
+
var NewsResource = class {
|
|
881
|
+
#client;
|
|
882
|
+
constructor(client) {
|
|
883
|
+
this.#client = client;
|
|
884
|
+
}
|
|
885
|
+
/** List product announcements */
|
|
886
|
+
async list(options = {}) {
|
|
887
|
+
return this.#client._call({
|
|
888
|
+
operationId: "news_list",
|
|
889
|
+
method: "GET",
|
|
890
|
+
path: "/news"
|
|
891
|
+
}, {
|
|
892
|
+
query: {
|
|
893
|
+
limit: options.limit,
|
|
894
|
+
offset: options.offset,
|
|
895
|
+
ordering: options.ordering,
|
|
896
|
+
search: options.search
|
|
897
|
+
},
|
|
898
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
899
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
var OrdersResource = class {
|
|
904
|
+
#client;
|
|
905
|
+
constructor(client) {
|
|
906
|
+
this.#client = client;
|
|
907
|
+
}
|
|
908
|
+
/** List active orders */
|
|
909
|
+
async list(options = {}) {
|
|
910
|
+
return this.#client._call({
|
|
911
|
+
operationId: "orders_list",
|
|
912
|
+
method: "GET",
|
|
913
|
+
path: "/orders"
|
|
914
|
+
}, {
|
|
915
|
+
query: {
|
|
916
|
+
limit: options.limit,
|
|
917
|
+
offset: options.offset,
|
|
918
|
+
ordering: options.ordering,
|
|
919
|
+
package__alias: options.packageAlias,
|
|
920
|
+
package__id: options.packageId,
|
|
921
|
+
package__type: options.packageType,
|
|
922
|
+
search: options.search,
|
|
923
|
+
user__email: options.userEmail,
|
|
924
|
+
user__id: options.userId
|
|
925
|
+
},
|
|
926
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
927
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
/** Get an order */
|
|
931
|
+
async get(options) {
|
|
932
|
+
return this.#client._call({
|
|
933
|
+
operationId: "orders_retrieve",
|
|
934
|
+
method: "GET",
|
|
935
|
+
path: "/orders/{id}"
|
|
936
|
+
}, {
|
|
937
|
+
path: { id: options.id },
|
|
938
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
939
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
/** Update order auto-renewal */
|
|
943
|
+
async updateAutoRenewal(options) {
|
|
944
|
+
return this.#client._call({
|
|
945
|
+
operationId: "orders_partial_update",
|
|
946
|
+
method: "PATCH",
|
|
947
|
+
path: "/orders/{id}"
|
|
948
|
+
}, {
|
|
949
|
+
path: { id: options.id },
|
|
950
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
951
|
+
...options.body === void 0 ? {} : { body: options.body },
|
|
952
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
/** Delete a sub-user order */
|
|
956
|
+
async delete(options) {
|
|
957
|
+
return this.#client._call({
|
|
958
|
+
operationId: "orders_destroy",
|
|
959
|
+
method: "DELETE",
|
|
960
|
+
path: "/orders/{id}"
|
|
961
|
+
}, {
|
|
962
|
+
path: { id: options.id },
|
|
963
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
964
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
/** Reset an order's proxy password */
|
|
968
|
+
async resetPassword(options) {
|
|
969
|
+
return this.#client._call({
|
|
970
|
+
operationId: "reset_password_create",
|
|
971
|
+
method: "POST",
|
|
972
|
+
path: "/reset-password"
|
|
973
|
+
}, {
|
|
974
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
975
|
+
body: options.body,
|
|
976
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
var PackagesResource = class {
|
|
981
|
+
#client;
|
|
982
|
+
constructor(client) {
|
|
983
|
+
this.#client = client;
|
|
984
|
+
}
|
|
985
|
+
/** List available proxy packages */
|
|
986
|
+
async list(options = {}) {
|
|
987
|
+
return this.#client._call({
|
|
988
|
+
operationId: "packages_list",
|
|
989
|
+
method: "GET",
|
|
990
|
+
path: "/packages"
|
|
991
|
+
}, {
|
|
992
|
+
query: {
|
|
993
|
+
alias: options.alias,
|
|
994
|
+
limit: options.limit,
|
|
995
|
+
offset: options.offset,
|
|
996
|
+
ordering: options.ordering,
|
|
997
|
+
pricing_unit: options.pricingUnit,
|
|
998
|
+
search: options.search,
|
|
999
|
+
type: options.type
|
|
1000
|
+
},
|
|
1001
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1002
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
/** List affiliate package commissions */
|
|
1006
|
+
async listCommissions(options = {}) {
|
|
1007
|
+
return this.#client._call({
|
|
1008
|
+
operationId: "packages_commissions_list",
|
|
1009
|
+
method: "GET",
|
|
1010
|
+
path: "/packages/commissions"
|
|
1011
|
+
}, {
|
|
1012
|
+
query: {
|
|
1013
|
+
alias: options.alias,
|
|
1014
|
+
limit: options.limit,
|
|
1015
|
+
offset: options.offset,
|
|
1016
|
+
ordering: options.ordering,
|
|
1017
|
+
pricing_unit: options.pricingUnit,
|
|
1018
|
+
type: options.type
|
|
1019
|
+
},
|
|
1020
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1021
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
var ProfileResource = class {
|
|
1026
|
+
#client;
|
|
1027
|
+
constructor(client) {
|
|
1028
|
+
this.#client = client;
|
|
1029
|
+
}
|
|
1030
|
+
/** Get the current profile */
|
|
1031
|
+
async get(options = {}) {
|
|
1032
|
+
return this.#client._call({
|
|
1033
|
+
operationId: "profile_retrieve",
|
|
1034
|
+
method: "GET",
|
|
1035
|
+
path: "/profile"
|
|
1036
|
+
}, {
|
|
1037
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1038
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
/** Update the current profile */
|
|
1042
|
+
async update(options = {}) {
|
|
1043
|
+
return this.#client._call({
|
|
1044
|
+
operationId: "profile_partial_update",
|
|
1045
|
+
method: "PATCH",
|
|
1046
|
+
path: "/profile"
|
|
1047
|
+
}, {
|
|
1048
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1049
|
+
...options.body === void 0 ? {} : { body: options.body },
|
|
1050
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
/** Delete the current account */
|
|
1054
|
+
async delete(options = {}) {
|
|
1055
|
+
return this.#client._call({
|
|
1056
|
+
operationId: "profile_destroy",
|
|
1057
|
+
method: "DELETE",
|
|
1058
|
+
path: "/profile"
|
|
1059
|
+
}, {
|
|
1060
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1061
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
/** Confirm two-factor setup */
|
|
1065
|
+
async confirmTwoFactor(options) {
|
|
1066
|
+
return this.#client._call({
|
|
1067
|
+
operationId: "profile_2fa_confirm_create",
|
|
1068
|
+
method: "POST",
|
|
1069
|
+
path: "/profile/2fa/confirm"
|
|
1070
|
+
}, {
|
|
1071
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1072
|
+
body: options.body,
|
|
1073
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
/** Disable two-factor authentication */
|
|
1077
|
+
async disableTwoFactor(options) {
|
|
1078
|
+
return this.#client._call({
|
|
1079
|
+
operationId: "profile_2fa_disable_create",
|
|
1080
|
+
method: "POST",
|
|
1081
|
+
path: "/profile/2fa/disable"
|
|
1082
|
+
}, {
|
|
1083
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1084
|
+
body: options.body,
|
|
1085
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
/** Start two-factor setup */
|
|
1089
|
+
async setupTwoFactor(options = {}) {
|
|
1090
|
+
return this.#client._call({
|
|
1091
|
+
operationId: "profile_2fa_setup_create",
|
|
1092
|
+
method: "POST",
|
|
1093
|
+
path: "/profile/2fa/setup"
|
|
1094
|
+
}, {
|
|
1095
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1096
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
/** Get two-factor status */
|
|
1100
|
+
async getTwoFactorStatus(options = {}) {
|
|
1101
|
+
return this.#client._call({
|
|
1102
|
+
operationId: "profile_2fa_status_retrieve",
|
|
1103
|
+
method: "GET",
|
|
1104
|
+
path: "/profile/2fa/status"
|
|
1105
|
+
}, {
|
|
1106
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1107
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
/** Change the account password */
|
|
1111
|
+
async changePassword(options) {
|
|
1112
|
+
return this.#client._call({
|
|
1113
|
+
operationId: "profile_change_password_create",
|
|
1114
|
+
method: "POST",
|
|
1115
|
+
path: "/profile/change-password"
|
|
1116
|
+
}, {
|
|
1117
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1118
|
+
body: options.body,
|
|
1119
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
var ProxiesResource = class {
|
|
1124
|
+
#client;
|
|
1125
|
+
constructor(client) {
|
|
1126
|
+
this.#client = client;
|
|
1127
|
+
}
|
|
1128
|
+
/** Generate proxy credentials */
|
|
1129
|
+
async generate(options) {
|
|
1130
|
+
return this.#client._call({
|
|
1131
|
+
operationId: "proxies_generate_create",
|
|
1132
|
+
method: "POST",
|
|
1133
|
+
path: "/proxies/generate"
|
|
1134
|
+
}, {
|
|
1135
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1136
|
+
body: options.body,
|
|
1137
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
var RewardsResource = class {
|
|
1142
|
+
#client;
|
|
1143
|
+
constructor(client) {
|
|
1144
|
+
this.#client = client;
|
|
1145
|
+
}
|
|
1146
|
+
/** List account rewards */
|
|
1147
|
+
async list(options = {}) {
|
|
1148
|
+
return this.#client._call({
|
|
1149
|
+
operationId: "rewards_list",
|
|
1150
|
+
method: "GET",
|
|
1151
|
+
path: "/rewards"
|
|
1152
|
+
}, {
|
|
1153
|
+
query: {
|
|
1154
|
+
level: options.level,
|
|
1155
|
+
limit: options.limit,
|
|
1156
|
+
offset: options.offset,
|
|
1157
|
+
ordering: options.ordering,
|
|
1158
|
+
user__email: options.userEmail,
|
|
1159
|
+
user__id: options.userId
|
|
1160
|
+
},
|
|
1161
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1162
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
/** Claim available rewards */
|
|
1166
|
+
async claim(options) {
|
|
1167
|
+
return this.#client._call({
|
|
1168
|
+
operationId: "rewards_claim_create",
|
|
1169
|
+
method: "POST",
|
|
1170
|
+
path: "/rewards/claim"
|
|
1171
|
+
}, {
|
|
1172
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1173
|
+
body: options.body,
|
|
1174
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
};
|
|
1178
|
+
var SessionsResource = class {
|
|
1179
|
+
#client;
|
|
1180
|
+
constructor(client) {
|
|
1181
|
+
this.#client = client;
|
|
1182
|
+
}
|
|
1183
|
+
/** List active proxy sessions */
|
|
1184
|
+
async list(options = {}) {
|
|
1185
|
+
return this.#client._call({
|
|
1186
|
+
operationId: "sessions_list",
|
|
1187
|
+
method: "GET",
|
|
1188
|
+
path: "/sessions"
|
|
1189
|
+
}, {
|
|
1190
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1191
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
/** Revoke a proxy session */
|
|
1195
|
+
async delete(options) {
|
|
1196
|
+
return this.#client._call({
|
|
1197
|
+
operationId: "sessions_destroy",
|
|
1198
|
+
method: "DELETE",
|
|
1199
|
+
path: "/sessions/{id}"
|
|
1200
|
+
}, {
|
|
1201
|
+
path: { id: options.id },
|
|
1202
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1203
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1204
|
+
});
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1207
|
+
var SettingsResource = class {
|
|
1208
|
+
#client;
|
|
1209
|
+
constructor(client) {
|
|
1210
|
+
this.#client = client;
|
|
1211
|
+
}
|
|
1212
|
+
/** Get account settings */
|
|
1213
|
+
async get(options = {}) {
|
|
1214
|
+
return this.#client._call({
|
|
1215
|
+
operationId: "settings_retrieve",
|
|
1216
|
+
method: "GET",
|
|
1217
|
+
path: "/settings"
|
|
1218
|
+
}, {
|
|
1219
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1220
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
};
|
|
1224
|
+
var TelegramDashboardResource = class {
|
|
1225
|
+
#client;
|
|
1226
|
+
constructor(client) {
|
|
1227
|
+
this.#client = client;
|
|
1228
|
+
}
|
|
1229
|
+
/** Get the Telegram dashboard connection */
|
|
1230
|
+
async getConnection(options = {}) {
|
|
1231
|
+
return this.#client._call({
|
|
1232
|
+
operationId: "integrations_telegram_connection_retrieve",
|
|
1233
|
+
method: "GET",
|
|
1234
|
+
path: "/integrations/telegram/connection"
|
|
1235
|
+
}, {
|
|
1236
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1237
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
/** Update Telegram dashboard preferences */
|
|
1241
|
+
async updateConnection(options = {}) {
|
|
1242
|
+
return this.#client._call({
|
|
1243
|
+
operationId: "integrations_telegram_connection_partial_update",
|
|
1244
|
+
method: "PATCH",
|
|
1245
|
+
path: "/integrations/telegram/connection"
|
|
1246
|
+
}, {
|
|
1247
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1248
|
+
...options.body === void 0 ? {} : { body: options.body },
|
|
1249
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
/** Disconnect the Telegram dashboard */
|
|
1253
|
+
async deleteConnection(options = {}) {
|
|
1254
|
+
return this.#client._call({
|
|
1255
|
+
operationId: "integrations_telegram_connection_destroy",
|
|
1256
|
+
method: "DELETE",
|
|
1257
|
+
path: "/integrations/telegram/connection"
|
|
1258
|
+
}, {
|
|
1259
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1260
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
/** Create a Telegram account link */
|
|
1264
|
+
async createLink(options = {}) {
|
|
1265
|
+
return this.#client._call({
|
|
1266
|
+
operationId: "integrations_telegram_link_create",
|
|
1267
|
+
method: "POST",
|
|
1268
|
+
path: "/integrations/telegram/link"
|
|
1269
|
+
}, {
|
|
1270
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1271
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
};
|
|
1275
|
+
var TelegramServiceResource = class {
|
|
1276
|
+
#client;
|
|
1277
|
+
constructor(client) {
|
|
1278
|
+
this.#client = client;
|
|
1279
|
+
}
|
|
1280
|
+
/** Consume a Telegram account link */
|
|
1281
|
+
async consumeLink(options) {
|
|
1282
|
+
return this.#client._call({
|
|
1283
|
+
operationId: "integrations_telegram_link_consume_create",
|
|
1284
|
+
method: "POST",
|
|
1285
|
+
path: "/integrations/telegram/link/consume"
|
|
1286
|
+
}, {
|
|
1287
|
+
headers: {
|
|
1288
|
+
"X-ProxyRequest-Telegram-Secret": options.serviceSecret,
|
|
1289
|
+
"Accept-Language": options.acceptLanguage
|
|
1290
|
+
},
|
|
1291
|
+
body: options.body,
|
|
1292
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
/** Create a Telegram API session */
|
|
1296
|
+
async createSession(options) {
|
|
1297
|
+
return this.#client._call({
|
|
1298
|
+
operationId: "integrations_telegram_session_create",
|
|
1299
|
+
method: "POST",
|
|
1300
|
+
path: "/integrations/telegram/session"
|
|
1301
|
+
}, {
|
|
1302
|
+
headers: {
|
|
1303
|
+
"X-ProxyRequest-Telegram-Secret": options.serviceSecret,
|
|
1304
|
+
"Accept-Language": options.acceptLanguage
|
|
1305
|
+
},
|
|
1306
|
+
body: options.body,
|
|
1307
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
var UsersResource = class {
|
|
1312
|
+
#client;
|
|
1313
|
+
constructor(client) {
|
|
1314
|
+
this.#client = client;
|
|
1315
|
+
}
|
|
1316
|
+
/** List users in the current account */
|
|
1317
|
+
async list(options = {}) {
|
|
1318
|
+
return this.#client._call({
|
|
1319
|
+
operationId: "users_list",
|
|
1320
|
+
method: "GET",
|
|
1321
|
+
path: "/users"
|
|
1322
|
+
}, {
|
|
1323
|
+
query: {
|
|
1324
|
+
email: options.email,
|
|
1325
|
+
id: options.id,
|
|
1326
|
+
limit: options.limit,
|
|
1327
|
+
offset: options.offset,
|
|
1328
|
+
ordering: options.ordering,
|
|
1329
|
+
package__id: options.packageId,
|
|
1330
|
+
search: options.search,
|
|
1331
|
+
username: options.username
|
|
1332
|
+
},
|
|
1333
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1334
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
/** Create a sub-user */
|
|
1338
|
+
async create(options) {
|
|
1339
|
+
return this.#client._call({
|
|
1340
|
+
operationId: "users_create",
|
|
1341
|
+
method: "POST",
|
|
1342
|
+
path: "/users"
|
|
1343
|
+
}, {
|
|
1344
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1345
|
+
body: options.body,
|
|
1346
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
/** Get a user */
|
|
1350
|
+
async get(options) {
|
|
1351
|
+
return this.#client._call({
|
|
1352
|
+
operationId: "users_retrieve",
|
|
1353
|
+
method: "GET",
|
|
1354
|
+
path: "/users/{id}"
|
|
1355
|
+
}, {
|
|
1356
|
+
path: { id: options.id },
|
|
1357
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1358
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
/** Update a user */
|
|
1362
|
+
async update(options) {
|
|
1363
|
+
return this.#client._call({
|
|
1364
|
+
operationId: "users_partial_update",
|
|
1365
|
+
method: "PATCH",
|
|
1366
|
+
path: "/users/{id}"
|
|
1367
|
+
}, {
|
|
1368
|
+
path: { id: options.id },
|
|
1369
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1370
|
+
...options.body === void 0 ? {} : { body: options.body },
|
|
1371
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
/** Delete a user */
|
|
1375
|
+
async delete(options) {
|
|
1376
|
+
return this.#client._call({
|
|
1377
|
+
operationId: "users_destroy",
|
|
1378
|
+
method: "DELETE",
|
|
1379
|
+
path: "/users/{id}"
|
|
1380
|
+
}, {
|
|
1381
|
+
path: { id: options.id },
|
|
1382
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1383
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
/** Add data to a sub-user order */
|
|
1387
|
+
async addData(options) {
|
|
1388
|
+
return this.#client._call({
|
|
1389
|
+
operationId: "users_data_add_create",
|
|
1390
|
+
method: "POST",
|
|
1391
|
+
path: "/users/{id}/data/add"
|
|
1392
|
+
}, {
|
|
1393
|
+
path: { id: options.id },
|
|
1394
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1395
|
+
body: options.body,
|
|
1396
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
/** Subtract data from a sub-user order */
|
|
1400
|
+
async subtractData(options) {
|
|
1401
|
+
return this.#client._call({
|
|
1402
|
+
operationId: "users_data_subtract_create",
|
|
1403
|
+
method: "POST",
|
|
1404
|
+
path: "/users/{id}/data/subtract"
|
|
1405
|
+
}, {
|
|
1406
|
+
path: { id: options.id },
|
|
1407
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1408
|
+
body: options.body,
|
|
1409
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
/** List a sub-user's orders */
|
|
1413
|
+
async listOrders(options) {
|
|
1414
|
+
return this.#client._call({
|
|
1415
|
+
operationId: "users_orders_list",
|
|
1416
|
+
method: "GET",
|
|
1417
|
+
path: "/users/{id}/orders"
|
|
1418
|
+
}, {
|
|
1419
|
+
path: { id: options.idPath },
|
|
1420
|
+
query: {
|
|
1421
|
+
email: options.email,
|
|
1422
|
+
id: options.idQuery,
|
|
1423
|
+
limit: options.limit,
|
|
1424
|
+
offset: options.offset,
|
|
1425
|
+
ordering: options.ordering,
|
|
1426
|
+
username: options.username
|
|
1427
|
+
},
|
|
1428
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1429
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
/** Rotate a sub-user proxy password */
|
|
1433
|
+
async resetPassword(options) {
|
|
1434
|
+
return this.#client._call({
|
|
1435
|
+
operationId: "users_password_create",
|
|
1436
|
+
method: "POST",
|
|
1437
|
+
path: "/users/{id}/password"
|
|
1438
|
+
}, {
|
|
1439
|
+
path: { id: options.id },
|
|
1440
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1441
|
+
...options.body === void 0 ? {} : { body: options.body },
|
|
1442
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
};
|
|
1446
|
+
var WebhooksResource = class {
|
|
1447
|
+
#client;
|
|
1448
|
+
constructor(client) {
|
|
1449
|
+
this.#client = client;
|
|
1450
|
+
}
|
|
1451
|
+
/** List customer webhooks */
|
|
1452
|
+
async list(options = {}) {
|
|
1453
|
+
return this.#client._call({
|
|
1454
|
+
operationId: "webhooks_list",
|
|
1455
|
+
method: "GET",
|
|
1456
|
+
path: "/webhooks"
|
|
1457
|
+
}, {
|
|
1458
|
+
query: {
|
|
1459
|
+
limit: options.limit,
|
|
1460
|
+
offset: options.offset
|
|
1461
|
+
},
|
|
1462
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1463
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
/** Create a customer webhook */
|
|
1467
|
+
async create(options) {
|
|
1468
|
+
return this.#client._call({
|
|
1469
|
+
operationId: "webhooks_create",
|
|
1470
|
+
method: "POST",
|
|
1471
|
+
path: "/webhooks"
|
|
1472
|
+
}, {
|
|
1473
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1474
|
+
body: options.body,
|
|
1475
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
/** Get a customer webhook */
|
|
1479
|
+
async get(options) {
|
|
1480
|
+
return this.#client._call({
|
|
1481
|
+
operationId: "webhooks_retrieve",
|
|
1482
|
+
method: "GET",
|
|
1483
|
+
path: "/webhooks/{id}"
|
|
1484
|
+
}, {
|
|
1485
|
+
path: { id: options.id },
|
|
1486
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1487
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
/** Delete a customer webhook */
|
|
1491
|
+
async delete(options) {
|
|
1492
|
+
return this.#client._call({
|
|
1493
|
+
operationId: "webhooks_destroy",
|
|
1494
|
+
method: "DELETE",
|
|
1495
|
+
path: "/webhooks/{id}"
|
|
1496
|
+
}, {
|
|
1497
|
+
path: { id: options.id },
|
|
1498
|
+
headers: { "Accept-Language": options.acceptLanguage },
|
|
1499
|
+
...options.request === void 0 ? {} : { request: options.request }
|
|
1500
|
+
});
|
|
1501
|
+
}
|
|
1502
|
+
};
|
|
1503
|
+
function createResourceCollection(client) {
|
|
1504
|
+
return {
|
|
1505
|
+
apiKeys: new APIKeysResource(client),
|
|
1506
|
+
affiliates: new AffiliatesResource(client),
|
|
1507
|
+
analytics: new AnalyticsResource(client),
|
|
1508
|
+
authorization: new AuthorizationResource(client),
|
|
1509
|
+
coupons: new CouponsResource(client),
|
|
1510
|
+
invoices: new InvoicesResource(client),
|
|
1511
|
+
locations: new LocationsResource(client),
|
|
1512
|
+
news: new NewsResource(client),
|
|
1513
|
+
orders: new OrdersResource(client),
|
|
1514
|
+
packages: new PackagesResource(client),
|
|
1515
|
+
profile: new ProfileResource(client),
|
|
1516
|
+
proxies: new ProxiesResource(client),
|
|
1517
|
+
rewards: new RewardsResource(client),
|
|
1518
|
+
sessions: new SessionsResource(client),
|
|
1519
|
+
settings: new SettingsResource(client),
|
|
1520
|
+
telegram: new TelegramDashboardResource(client),
|
|
1521
|
+
telegramService: new TelegramServiceResource(client),
|
|
1522
|
+
users: new UsersResource(client),
|
|
1523
|
+
webhooks: new WebhooksResource(client)
|
|
1524
|
+
};
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
//#endregion
|
|
1528
|
+
//#region src/pagination.ts
|
|
1529
|
+
async function* paginate(pageFetcher, options = {}) {
|
|
1530
|
+
const limit = options.limit ?? 100;
|
|
1531
|
+
let offset = options.offset ?? 0;
|
|
1532
|
+
const maxPages = options.maxPages ?? 1e4;
|
|
1533
|
+
if (limit <= 0 || offset < 0 || maxPages <= 0) throw new RangeError("limit and maxPages must be positive; offset must not be negative.");
|
|
1534
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1535
|
+
for (let pageNumber = 0; pageNumber < maxPages; pageNumber += 1) {
|
|
1536
|
+
const page = await pageFetcher({
|
|
1537
|
+
limit,
|
|
1538
|
+
offset
|
|
1539
|
+
});
|
|
1540
|
+
if (!Array.isArray(page.results)) throw new PaginationError("A page object must expose an array in results.");
|
|
1541
|
+
yield* page.results;
|
|
1542
|
+
if (page.next === null || page.next === void 0) return;
|
|
1543
|
+
if (visited.has(page.next)) throw new PaginationError("Pagination stopped because the API returned a repeated next URL.");
|
|
1544
|
+
visited.add(page.next);
|
|
1545
|
+
const nextOffset = offsetFromUrl(page.next);
|
|
1546
|
+
offset = nextOffset ?? offset + page.results.length;
|
|
1547
|
+
if (page.results.length === 0 && nextOffset === void 0) throw new PaginationError("Pagination cannot advance from an empty page.");
|
|
1548
|
+
}
|
|
1549
|
+
throw new PaginationError("Pagination stopped after the configured maximum number of pages.");
|
|
1550
|
+
}
|
|
1551
|
+
function offsetFromUrl(url) {
|
|
1552
|
+
try {
|
|
1553
|
+
const value = new URL(url, "https://api.proxyrequest.com").searchParams.get("offset");
|
|
1554
|
+
if (value === null) return void 0;
|
|
1555
|
+
const offset = Number(value);
|
|
1556
|
+
return Number.isInteger(offset) && offset >= 0 ? offset : void 0;
|
|
1557
|
+
} catch {
|
|
1558
|
+
return;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
//#endregion
|
|
1563
|
+
//#region src/client.ts
|
|
1564
|
+
const DEFAULT_BASE_URL = "https://api.proxyrequest.com/api/v1";
|
|
1565
|
+
const SDK_VERSION = "1.0.0";
|
|
1566
|
+
var ProxyRequestClient = class ProxyRequestClient {
|
|
1567
|
+
apiKeys;
|
|
1568
|
+
affiliates;
|
|
1569
|
+
analytics;
|
|
1570
|
+
authorization;
|
|
1571
|
+
coupons;
|
|
1572
|
+
invoices;
|
|
1573
|
+
locations;
|
|
1574
|
+
news;
|
|
1575
|
+
orders;
|
|
1576
|
+
packages;
|
|
1577
|
+
profile;
|
|
1578
|
+
proxies;
|
|
1579
|
+
rewards;
|
|
1580
|
+
sessions;
|
|
1581
|
+
settings;
|
|
1582
|
+
telegram;
|
|
1583
|
+
telegramService;
|
|
1584
|
+
users;
|
|
1585
|
+
webhooks;
|
|
1586
|
+
baseUrl;
|
|
1587
|
+
language;
|
|
1588
|
+
timeoutMs;
|
|
1589
|
+
#fetch;
|
|
1590
|
+
#headers;
|
|
1591
|
+
#openapi;
|
|
1592
|
+
constructor(options = {}) {
|
|
1593
|
+
this.baseUrl = normalizeBaseUrl(options.baseUrl ?? "https://api.proxyrequest.com/api/v1");
|
|
1594
|
+
this.language = options.language ?? "en";
|
|
1595
|
+
this.timeoutMs = options.timeoutMs ?? 15e3;
|
|
1596
|
+
if (!Number.isFinite(this.timeoutMs) || this.timeoutMs < 0) throw new RangeError("timeoutMs must be a non-negative finite number.");
|
|
1597
|
+
this.#fetch = options.fetch ?? globalThis.fetch;
|
|
1598
|
+
if (typeof this.#fetch !== "function") throw new TypeError("A Fetch API implementation is required.");
|
|
1599
|
+
this.#headers = new Headers(options.headers);
|
|
1600
|
+
this.#headers.set("Accept-Language", this.language);
|
|
1601
|
+
if (options.apiKey !== void 0) this.#headers.set("Authorization", `Static ${options.apiKey}`);
|
|
1602
|
+
if (options.bearerToken !== void 0) this.#headers.set("Authorization", `Bearer ${options.bearerToken}`);
|
|
1603
|
+
this.#openapi = createClient({
|
|
1604
|
+
baseUrl: this.baseUrl,
|
|
1605
|
+
fetch: this.#fetch,
|
|
1606
|
+
headers: this.#headers
|
|
1607
|
+
});
|
|
1608
|
+
this.#openapi.use({
|
|
1609
|
+
async onResponse({ response }) {
|
|
1610
|
+
if (!response.ok) throw await ApiError.fromResponse(response);
|
|
1611
|
+
},
|
|
1612
|
+
onError({ error }) {
|
|
1613
|
+
return error instanceof ApiError ? error : ApiError.network(error);
|
|
1614
|
+
}
|
|
1615
|
+
});
|
|
1616
|
+
const resources = createResourceCollection(this);
|
|
1617
|
+
this.apiKeys = resources.apiKeys;
|
|
1618
|
+
this.affiliates = resources.affiliates;
|
|
1619
|
+
this.analytics = resources.analytics;
|
|
1620
|
+
this.authorization = resources.authorization;
|
|
1621
|
+
this.coupons = resources.coupons;
|
|
1622
|
+
this.invoices = resources.invoices;
|
|
1623
|
+
this.locations = resources.locations;
|
|
1624
|
+
this.news = resources.news;
|
|
1625
|
+
this.orders = resources.orders;
|
|
1626
|
+
this.packages = resources.packages;
|
|
1627
|
+
this.profile = resources.profile;
|
|
1628
|
+
this.proxies = resources.proxies;
|
|
1629
|
+
this.rewards = resources.rewards;
|
|
1630
|
+
this.sessions = resources.sessions;
|
|
1631
|
+
this.settings = resources.settings;
|
|
1632
|
+
this.telegram = resources.telegram;
|
|
1633
|
+
this.telegramService = resources.telegramService;
|
|
1634
|
+
this.users = resources.users;
|
|
1635
|
+
this.webhooks = resources.webhooks;
|
|
1636
|
+
}
|
|
1637
|
+
static withApiKey(apiKey, options = {}) {
|
|
1638
|
+
return new ProxyRequestClient({
|
|
1639
|
+
...options,
|
|
1640
|
+
apiKey
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1643
|
+
static withBearerToken(bearerToken, options = {}) {
|
|
1644
|
+
return new ProxyRequestClient({
|
|
1645
|
+
...options,
|
|
1646
|
+
bearerToken
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
static anonymous(options = {}) {
|
|
1650
|
+
return new ProxyRequestClient(options);
|
|
1651
|
+
}
|
|
1652
|
+
async _call(spec, data = {}) {
|
|
1653
|
+
const controls = data.request ?? {};
|
|
1654
|
+
const timeout = requestSignal(controls.signal, controls.timeoutMs ?? this.timeoutMs);
|
|
1655
|
+
const options = {
|
|
1656
|
+
params: {
|
|
1657
|
+
...data.path === void 0 ? {} : { path: data.path },
|
|
1658
|
+
...data.query === void 0 ? {} : { query: data.query },
|
|
1659
|
+
...data.headers === void 0 ? {} : { header: data.headers }
|
|
1660
|
+
},
|
|
1661
|
+
...data.body === void 0 ? {} : { body: data.body },
|
|
1662
|
+
...controls.headers === void 0 ? {} : { headers: controls.headers },
|
|
1663
|
+
signal: timeout.signal,
|
|
1664
|
+
...spec.binary ? { parseAs: "arrayBuffer" } : {}
|
|
1665
|
+
};
|
|
1666
|
+
try {
|
|
1667
|
+
const method = this.#openapi[spec.method];
|
|
1668
|
+
const result = await method(spec.path, options);
|
|
1669
|
+
if (result.error !== void 0) throw ApiError.unexpected(`ProxyRequest returned an undocumented error for ${spec.operationId}.`, result.error);
|
|
1670
|
+
if (spec.binary) {
|
|
1671
|
+
if (!(result.data instanceof ArrayBuffer)) throw ApiError.unexpected(`ProxyRequest returned an invalid file for ${spec.operationId}.`);
|
|
1672
|
+
return FileDownload.fromResponse(result.data, result.response.headers);
|
|
1673
|
+
}
|
|
1674
|
+
return result.data;
|
|
1675
|
+
} catch (error) {
|
|
1676
|
+
if (error instanceof ApiError) throw error;
|
|
1677
|
+
throw ApiError.unexpected(`Unable to process the ProxyRequest response for ${spec.operationId}.`, error);
|
|
1678
|
+
} finally {
|
|
1679
|
+
timeout.cleanup();
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
async request(method, path, options = {}) {
|
|
1683
|
+
const url = new URL(path.replace(/^\//u, ""), `${this.baseUrl}/`);
|
|
1684
|
+
appendQuery(url.searchParams, options.query);
|
|
1685
|
+
const headers = new Headers(this.#headers);
|
|
1686
|
+
new Headers(options.headers).forEach((value, key) => {
|
|
1687
|
+
headers.set(key, value);
|
|
1688
|
+
});
|
|
1689
|
+
let body;
|
|
1690
|
+
if (options.body !== void 0) {
|
|
1691
|
+
if (isBodyInit(options.body)) body = options.body;
|
|
1692
|
+
else {
|
|
1693
|
+
headers.set("Content-Type", "application/json");
|
|
1694
|
+
body = JSON.stringify(options.body);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
const timeout = requestSignal(options.signal, options.timeoutMs ?? this.timeoutMs);
|
|
1698
|
+
try {
|
|
1699
|
+
const response = await this.#fetch(url, {
|
|
1700
|
+
method: method.toUpperCase(),
|
|
1701
|
+
headers,
|
|
1702
|
+
...body === void 0 ? {} : { body },
|
|
1703
|
+
signal: timeout.signal
|
|
1704
|
+
});
|
|
1705
|
+
if (!response.ok) throw await ApiError.fromResponse(response);
|
|
1706
|
+
return response;
|
|
1707
|
+
} catch (error) {
|
|
1708
|
+
if (error instanceof ApiError) throw error;
|
|
1709
|
+
throw ApiError.network(error);
|
|
1710
|
+
} finally {
|
|
1711
|
+
timeout.cleanup();
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
paginate(pageFetcher, options = {}) {
|
|
1715
|
+
return paginate(pageFetcher, options);
|
|
1716
|
+
}
|
|
1717
|
+
downloadInvoicePdf(id, request) {
|
|
1718
|
+
return this.invoices.downloadPdf({
|
|
1719
|
+
id,
|
|
1720
|
+
...request === void 0 ? {} : { request }
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1723
|
+
};
|
|
1724
|
+
function normalizeBaseUrl(value) {
|
|
1725
|
+
const url = new URL(value);
|
|
1726
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") throw new TypeError("baseUrl must use http or https.");
|
|
1727
|
+
return url.toString().replace(/\/$/u, "");
|
|
1728
|
+
}
|
|
1729
|
+
function requestSignal(input, timeoutMs) {
|
|
1730
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs < 0) throw new RangeError("timeoutMs must be a non-negative finite number.");
|
|
1731
|
+
const controller = new AbortController();
|
|
1732
|
+
const abortFromInput = () => controller.abort(input?.reason);
|
|
1733
|
+
if (input?.aborted) abortFromInput();
|
|
1734
|
+
else input?.addEventListener("abort", abortFromInput, { once: true });
|
|
1735
|
+
const timer = timeoutMs === 0 ? void 0 : setTimeout(() => controller.abort(new DOMException("Request timed out.", "TimeoutError")), timeoutMs);
|
|
1736
|
+
return {
|
|
1737
|
+
signal: controller.signal,
|
|
1738
|
+
cleanup: () => {
|
|
1739
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
1740
|
+
input?.removeEventListener("abort", abortFromInput);
|
|
1741
|
+
}
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
function appendQuery(search, query) {
|
|
1745
|
+
if (query === void 0) return;
|
|
1746
|
+
for (const [key, value] of Object.entries(query)) {
|
|
1747
|
+
if (value === void 0 || value === null) continue;
|
|
1748
|
+
if (Array.isArray(value)) for (const item of value) search.append(key, String(item));
|
|
1749
|
+
else search.set(key, String(value));
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
function isBodyInit(value) {
|
|
1753
|
+
return typeof value === "string" || value instanceof Blob || value instanceof ArrayBuffer || ArrayBuffer.isView(value) || value instanceof FormData || value instanceof URLSearchParams || value instanceof ReadableStream;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
//#endregion
|
|
1757
|
+
//#region src/webhooks.ts
|
|
1758
|
+
const encoder = new TextEncoder();
|
|
1759
|
+
var WebhookVerifier = class WebhookVerifier {
|
|
1760
|
+
static async verify(rawBody, signature, secret, options = {}) {
|
|
1761
|
+
const tolerance = options.tolerance === void 0 ? 300 : options.tolerance;
|
|
1762
|
+
if (!signature || !secret || tolerance !== null && tolerance < 0) return false;
|
|
1763
|
+
const parsed = parseSignature(signature);
|
|
1764
|
+
if (parsed === void 0) return false;
|
|
1765
|
+
if (options.timestampHeader !== void 0) {
|
|
1766
|
+
const timestampHeader = options.timestampHeader.trim();
|
|
1767
|
+
if (!/^\d+$/u.test(timestampHeader) || Number(timestampHeader) !== parsed.timestamp) return false;
|
|
1768
|
+
}
|
|
1769
|
+
const now = options.now ?? Math.floor(Date.now() / 1e3);
|
|
1770
|
+
if (tolerance !== null && Math.abs(now - parsed.timestamp) > tolerance) return false;
|
|
1771
|
+
const body = bodyBytes(rawBody);
|
|
1772
|
+
const payload = concatBytes(encoder.encode(`${parsed.timestamp}.`), body);
|
|
1773
|
+
try {
|
|
1774
|
+
const key = await globalThis.crypto.subtle.importKey("raw", encoder.encode(secret), {
|
|
1775
|
+
name: "HMAC",
|
|
1776
|
+
hash: "SHA-256"
|
|
1777
|
+
}, false, ["sign"]);
|
|
1778
|
+
const expected = new Uint8Array(await globalThis.crypto.subtle.sign("HMAC", key, payload.slice().buffer));
|
|
1779
|
+
return parsed.signatures.some((candidate) => constantTimeHexEqual(expected, candidate));
|
|
1780
|
+
} catch {
|
|
1781
|
+
return false;
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
static async verifyOrThrow(rawBody, signature, secret, options = {}) {
|
|
1785
|
+
if (!await WebhookVerifier.verify(rawBody, signature, secret, options)) throw new InvalidSignatureError("The ProxyRequest webhook signature is invalid or expired.");
|
|
1786
|
+
}
|
|
1787
|
+
static async decodeVerifiedJson(rawBody, signature, secret, options = {}) {
|
|
1788
|
+
await WebhookVerifier.verifyOrThrow(rawBody, signature, secret, options);
|
|
1789
|
+
const text = typeof rawBody === "string" ? rawBody : new TextDecoder().decode(bodyBytes(rawBody));
|
|
1790
|
+
try {
|
|
1791
|
+
const payload = JSON.parse(text);
|
|
1792
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) throw new TypeError("The verified webhook payload must be a JSON object.");
|
|
1793
|
+
return payload;
|
|
1794
|
+
} catch (error) {
|
|
1795
|
+
if (error instanceof TypeError) throw error;
|
|
1796
|
+
throw new TypeError("The verified webhook body is not valid JSON.", { cause: error });
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
};
|
|
1800
|
+
function parseSignature(signature) {
|
|
1801
|
+
let timestamp;
|
|
1802
|
+
const signatures = [];
|
|
1803
|
+
for (const part of signature.split(",")) {
|
|
1804
|
+
const [key, value] = part.trim().split("=", 2);
|
|
1805
|
+
if (key === "t" && value !== void 0 && /^\d+$/u.test(value)) timestamp = Number(value);
|
|
1806
|
+
if (key === "v1" && value !== void 0 && /^[a-f\d]{64}$/iu.test(value)) signatures.push(value.toLowerCase());
|
|
1807
|
+
}
|
|
1808
|
+
if (timestamp === void 0 || !Number.isSafeInteger(timestamp) || signatures.length === 0) return;
|
|
1809
|
+
return {
|
|
1810
|
+
timestamp,
|
|
1811
|
+
signatures
|
|
1812
|
+
};
|
|
1813
|
+
}
|
|
1814
|
+
function bodyBytes(value) {
|
|
1815
|
+
if (typeof value === "string") return encoder.encode(value);
|
|
1816
|
+
return value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
1817
|
+
}
|
|
1818
|
+
function concatBytes(left, right) {
|
|
1819
|
+
const result = new Uint8Array(left.byteLength + right.byteLength);
|
|
1820
|
+
result.set(left, 0);
|
|
1821
|
+
result.set(right, left.byteLength);
|
|
1822
|
+
return result;
|
|
1823
|
+
}
|
|
1824
|
+
function constantTimeHexEqual(expected, candidate) {
|
|
1825
|
+
if (!/^[a-f\d]+$/iu.test(candidate) || candidate.length !== expected.byteLength * 2) return false;
|
|
1826
|
+
let difference = 0;
|
|
1827
|
+
for (let index = 0; index < expected.byteLength; index += 1) {
|
|
1828
|
+
const byte = Number.parseInt(candidate.slice(index * 2, index * 2 + 2), 16);
|
|
1829
|
+
difference |= (expected[index] ?? 0) ^ byte;
|
|
1830
|
+
}
|
|
1831
|
+
return difference === 0;
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
//#endregion
|
|
1835
|
+
export { APIKeysResource, AffiliatesResource, AnalyticsResource, ApiError, AuthorizationResource, ProxyRequestClient as Client, ProxyRequestClient, CouponsResource, DEFAULT_BASE_URL, FileDownload, InvalidSignatureError, InvoicesResource, LocationsResource, NewsResource, OrdersResource, PackagesResource, PaginationError, ProfileResource, ProxiesResource, ProxyRequestError, RewardsResource, SDK_VERSION, SessionsResource, SettingsResource, TelegramDashboardResource, TelegramServiceResource, UsersResource, WebhookVerifier, WebhooksResource, createResourceCollection, paginate };
|
|
1836
|
+
//# sourceMappingURL=index.js.map
|