2024-07-27 18:53:07 +02:00
|
|
|
import {Event, EventAction, request, Watchlist} from "./index";
|
2024-07-25 02:09:49 +02:00
|
|
|
|
|
|
|
|
export async function getWatchlists() {
|
2024-07-27 18:53:07 +02:00
|
|
|
const response = await request({
|
2024-07-25 02:09:49 +02:00
|
|
|
url: 'watchlists'
|
|
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getWatchlist(token: string) {
|
|
|
|
|
const response = await request<Watchlist>({
|
|
|
|
|
url: 'watchlists/' + token
|
|
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-27 18:53:07 +02:00
|
|
|
export async function postWatchlist(domains: string[], triggers: { action: string, event: EventAction }[]) {
|
2024-07-25 02:09:49 +02:00
|
|
|
const response = await request<{ token: string }>({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: 'watchlists',
|
|
|
|
|
data: {
|
|
|
|
|
domains,
|
|
|
|
|
triggers
|
|
|
|
|
},
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": 'application/json'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function deleteWatchlist(token: string): Promise<void> {
|
|
|
|
|
await request({
|
|
|
|
|
method: 'DELETE',
|
|
|
|
|
url: 'watchlists/' + token
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function patchWatchlist(domains: string[], triggers: Event[]) {
|
|
|
|
|
const response = await request<Watchlist>({
|
|
|
|
|
method: 'PATCH',
|
|
|
|
|
url: 'watchlists',
|
|
|
|
|
data: {
|
|
|
|
|
domains,
|
|
|
|
|
triggers
|
|
|
|
|
},
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": 'application/merge-patch+json'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|