export type GetApiApiResourcePkcs12ResourceIdDownloadArgs = {resourceId: string, 'If-None-Match'?: string | undefined}; export type GetApiApiResourcePkcs12ResourceIdDownloadOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download PKCS_12 Resource (downloadPkcs12ResourceIfChanged) * * GET /api/resource/pkcs12/{resourceId}/download */ export const getApiApiResourcePkcs12ResourceIdDownload = async (args: GetApiApiResourcePkcs12ResourceIdDownloadArgs, options?: GetApiApiResourcePkcs12ResourceIdDownloadOptions) => { const {baseUrl = "https://demo.thingsboard.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/x-pkcs12") if (args['If-None-Match'] != null) headers.set("If-None-Match", String(args['If-None-Match'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/resource/pkcs12/${encodeURIComponent(String(args.resourceId))}/download${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() };