export type GetApiRestApiV1PeoplePersonIdPhotoArgs = {person_id: string, ds?: string | undefined}; export type GetApiRestApiV1PeoplePersonIdPhotoOptions = {baseUrl?: string | undefined, APIToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get person photo * * GET /rest/api/v1/people/{person_id}/photo */ export const getApiRestApiV1PeoplePersonIdPhoto = async (args: GetApiRestApiV1PeoplePersonIdPhotoArgs, options?: GetApiRestApiV1PeoplePersonIdPhotoOptions) => { const {baseUrl = "https://instance-name-be.glean.com", fetch: fetchFn = fetch, APIToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (args.ds != null) query.append("ds", String(args.ds)) if (APIToken !== undefined) headers.set('authorization', `Bearer ${APIToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/rest/api/v1/people/${encodeURIComponent(String(args.person_id))}/photo${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 res.blob() };