export type MessagePayload = {attributes?: {[key: string]: string} | undefined, data: string, messageId?: string | undefined, orderingKey?: string | undefined, publishTime?: string | undefined}; export type PubSubPayload4 = {deliveryAttempt?: number | undefined, message?: MessagePayload | undefined, subscription?: string | undefined}; export type CreateApiRentalitemEventsTerminationArgs = {token: string, body: PubSubPayload4}; export type CreateApiRentalitemEventsTerminationOptions = {baseUrl?: string | undefined, jwtHeaderAuthorization?: string | undefined, fetch?: typeof fetch | undefined}; /** * Handle a rental item termination event * * POST /rentalitem/events/termination */ export const createApiRentalitemEventsTermination = async (args: CreateApiRentalitemEventsTerminationArgs, options?: CreateApiRentalitemEventsTerminationOptions) => { const {baseUrl = "https://api.topi-staging.eu", fetch: fetchFn = fetch, jwtHeaderAuthorization} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.token != null) query.append("token", String(args.token)) if (jwtHeaderAuthorization !== undefined) headers.set('authorization', `Bearer ${jwtHeaderAuthorization}`) const url = `${baseUrl.replace(/\/+$/, '')}/rentalitem/events/termination${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 };