export type CreateApiStatementRetrievalArgs = {client_id: string, 'Content-Type': string, body: BodyInit}; export type CreateApiStatementRetrievalOptions = {baseUrl?: string | undefined, clientCredentials?: string | undefined, fetch?: typeof fetch | undefined}; /** * Statement Retrieval Request * * POST /statement/retrieval */ export const createApiStatementRetrieval = async (args: CreateApiStatementRetrievalArgs, options?: CreateApiStatementRetrievalOptions) => { const {baseUrl = "https://tts.sandbox.apib2b.citi.com/citiconnect/sb/accountstatementservices/v1", fetch: fetchFn = fetch, clientCredentials} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/xml") headers.set('accept', "application/xml") if (args.client_id != null) query.append("client_id", String(args.client_id)) if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (clientCredentials !== undefined) headers.set('authorization', `Bearer ${clientCredentials}`) const url = `${baseUrl.replace(/\/+$/, '')}/statement/retrieval${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() };