export type GetApiV1SettingsFacilityFacilityCodeArgs = {facilityCode: string}; export type GetApiV1SettingsFacilityFacilityCodeOptions = {baseUrl: string, https?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Get one key / value pair from the settings table * * GET /v1/settings/facility/{facilityCode} */ export const getApiV1SettingsFacilityFacilityCode = async (args: GetApiV1SettingsFacilityFacilityCodeArgs, options: GetApiV1SettingsFacilityFacilityCodeOptions) => { const {baseUrl, fetch: fetchFn = fetch, https} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (https !== undefined) headers.set('authorization', `Basic ${btoa(`${https.username}:${https.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/settings/facility/${encodeURIComponent(String(args.facilityCode))}${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 };