import {z} from 'zod' export type Model230 = {guardian?: string | undefined, prefix?: ('Mr.' | 'Ms.' | 'Mrs.' | 'Miss' | 'Ms' | 'Prof' | 'Sir') | undefined, suffix?: ('Jr.' | 'Sr.' | 'I' | 'II' | 'III' | 'IV' | 'V') | undefined, first_name: string, last_name: string, gender: 'male' | 'female' | 'unknown', dob: string, zip?: string | undefined, species?: ('Human' | 'Crocodile' | 'Frog' | 'Iguana' | 'Lizard' | 'Snake' | 'Tortoise' | 'Turtle' | 'Spider' | 'Other Arthopoda' | 'Chicken' | 'African Goshawk' | 'Budgerigar' | 'Cockatiel' | 'Cockatoo' | 'Common Canary' | 'Crow' | 'Duck' | 'Eagle' | 'Goose' | 'Guinea Fowl' | 'Kestrel' | 'Kite' | 'Macaw' | 'Ostrich' | 'Other Aves' | 'Owl' | 'Parakeet' | 'Parrot' | 'Partridge' | 'Peregrin Falcon' | 'Pheasant' | 'Pigeon' | 'Quail' | 'Snipe' | 'Sparrow' | 'Starling' | 'Swan' | 'Turtle Dove' | 'Bison' | 'Cattle/Bovine' | 'Buffalo' | 'Other Bovinae' | 'Alpaca' | 'Camel' | 'Llama' | 'Other Camelidae' | 'Dog/Canine' | 'Fox' | 'Jackal' | 'Raccoon Dog' | 'Wolf' | 'Other Caprinae' | 'Goat/Carpine' | 'Sheep/Ovine' | 'Elk' | 'Moose' | 'Fallow' | 'Other Cervidae' | 'Red Deer' | 'Reindeer' | 'Roe Deer' | 'Donkey/Asinine' | 'Horse/Equine' | 'Hybrid' | 'Other Equidae' | 'Zebra' | 'Bobcat' | 'Cougar' | 'Puma' | 'European Lynx' | 'Cat/Feline' | 'Jaguar' | 'Leopard' | 'Lion' | 'Other Felidae' | 'Tiger' | 'Wild Cat' | 'European Rabbit' | 'Hare' | 'Other Leporidae' | 'Bivalvia' | 'Cephalopoda' | 'Other Mollusca' | 'Badger' | 'Ferret' | 'Mink' | 'Other Mustelidae' | 'Bat' | 'Bear' | 'Hedgehog' | 'Monkey' | 'Other Mammalia' | 'Arctic Char' | 'Atlantic Salmon' | 'Brill' | 'Carp' | 'Catfish' | 'Cod' | 'Crucian Carp' | 'European Eel' | 'Gilthead' | 'Goldfish' | 'Gudgeon' | 'Halibut' | 'Largemouth Bass' | 'Mullet' | 'Other Pisces' | 'Perch' | 'Pike' | 'Roach' | 'Sea Bream' | 'Seabass' | 'Sharpsnout Seabream' | 'Sole' | 'Sturgeon' | 'Tench' | 'Trout' | 'Turbot' | 'Rockfish/Wolffish' | 'Beaver' | 'Chinchilla' | 'Dormouse' | 'Dwarf Hamster' | 'European Hamster' | 'Gerbil' | 'Guinea Pig' | 'House Mouse' | 'Other Rodentia' | 'Rat' | 'Russian Hamster' | 'Syrian Hamster' | 'Golden Hamster' | 'Vole' | 'Other Suidae' | 'Pig/Porcine' | 'Wild Boar' | 'Addax') | undefined, company?: string | undefined, street1?: string | undefined, street2?: string | undefined, city?: string | undefined, state?: string | undefined, country?: string | undefined, phone?: string | undefined, email?: string | undefined, ssn?: string | undefined, ssn_serial?: string | undefined, communications_opt_in?: boolean | undefined, language_preference?: string | undefined, id_image?: string | undefined, mbi?: string | undefined, viewed_notice_of_privacy_practices?: boolean | undefined, viewed_notice_of_privacy_practices_date?: string | undefined}; export type UpdateApiV1PatientArgs = {body: Model230}; export type UpdateApiV1PatientOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const model231 = z.object({patient_token: z.string().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 }; /** * Create Patient * * PUT /v1/patient */ export const updateApiV1Patient = async (args: UpdateApiV1PatientArgs, options?: UpdateApiV1PatientOptions) => { const {baseUrl = "https://api.truepill.com", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (apiKey !== undefined) headers.set("Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/patient${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 validateResponse(model231, await res.json()) };