/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod";
import { safeParse } from "../../lib/schemas.js";
import { ClosedEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

/**
 * The 2-letter country code of the city: https://d.to/geo
 */
export const AnalyticsCitiesCountry = {
  Af: "AF",
  Al: "AL",
  Dz: "DZ",
  As: "AS",
  Ad: "AD",
  Ao: "AO",
  Ai: "AI",
  Aq: "AQ",
  Ag: "AG",
  Ar: "AR",
  Am: "AM",
  Aw: "AW",
  Au: "AU",
  At: "AT",
  Az: "AZ",
  Bs: "BS",
  Bh: "BH",
  Bd: "BD",
  Bb: "BB",
  By: "BY",
  Be: "BE",
  Bz: "BZ",
  Bj: "BJ",
  Bm: "BM",
  Bt: "BT",
  Bo: "BO",
  Ba: "BA",
  Bw: "BW",
  Bv: "BV",
  Br: "BR",
  Io: "IO",
  Bn: "BN",
  Bg: "BG",
  Bf: "BF",
  Bi: "BI",
  Kh: "KH",
  Cm: "CM",
  Ca: "CA",
  Cv: "CV",
  Ky: "KY",
  Cf: "CF",
  Td: "TD",
  Cl: "CL",
  Cn: "CN",
  Cx: "CX",
  Cc: "CC",
  Co: "CO",
  Km: "KM",
  Cg: "CG",
  Cd: "CD",
  Ck: "CK",
  Cr: "CR",
  Ci: "CI",
  Hr: "HR",
  Cu: "CU",
  Cy: "CY",
  Cz: "CZ",
  Dk: "DK",
  Dj: "DJ",
  Dm: "DM",
  Do: "DO",
  Ec: "EC",
  Eg: "EG",
  Sv: "SV",
  Gq: "GQ",
  Er: "ER",
  Ee: "EE",
  Et: "ET",
  Fk: "FK",
  Fo: "FO",
  Fj: "FJ",
  Fi: "FI",
  Fr: "FR",
  Gf: "GF",
  Pf: "PF",
  Tf: "TF",
  Ga: "GA",
  Gm: "GM",
  Ge: "GE",
  De: "DE",
  Gh: "GH",
  Gi: "GI",
  Gr: "GR",
  Gl: "GL",
  Gd: "GD",
  Gp: "GP",
  Gu: "GU",
  Gt: "GT",
  Gn: "GN",
  Gw: "GW",
  Gy: "GY",
  Ht: "HT",
  Hm: "HM",
  Va: "VA",
  Hn: "HN",
  Hk: "HK",
  Hu: "HU",
  Is: "IS",
  In: "IN",
  Id: "ID",
  Ir: "IR",
  Iq: "IQ",
  Ie: "IE",
  Il: "IL",
  It: "IT",
  Jm: "JM",
  Jp: "JP",
  Jo: "JO",
  Kz: "KZ",
  Ke: "KE",
  Ki: "KI",
  Kp: "KP",
  Kr: "KR",
  Kw: "KW",
  Kg: "KG",
  La: "LA",
  Lv: "LV",
  Lb: "LB",
  Ls: "LS",
  Lr: "LR",
  Ly: "LY",
  Li: "LI",
  Lt: "LT",
  Lu: "LU",
  Mo: "MO",
  Mg: "MG",
  Mw: "MW",
  My: "MY",
  Mv: "MV",
  Ml: "ML",
  Mt: "MT",
  Mh: "MH",
  Mq: "MQ",
  Mr: "MR",
  Mu: "MU",
  Yt: "YT",
  Mx: "MX",
  Fm: "FM",
  Md: "MD",
  Mc: "MC",
  Mn: "MN",
  Ms: "MS",
  Ma: "MA",
  Mz: "MZ",
  Mm: "MM",
  Na: "NA",
  Nr: "NR",
  Np: "NP",
  Nl: "NL",
  Nc: "NC",
  Nz: "NZ",
  Ni: "NI",
  Ne: "NE",
  Ng: "NG",
  Nu: "NU",
  Nf: "NF",
  Mk: "MK",
  Mp: "MP",
  No: "NO",
  Om: "OM",
  Pk: "PK",
  Pw: "PW",
  Ps: "PS",
  Pa: "PA",
  Pg: "PG",
  Py: "PY",
  Pe: "PE",
  Ph: "PH",
  Pn: "PN",
  Pl: "PL",
  Pt: "PT",
  Pr: "PR",
  Qa: "QA",
  Re: "RE",
  Ro: "RO",
  Ru: "RU",
  Rw: "RW",
  Sh: "SH",
  Kn: "KN",
  Lc: "LC",
  Pm: "PM",
  Vc: "VC",
  Ws: "WS",
  Sm: "SM",
  St: "ST",
  Sa: "SA",
  Sn: "SN",
  Sc: "SC",
  Sl: "SL",
  Sg: "SG",
  Sk: "SK",
  Si: "SI",
  Sb: "SB",
  So: "SO",
  Za: "ZA",
  Gs: "GS",
  Es: "ES",
  Lk: "LK",
  Sd: "SD",
  Sr: "SR",
  Sj: "SJ",
  Sz: "SZ",
  Se: "SE",
  Ch: "CH",
  Sy: "SY",
  Tw: "TW",
  Tj: "TJ",
  Tz: "TZ",
  Th: "TH",
  Tl: "TL",
  Tg: "TG",
  Tk: "TK",
  To: "TO",
  Tt: "TT",
  Tn: "TN",
  Tr: "TR",
  Tm: "TM",
  Tc: "TC",
  Tv: "TV",
  Ug: "UG",
  Ua: "UA",
  Ae: "AE",
  Gb: "GB",
  Us: "US",
  Um: "UM",
  Uy: "UY",
  Uz: "UZ",
  Vu: "VU",
  Ve: "VE",
  Vn: "VN",
  Vg: "VG",
  Vi: "VI",
  Wf: "WF",
  Eh: "EH",
  Ye: "YE",
  Zm: "ZM",
  Zw: "ZW",
  Ax: "AX",
  Bq: "BQ",
  Cw: "CW",
  Gg: "GG",
  Im: "IM",
  Je: "JE",
  Me: "ME",
  Bl: "BL",
  Mf: "MF",
  Rs: "RS",
  Sx: "SX",
  Ss: "SS",
  Xk: "XK",
} as const;
/**
 * The 2-letter country code of the city: https://d.to/geo
 */
export type AnalyticsCitiesCountry = ClosedEnum<typeof AnalyticsCitiesCountry>;

export type AnalyticsCities = {
  /**
   * The name of the city
   */
  city: string;
  /**
   * The 2-letter country code of the city: https://d.to/geo
   */
  country: AnalyticsCitiesCountry;
  /**
   * The number of clicks from this city
   */
  clicks?: number | undefined;
  /**
   * The number of leads from this city
   */
  leads?: number | undefined;
  /**
   * The number of sales from this city
   */
  sales?: number | undefined;
  /**
   * The total amount of sales from this city, in cents
   */
  saleAmount?: number | undefined;
};

/** @internal */
export const AnalyticsCitiesCountry$inboundSchema: z.ZodNativeEnum<
  typeof AnalyticsCitiesCountry
> = z.nativeEnum(AnalyticsCitiesCountry);

/** @internal */
export const AnalyticsCitiesCountry$outboundSchema: z.ZodNativeEnum<
  typeof AnalyticsCitiesCountry
> = AnalyticsCitiesCountry$inboundSchema;

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace AnalyticsCitiesCountry$ {
  /** @deprecated use `AnalyticsCitiesCountry$inboundSchema` instead. */
  export const inboundSchema = AnalyticsCitiesCountry$inboundSchema;
  /** @deprecated use `AnalyticsCitiesCountry$outboundSchema` instead. */
  export const outboundSchema = AnalyticsCitiesCountry$outboundSchema;
}

/** @internal */
export const AnalyticsCities$inboundSchema: z.ZodType<
  AnalyticsCities,
  z.ZodTypeDef,
  unknown
> = z.object({
  city: z.string(),
  country: AnalyticsCitiesCountry$inboundSchema,
  clicks: z.number().default(0),
  leads: z.number().default(0),
  sales: z.number().default(0),
  saleAmount: z.number().default(0),
});

/** @internal */
export type AnalyticsCities$Outbound = {
  city: string;
  country: string;
  clicks: number;
  leads: number;
  sales: number;
  saleAmount: number;
};

/** @internal */
export const AnalyticsCities$outboundSchema: z.ZodType<
  AnalyticsCities$Outbound,
  z.ZodTypeDef,
  AnalyticsCities
> = z.object({
  city: z.string(),
  country: AnalyticsCitiesCountry$outboundSchema,
  clicks: z.number().default(0),
  leads: z.number().default(0),
  sales: z.number().default(0),
  saleAmount: z.number().default(0),
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace AnalyticsCities$ {
  /** @deprecated use `AnalyticsCities$inboundSchema` instead. */
  export const inboundSchema = AnalyticsCities$inboundSchema;
  /** @deprecated use `AnalyticsCities$outboundSchema` instead. */
  export const outboundSchema = AnalyticsCities$outboundSchema;
  /** @deprecated use `AnalyticsCities$Outbound` instead. */
  export type Outbound = AnalyticsCities$Outbound;
}

export function analyticsCitiesToJSON(
  analyticsCities: AnalyticsCities,
): string {
  return JSON.stringify(AnalyticsCities$outboundSchema.parse(analyticsCities));
}

export function analyticsCitiesFromJSON(
  jsonString: string,
): SafeParseResult<AnalyticsCities, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AnalyticsCities$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AnalyticsCities' from JSON`,
  );
}
