0
Get account saved filters
One script reply has been approved by the moderators Verified

List all the account saved filters

Created by hugo697 2 days ago Viewed 0 times
0
Submitted by hugo697 Bun
Verified 2 days ago
1
//native
2
type Botify = {
3
	token: string
4
}
5
/**
6
 * Get account saved filters
7
 * List all the account saved filters
8
 */
9
export async function main(
10
	auth: Botify,
11
	username: string,
12
	project_slug: string,
13
	page: string | undefined,
14
	size: string | undefined,
15
	search: string | undefined,
16
	disable_project: string | undefined
17
) {
18
	const url = new URL(`https://api.botify.com/projects/${username}/${project_slug}/account_filters`)
19
	for (const [k, v] of [
20
		['page', page],
21
		['size', size],
22
		['search', search],
23
		['disable_project', disable_project]
24
	]) {
25
		if (v !== undefined && v !== '' && k !== undefined) {
26
			url.searchParams.append(k, v)
27
		}
28
	}
29
	const response = await fetch(url, {
30
		method: 'GET',
31
		headers: {
32
			Authorization: 'Token ' + auth.token
33
		},
34
		body: undefined
35
	})
36
	if (!response.ok) {
37
		const text = await response.text()
38
		throw new Error(`${response.status} ${text}`)
39
	}
40
	return await response.text()
41
}
42