export type DeleteApiOrganisationsPillarTwoSetupOrganisationArgs = {Authorization: string, 'X-Pillar2-Id': string, Accept?: string | undefined}; export type DeleteApiOrganisationsPillarTwoSetupOrganisationOptions = {baseUrl?: string | undefined, userRestricted?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete Test Organisation * * DELETE /organisations/pillar-two/setup/organisation */ export const deleteApiOrganisationsPillarTwoSetupOrganisation = async (args: DeleteApiOrganisationsPillarTwoSetupOrganisationArgs, options?: DeleteApiOrganisationsPillarTwoSetupOrganisationOptions) => { const {baseUrl = "https://test-api.service.hmrc.gov.uk", fetch: fetchFn = fetch, userRestricted} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args['X-Pillar2-Id'] != null) headers.set("X-Pillar2-Id", String(args['X-Pillar2-Id'])) if (args.Accept != null) headers.set("Accept", String(args.Accept)) if (userRestricted !== undefined) headers.set('authorization', `Bearer ${userRestricted}`) const url = `${baseUrl.replace(/\/+$/, '')}/organisations/pillar-two/setup/organisation${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };