//native
type Phrase = {
token: string
baseUrl: string
}
/**
* Remove keys from job
* Remove multiple keys from existing job.
*/
export async function main(
auth: Phrase,
project_id: string,
id: string,
branch: string | undefined,
translation_key_ids: string | undefined
) {
const url = new URL(`${auth.baseUrl}/projects/${project_id}/jobs/${id}/keys`)
for (const [k, v] of [
['branch', branch],
['translation_key_ids', translation_key_ids]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'DELETE',
headers: {
Authorization: 'ApiToken ' + 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 235 days ago