export type GetApiAppsec70AppleCertificatesIdP12Args = {id: number, password?: string | undefined}; export type GetApiAppsec70AppleCertificatesIdP12Options = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download the certificate as a PKCS#12 (.p12) * * GET /appsec/7.0/apple/certificates/{id}/p12 */ export const getApiAppsec70AppleCertificatesIdP12 = async (args: GetApiAppsec70AppleCertificatesIdP12Args, options?: GetApiAppsec70AppleCertificatesIdP12Options) => { const {baseUrl = "https://cloud.codenameone.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/x-pkcs12") if (args.password != null) query.append("password", String(args.password)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/appsec/7.0/apple/certificates/${encodeURIComponent(String(args.id))}/p12${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() };