export type CreateApiPackagesInstalledNameArgs = {name: string, assemblyGuid?: (string | null) | undefined, version?: (string | null) | undefined, repositoryUrl?: (string | null) | undefined}; export type CreateApiPackagesInstalledNameOptions = {baseUrl?: string | undefined, CustomAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Installs a package. * * POST /Packages/Installed/{name} */ export const createApiPackagesInstalledName = async (args: CreateApiPackagesInstalledNameArgs, options?: CreateApiPackagesInstalledNameOptions) => { const {baseUrl = "http://localhost", fetch: fetchFn = fetch, CustomAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.assemblyGuid != null) query.append("assemblyGuid", String(args.assemblyGuid)) if (args.version != null) query.append("version", String(args.version)) if (args.repositoryUrl != null) query.append("repositoryUrl", String(args.repositoryUrl)) if (CustomAuthentication !== undefined) headers.set("X-Emby-Authorization", CustomAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/Packages/Installed/${encodeURIComponent(String(args.name))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };