/*
 * 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 ISO 3166-1 code representing the continent associated with the location of the user.
 */
export const Continent = {
  Af: "AF",
  An: "AN",
  As: "AS",
  Eu: "EU",
  Na: "NA",
  Oc: "OC",
  Sa: "SA",
} as const;
/**
 * The 2-letter ISO 3166-1 code representing the continent associated with the location of the user.
 */
export type Continent = ClosedEnum<typeof Continent>;

export type AnalyticsContinents = {
  /**
   * The 2-letter ISO 3166-1 code representing the continent associated with the location of the user.
   */
  continent: Continent;
  /**
   * The number of clicks from this continent
   */
  clicks?: number | undefined;
  /**
   * The number of leads from this continent
   */
  leads?: number | undefined;
  /**
   * The number of sales from this continent
   */
  sales?: number | undefined;
  /**
   * The total amount of sales from this continent, in cents
   */
  saleAmount?: number | undefined;
};

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

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

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

/** @internal */
export const AnalyticsContinents$inboundSchema: z.ZodType<
  AnalyticsContinents,
  z.ZodTypeDef,
  unknown
> = z.object({
  continent: Continent$inboundSchema,
  clicks: z.number().default(0),
  leads: z.number().default(0),
  sales: z.number().default(0),
  saleAmount: z.number().default(0),
});

/** @internal */
export type AnalyticsContinents$Outbound = {
  continent: string;
  clicks: number;
  leads: number;
  sales: number;
  saleAmount: number;
};

/** @internal */
export const AnalyticsContinents$outboundSchema: z.ZodType<
  AnalyticsContinents$Outbound,
  z.ZodTypeDef,
  AnalyticsContinents
> = z.object({
  continent: Continent$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 AnalyticsContinents$ {
  /** @deprecated use `AnalyticsContinents$inboundSchema` instead. */
  export const inboundSchema = AnalyticsContinents$inboundSchema;
  /** @deprecated use `AnalyticsContinents$outboundSchema` instead. */
  export const outboundSchema = AnalyticsContinents$outboundSchema;
  /** @deprecated use `AnalyticsContinents$Outbound` instead. */
  export type Outbound = AnalyticsContinents$Outbound;
}

export function analyticsContinentsToJSON(
  analyticsContinents: AnalyticsContinents,
): string {
  return JSON.stringify(
    AnalyticsContinents$outboundSchema.parse(analyticsContinents),
  );
}

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