//native
type Phrase = {
token: string
baseUrl: string
}
/**
* Check if comment is read
* Check if comment was marked as read. Returns 204 if read, 404 if unread.
*/
export async function main(
auth: Phrase,
project_id: string,
key_id: string,
id: string,
branch: string | undefined
) {
const url = new URL(`${auth.baseUrl}/projects/${project_id}/keys/${key_id}/comments/${id}/read`)
for (const [k, v] of [['branch', branch]]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
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