import {z} from 'zod' export type GetApiOdataV1DestinationDestinationKeyArgs = {DestinationKey: string, $select?: string | undefined}; export type GetApiOdataV1DestinationDestinationKeyOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const dDFInfrastructureSwaggerExampleModelsODataSingleResponse1DDFCoreEntitiesDestinationDDFCoreVersion1000CultureNeutralPublicKeyTokenNull = z.object({"@odata.context": z.string().nullable().optional(), DestinationId: z.number().int().optional(), DestinationName: z.string().nullable().optional(), DestinationUrl: z.string().nullable().optional(), DestinationType: z.union([z.literal(1), z.literal(2), z.literal(3), z.literal(4), z.literal(5), z.literal(6), z.literal(7), z.literal(8), z.literal(9), z.literal(10), z.literal(11), z.literal(12), z.literal(13)]).nullable().optional(), DestinationStatus: z.union([z.literal(1), z.literal(2), z.literal(3)]).nullable().optional(), MemberFirstName: z.string().nullable().optional(), MemberLastName: z.string().nullable().optional(), MemberKey: z.string().nullable().optional(), OriginalEntryTimestamp: z.string().nullable().optional(), ModificationTimestamp: z.string().nullable().optional(), FullNSP: z.boolean().optional()}); 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 }; /** * Get a single Client Destination by DestinationId * * GET /odata/v1/Destination/{DestinationKey} */ export const getApiOdataV1DestinationDestinationKey = async (args: GetApiOdataV1DestinationDestinationKeyArgs, options?: GetApiOdataV1DestinationDestinationKeyOptions) => { const {baseUrl = "https://localhost:7051", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.$select != null) query.append("$select", String(args.$select)) const url = `${baseUrl.replace(/\/+$/, '')}/odata/v1/Destination/${encodeURIComponent(String(args.DestinationKey))}${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(dDFInfrastructureSwaggerExampleModelsODataSingleResponse1DDFCoreEntitiesDestinationDDFCoreVersion1000CultureNeutralPublicKeyTokenNull, await res.json()) };