export type GetApiDevicesRegistrationKeySnapArgs = {registrationKey: string, base64?: boolean | undefined}; export type GetApiDevicesRegistrationKeySnapOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, ApiKeyInHeader?: string | undefined, ApiKeyInQuery?: string | undefined, fetch?: typeof fetch | undefined}; /** * Gets current snapshot of the device screen. Image is returned as a JPEG image. * * GET /devices/{registrationKey}/snap */ export const getApiDevicesRegistrationKeySnap = async (args: GetApiDevicesRegistrationKeySnapArgs, options?: GetApiDevicesRegistrationKeySnapOptions) => { const {baseUrl = "https://api.reveldigital.com", fetch: fetchFn = fetch, Bearer, ApiKeyInHeader, ApiKeyInQuery} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.base64 != null) query.append("base64", String(args.base64)) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) if (ApiKeyInHeader !== undefined) headers.set("X-RevelDigital-ApiKey", ApiKeyInHeader) if (ApiKeyInQuery !== undefined) query.set("api_key", ApiKeyInQuery) const url = `${baseUrl.replace(/\/+$/, '')}/devices/${encodeURIComponent(String(args.registrationKey))}/snap${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 };