/*
 * 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 * as shared from "../shared/index.js";

export type GetCountryRegionsGlobals = {
  /**
   * Indicates the client accepts the indicated media types
   */
  accepts?: shared.Accepts | undefined;
  /**
   * An opaque identifier unique to the client
   */
  clientIdentifier?: string | undefined;
  /**
   * The name of the client product
   */
  product?: string | undefined;
  /**
   * The version of the client application
   */
  version?: string | undefined;
  /**
   * The platform of the client
   */
  platform?: string | undefined;
  /**
   * The version of the platform
   */
  platformVersion?: string | undefined;
  /**
   * A relatively friendly name for the client device
   */
  device?: string | undefined;
  /**
   * A potentially less friendly identifier for the device model
   */
  model?: string | undefined;
  /**
   * The device vendor
   */
  deviceVendor?: string | undefined;
  /**
   * A friendly name for the client
   */
  deviceName?: string | undefined;
  /**
   * The marketplace on which the client application is distributed
   */
  marketplace?: string | undefined;
};

export type GetCountryRegionsRequest = {
  /**
   * Indicates the client accepts the indicated media types
   */
  accepts?: shared.Accepts | undefined;
  /**
   * An opaque identifier unique to the client
   */
  clientIdentifier?: string | undefined;
  /**
   * The name of the client product
   */
  product?: string | undefined;
  /**
   * The version of the client application
   */
  version?: string | undefined;
  /**
   * The platform of the client
   */
  platform?: string | undefined;
  /**
   * The version of the platform
   */
  platformVersion?: string | undefined;
  /**
   * A relatively friendly name for the client device
   */
  device?: string | undefined;
  /**
   * A potentially less friendly identifier for the device model
   */
  model?: string | undefined;
  /**
   * The device vendor
   */
  deviceVendor?: string | undefined;
  /**
   * A friendly name for the client
   */
  deviceName?: string | undefined;
  /**
   * The marketplace on which the client application is distributed
   */
  marketplace?: string | undefined;
  /**
   * 3 letter country code
   */
  country: string;
  /**
   * The `providerIdentifier` of the provider
   */
  epgId: string;
};

export type GetCountryRegionsCountry = {
  key?: string | undefined;
  national?: boolean | undefined;
  title?: string | undefined;
  type?: string | undefined;
};

/**
 * `MediaContainer` is the root element of most Plex API responses. It serves as a generic container for various types of content (Metadata, Hubs, Directories, etc.) and includes pagination information (offset, size, totalSize) when applicable.
 *
 * @remarks
 * Common attributes: - identifier: Unique identifier for this container - size: Number of items in this response page - totalSize: Total number of items available (for pagination) - offset: Starting index of this page (for pagination)
 * The container often "hoists" common attributes from its children. For example, if all tracks in a container share the same album title, the `parentTitle` attribute may appear on the MediaContainer rather than being repeated on each track.
 */
export type GetCountryRegionsMediaContainer = {
  identifier?: string | undefined;
  /**
   * The offset of where this container page starts among the total objects available. Also provided in the `X-Plex-Container-Start` header.
   *
   * @remarks
   */
  offset?: number | undefined;
  size?: number | undefined;
  /**
   * The total size of objects available. Also provided in the `X-Plex-Container-Total-Size` header.
   *
   * @remarks
   */
  totalSize?: number | undefined;
  country?: Array<GetCountryRegionsCountry> | undefined;
};

/**
 * OK
 */
export type GetCountryRegionsResponseBody = {
  mediaContainer?: GetCountryRegionsMediaContainer | undefined;
};

export type GetCountryRegionsResponse = {
  /**
   * HTTP response content type for this operation
   */
  contentType: string;
  /**
   * HTTP response status code for this operation
   */
  statusCode: number;
  /**
   * Raw HTTP response; suitable for custom response parsing
   */
  rawResponse: Response;
  /**
   * OK
   */
  object?: GetCountryRegionsResponseBody | undefined;
  headers: { [k: string]: Array<string> };
};

/** @internal */
export type GetCountryRegionsRequest$Outbound = {
  accepts: string;
  "Client-Identifier"?: string | undefined;
  Product?: string | undefined;
  Version?: string | undefined;
  Platform?: string | undefined;
  "Platform-Version"?: string | undefined;
  Device?: string | undefined;
  Model?: string | undefined;
  "Device-Vendor"?: string | undefined;
  "Device-Name"?: string | undefined;
  Marketplace?: string | undefined;
  country: string;
  epgId: string;
};

/** @internal */
export const GetCountryRegionsRequest$outboundSchema: z.ZodType<
  GetCountryRegionsRequest$Outbound,
  z.ZodTypeDef,
  GetCountryRegionsRequest
> = z.object({
  accepts: shared.Accepts$outboundSchema.default(shared.Accepts.ApplicationXml),
  clientIdentifier: z.string().optional(),
  product: z.string().optional(),
  version: z.string().optional(),
  platform: z.string().optional(),
  platformVersion: z.string().optional(),
  device: z.string().optional(),
  model: z.string().optional(),
  deviceVendor: z.string().optional(),
  deviceName: z.string().optional(),
  marketplace: z.string().optional(),
  country: z.string(),
  epgId: z.string(),
}).transform((v) => {
  return remap$(v, {
    clientIdentifier: "Client-Identifier",
    product: "Product",
    version: "Version",
    platform: "Platform",
    platformVersion: "Platform-Version",
    device: "Device",
    model: "Model",
    deviceVendor: "Device-Vendor",
    deviceName: "Device-Name",
    marketplace: "Marketplace",
  });
});

export function getCountryRegionsRequestToJSON(
  getCountryRegionsRequest: GetCountryRegionsRequest,
): string {
  return JSON.stringify(
    GetCountryRegionsRequest$outboundSchema.parse(getCountryRegionsRequest),
  );
}

/** @internal */
export const GetCountryRegionsCountry$inboundSchema: z.ZodType<
  GetCountryRegionsCountry,
  z.ZodTypeDef,
  unknown
> = z.object({
  key: z.string().optional(),
  national: z.boolean().optional(),
  title: z.string().optional(),
  type: z.string().optional(),
});

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

/** @internal */
export const GetCountryRegionsMediaContainer$inboundSchema: z.ZodType<
  GetCountryRegionsMediaContainer,
  z.ZodTypeDef,
  unknown
> = z.object({
  identifier: z.string().optional(),
  offset: z.number().int().optional(),
  size: z.number().int().optional(),
  totalSize: z.number().int().optional(),
  Country: z.array(z.lazy(() => GetCountryRegionsCountry$inboundSchema))
    .optional(),
}).transform((v) => {
  return remap$(v, {
    "Country": "country",
  });
});

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

/** @internal */
export const GetCountryRegionsResponseBody$inboundSchema: z.ZodType<
  GetCountryRegionsResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  MediaContainer: z.lazy(() => GetCountryRegionsMediaContainer$inboundSchema)
    .optional(),
}).transform((v) => {
  return remap$(v, {
    "MediaContainer": "mediaContainer",
  });
});

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

/** @internal */
export const GetCountryRegionsResponse$inboundSchema: z.ZodType<
  GetCountryRegionsResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  ContentType: z.string(),
  StatusCode: z.number().int(),
  RawResponse: z.instanceof(Response),
  object: z.lazy(() => GetCountryRegionsResponseBody$inboundSchema).optional(),
  Headers: z.record(z.array(z.string())).default({}),
}).transform((v) => {
  return remap$(v, {
    "ContentType": "contentType",
    "StatusCode": "statusCode",
    "RawResponse": "rawResponse",
    "Headers": "headers",
  });
});

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