import {z} from 'zod' export type GetApiApiPowerBiAppServiceBusMailArgs = {email?: (string | null) | undefined, mobileNo?: (string | null) | undefined, lsCode?: (string | null) | undefined, string1?: (string | null) | undefined, value1?: (number | null) | undefined, string2?: (string | null) | undefined, value2?: (number | null) | undefined, string3?: (string | null) | undefined, value3?: (number | null) | undefined}; export type GetApiApiPowerBiAppServiceBusMailOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const getApiApiPowerBiAppServiceBusMailResponse = z.unknown(); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Triggermail * * GET /api/PowerBiApp/ServiceBusMail */ export const getApiApiPowerBiAppServiceBusMail = async (args: GetApiApiPowerBiAppServiceBusMailArgs, options: GetApiApiPowerBiAppServiceBusMailOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.email != null) query.append("email", String(args.email)) if (args.mobileNo != null) query.append("mobileNo", String(args.mobileNo)) if (args.lsCode != null) query.append("lsCode", String(args.lsCode)) if (args.string1 != null) query.append("string1", String(args.string1)) if (args.value1 != null) query.append("value1", String(args.value1)) if (args.string2 != null) query.append("string2", String(args.string2)) if (args.value2 != null) query.append("value2", String(args.value2)) if (args.string3 != null) query.append("string3", String(args.string3)) if (args.value3 != null) query.append("value3", String(args.value3)) const url = `${baseUrl.replace(/\/+$/, '')}/api/PowerBiApp/ServiceBusMail${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(getApiApiPowerBiAppServiceBusMailResponse, await res.json()) };