export type GetApiApiV0ReleasesLatestArgs = {'Memfault-Project-Key': string}; export type GetApiApiV0ReleasesLatestOptions = {baseUrl?: string | undefined, httpBasic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve Latest Release for a Device * * GET /api/v0/releases/latest * * Also accepts auth: httpBearer */ export const getApiApiV0ReleasesLatest = async (args: GetApiApiV0ReleasesLatestArgs, options?: GetApiApiV0ReleasesLatestOptions) => { const {baseUrl = "https://api.memfault.com", fetch: fetchFn = fetch, httpBasic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['Memfault-Project-Key'] != null) headers.set("Memfault-Project-Key", String(args['Memfault-Project-Key'])) if (httpBasic !== undefined) headers.set('authorization', `Basic ${btoa(`${httpBasic.username}:${httpBasic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v0/releases/latest${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };