import {z} from 'zod' export type GetApiV1CarsPenaltiesIdArgs = {id: number}; export type GetApiV1CarsPenaltiesIdOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const oKAutoCar = z.object({id: z.number().int(), outer_id: z.number().int().gte(-9223372036854776000).lte(9223372036854776000), number: z.string().max(20), tech_passport: z.string().max(255), published_at: z.string().nullable().optional(), created_at: z.string(), updated_at: z.string()}); export const oKAutoDriver = z.object({id: z.number().int(), outer_id: z.number().int().gte(-9223372036854776000).lte(9223372036854776000), iin_number: z.string().max(12).nullable().optional(), doc_number: z.string().max(255).nullable().optional(), doc_issue_date: z.string().nullable().optional(), first_name: z.string().max(255).nullable().optional(), last_name: z.string().max(255).nullable().optional(), middle_name: z.string().max(255).nullable().optional(), created_at: z.string(), updated_at: z.string()}); export const oKAutoCompany = z.object({id: z.number().int(), outer_id: z.number().int().gte(-9223372036854776000).lte(9223372036854776000), bin_number: z.string().max(12).nullable().optional(), name: z.string().max(255).nullable().optional(), created_at: z.string(), updated_at: z.string()}); export const oKAutoPenalty = z.object({id: z.number().int(), outer_id: z.number().int(), protocol_number: z.string().max(255), description: z.string().nullable().optional(), department_name: z.string().max(255).nullable().optional(), punishment_main: z.string().max(255).nullable().optional(), amount: z.string().nullable().optional(), violation_address: z.string().nullable().optional(), violated_at: z.string(), violation_date: z.string().nullable().optional(), violation_time: z.string().nullable().optional(), paid: z.boolean().optional(), payment_date: z.string().nullable().optional(), discount_expires_at: z.string().nullable().optional(), payment_kno: z.string().max(255).nullable().optional(), payment_kbk: z.string().max(255).nullable().optional(), payment_knp: z.string().max(255).nullable().optional(), beneficiary_tax_office_name: z.string().max(255).nullable().optional(), beneficiary_tax_iban: z.string().max(255).nullable().optional(), beneficiary_tax_bin_number: z.string().max(255).nullable().optional(), pdf: z.string().nullable().optional(), photo_urls: z.array(z.string().max(200)).optional(), car: oKAutoCar, driver: oKAutoDriver, company: oKAutoCompany, created_at: z.string(), updated_at: z.string(), state: z.number().int().nullable().optional(), inventory: z.string(), request: z.string(), client: z.string(), noted: 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 /v1/cars/penalties/{id}/ */ export const getApiV1CarsPenaltiesId = async (args: GetApiV1CarsPenaltiesIdArgs, options?: GetApiV1CarsPenaltiesIdOptions) => { const {baseUrl = "https://api.yume.cloud", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/cars/penalties/${encodeURIComponent(String(args.id))}/${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(oKAutoPenalty, await res.json()) };