/*
 * 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 GetLineupChannelsGlobals = {
  /**
   * 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 GetLineupChannelsRequest = {
  /**
   * 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;
  /**
   * The URIs describing the lineups
   */
  lineup: Array<string>;
};

/**
 * - `-1`: N/A
 *
 * @remarks
 * - `0`: Over the air
 * - `1`: Cable
 * - `2`: Satellite
 * - `3`: IPTV
 * - `4`: Virtual
 */
export enum LineupType {
  Minus1 = -1,
  Zero = 0,
  One = 1,
  Two = 2,
  Three = 3,
  Four = 4,
}

export type Lineup = {
  title?: string | undefined;
  /**
   * The type of this object (`lineup` in this case)
   */
  type?: string | undefined;
  /**
   * - `-1`: N/A
   *
   * @remarks
   * - `0`: Over the air
   * - `1`: Cable
   * - `2`: Satellite
   * - `3`: IPTV
   * - `4`: Virtual
   */
  lineupType?: LineupType | undefined;
  location?: string | undefined;
  /**
   * The uuid of this lineup
   */
  uuid?: string | undefined;
  channel?: Array<shared.Channel> | 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 GetLineupChannelsMediaContainer = {
  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;
  lineup?: Array<Lineup> | undefined;
};

/**
 * OK
 */
export type GetLineupChannelsResponseBody = {
  mediaContainer?: GetLineupChannelsMediaContainer | undefined;
};

export type GetLineupChannelsResponse = {
  /**
   * 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?: GetLineupChannelsResponseBody | undefined;
};

/** @internal */
export type GetLineupChannelsRequest$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;
  lineup: Array<string>;
};

/** @internal */
export const GetLineupChannelsRequest$outboundSchema: z.ZodType<
  GetLineupChannelsRequest$Outbound,
  z.ZodTypeDef,
  GetLineupChannelsRequest
> = 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(),
  lineup: z.array(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 getLineupChannelsRequestToJSON(
  getLineupChannelsRequest: GetLineupChannelsRequest,
): string {
  return JSON.stringify(
    GetLineupChannelsRequest$outboundSchema.parse(getLineupChannelsRequest),
  );
}

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

/** @internal */
export const Lineup$inboundSchema: z.ZodType<Lineup, z.ZodTypeDef, unknown> = z
  .object({
    title: z.string().optional(),
    type: z.string().optional(),
    lineupType: LineupType$inboundSchema.optional(),
    location: z.string().optional(),
    uuid: z.string().optional(),
    Channel: z.array(shared.Channel$inboundSchema).optional(),
  }).transform((v) => {
    return remap$(v, {
      "Channel": "channel",
    });
  });

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

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

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

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

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

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

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