//native
type Phrase = {
token: string
baseUrl: string
}
/**
* Get a single job template locale
* Get a single job template locale for a given job template.
*/
export async function main(
auth: Phrase,
project_id: string,
job_template_id: string,
job_template_locale_id: string,
branch: string | undefined
) {
const url = new URL(
`${auth.baseUrl}/projects/${project_id}/job_templates/${job_template_id}/locales/${job_template_locale_id}`
)
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.json()
}
Submitted by hugo697 235 days ago