export type GetApiAppsByPackageArgs = {'X-API-Key': string, appPackage: string}; export type GetApiAppsByPackageOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get App Metadata by Package Name * * GET /apps/by-package */ export const getApiAppsByPackage = async (args: GetApiAppsByPackageArgs, options?: GetApiAppsByPackageOptions) => { const {baseUrl = "https://api.notiflow.empushy.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['X-API-Key'] != null) headers.set("X-API-Key", String(args['X-API-Key'])) if (args.appPackage != null) query.append("appPackage", String(args.appPackage)) const url = `${baseUrl.replace(/\/+$/, '')}/apps/by-package${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 (await res.json()) as unknown };