//native
type Botify = {
token: string
}
/**
* Get urls datasets
* Gets Analysis Datasets
*/
export async function main(
auth: Botify,
username: string,
project_slug: string,
analysis_slug: string,
area: string | undefined,
previous_crawl: string | undefined,
deprecated_fields: string | undefined,
sequenced: string | undefined
) {
const url = new URL(
`https://api.botify.com/analyses/${username}/${project_slug}/${analysis_slug}/urls/datasets`
)
for (const [k, v] of [
['area', area],
['previous_crawl', previous_crawl],
['deprecated_fields', deprecated_fields],
['sequenced', sequenced]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'Token ' + auth.token
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.text()
}
Submitted by hugo697 18 days ago