export type GetApiHelloApplicationArgs = {Accept: 'application/vnd.hmrc.1.0+json' | 'application/vnd.hmrc.1.0+xml'}; export type GetApiHelloApplicationOptions = {baseUrl?: string | undefined, applicationRestricted?: string | undefined, fetch?: typeof fetch | undefined}; /** * Say hello application * * GET /hello/application */ export const getApiHelloApplication = async (args: GetApiHelloApplicationArgs, options?: GetApiHelloApplicationOptions) => { const {baseUrl = "https://test-api.service.hmrc.gov.uk", fetch: fetchFn = fetch, applicationRestricted} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.Accept != null) headers.set("Accept", String(args.Accept)) if (applicationRestricted !== undefined) headers.set('authorization', `Bearer ${applicationRestricted}`) const url = `${baseUrl.replace(/\/+$/, '')}/hello/application${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 };