export type IssuingTransactionId = string; export type PresentmentRequest = {amount?: number | undefined}; export type CreateApiIssuingSimulateAuthorizationsIdPresentmentsArgs = {id: IssuingTransactionId, body: PresentmentRequest}; export type CreateApiIssuingSimulateAuthorizationsIdPresentmentsOptions = {baseUrl: string, OAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Simulate clearing * * POST /issuing/simulate/authorizations/{id}/presentments */ export const createApiIssuingSimulateAuthorizationsIdPresentments = async (args: CreateApiIssuingSimulateAuthorizationsIdPresentmentsArgs, options: CreateApiIssuingSimulateAuthorizationsIdPresentmentsOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (OAuth !== undefined) headers.set('authorization', `Bearer ${OAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/issuing/simulate/authorizations/${encodeURIComponent(String(args.id))}/presentments${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };