/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Coordinates, Coordinates$inboundSchema } from "./coordinates.js"; export type Location = { /** * The English name of the detected city. */ city?: string | undefined; /** * The English name of the detected continent (North America, Europe, Asia, South America, Africa, Oceania, Antarctica). */ continent?: string | undefined; coordinates?: Coordinates | undefined; /** * The English name of the detected country. */ country?: string | undefined; /** * The detected two-letter ISO 3166-1 alpha-2 country code (US, CN, GB, RU, ...). */ countryCode?: string | undefined; /** * The postal code (if applicable) of the detected location. */ postalCode?: string | undefined; /** * The state or province name of the detected location. */ province?: string | undefined; /** * The English name of the registered country. */ registeredCountry?: string | undefined; /** * The registered country's two-letter ISO 3166-1 alpha-2 country code (US, CN, GB, RU, ...). */ registeredCountryCode?: string | undefined; /** * The IANA time zone database name of the detected location. */ timezone?: string | undefined; }; /** @internal */ export const Location$inboundSchema: z.ZodType< Location, z.ZodTypeDef, unknown > = z.object({ city: z.string().optional(), continent: z.string().optional(), coordinates: Coordinates$inboundSchema.optional(), country: z.string().optional(), country_code: z.string().optional(), postal_code: z.string().optional(), province: z.string().optional(), registered_country: z.string().optional(), registered_country_code: z.string().optional(), timezone: z.string().optional(), }).transform((v) => { return remap$(v, { "country_code": "countryCode", "postal_code": "postalCode", "registered_country": "registeredCountry", "registered_country_code": "registeredCountryCode", }); }); export function locationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Location$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Location' from JSON`, ); }