export type CreateApiCustomsImportsDeclarationsArgs = {'Content-Type': 'application/xml; charset=UTF-8', Accept: 'application/vnd.hmrc.1.0+xml', Authorization: 'Bearer bb7fed3fe10dd235a2ccda3d50fb', body: BodyInit}; export type CreateApiCustomsImportsDeclarationsOptions = {baseUrl?: string | undefined, UserRestricted?: string | undefined, fetch?: typeof fetch | undefined}; /** * Submit a new entry summary declaration (ENS) * * POST /customs/imports/declarations/ */ export const createApiCustomsImportsDeclarations = async (args: CreateApiCustomsImportsDeclarationsArgs, options?: CreateApiCustomsImportsDeclarationsOptions) => { const {baseUrl = "https://test-api.service.hmrc.gov.uk", fetch: fetchFn = fetch, UserRestricted} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/xml") headers.set('accept', "application/xml") if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (args.Accept != null) headers.set("Accept", String(args.Accept)) if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (UserRestricted !== undefined) headers.set('authorization', `Bearer ${UserRestricted}`) const url = `${baseUrl.replace(/\/+$/, '')}/customs/imports/declarations/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };