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

import * as z from "zod";
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";

export type GetMediaPostersRequest = {
  /**
   * the id of the library item to return the posters of.
   */
  ratingKey: number;
};

export type GetMediaPostersMetadata = {
  /**
   * The URL of the poster.
   */
  key: string;
  /**
   * The provider of the poster.
   */
  provider?: string | undefined;
  /**
   * The URL of the poster.
   */
  ratingKey: string;
  /**
   * Whether this is the selected poster.
   */
  selected: boolean;
  /**
   * The URL of the poster thumbnail.
   */
  thumb: string;
};

export type GetMediaPostersMediaContainer = {
  /**
   * Number of media items returned in this response.
   */
  size: number;
  /**
   * The version number for media tags.
   */
  mediaTagVersion: number;
  /**
   * The prefix used for media tag resource paths.
   */
  mediaTagPrefix: string;
  /**
   * An plugin identifier for the media container.
   */
  identifier: string;
  metadata: Array<GetMediaPostersMetadata>;
};

/**
 * The available posters for the library item.
 */
export type GetMediaPostersResponseBody = {
  mediaContainer?: GetMediaPostersMediaContainer | undefined;
};

export type GetMediaPostersResponse = {
  /**
   * 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;
  /**
   * The available posters for the library item.
   */
  object?: GetMediaPostersResponseBody | undefined;
};

/** @internal */
export const GetMediaPostersRequest$inboundSchema: z.ZodType<
  GetMediaPostersRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  ratingKey: z.number().int(),
});

/** @internal */
export type GetMediaPostersRequest$Outbound = {
  ratingKey: number;
};

/** @internal */
export const GetMediaPostersRequest$outboundSchema: z.ZodType<
  GetMediaPostersRequest$Outbound,
  z.ZodTypeDef,
  GetMediaPostersRequest
> = z.object({
  ratingKey: z.number().int(),
});

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

export function getMediaPostersRequestToJSON(
  getMediaPostersRequest: GetMediaPostersRequest,
): string {
  return JSON.stringify(
    GetMediaPostersRequest$outboundSchema.parse(getMediaPostersRequest),
  );
}

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

/** @internal */
export const GetMediaPostersMetadata$inboundSchema: z.ZodType<
  GetMediaPostersMetadata,
  z.ZodTypeDef,
  unknown
> = z.object({
  key: z.string(),
  provider: z.string().optional(),
  ratingKey: z.string(),
  selected: z.boolean(),
  thumb: z.string(),
});

/** @internal */
export type GetMediaPostersMetadata$Outbound = {
  key: string;
  provider?: string | undefined;
  ratingKey: string;
  selected: boolean;
  thumb: string;
};

/** @internal */
export const GetMediaPostersMetadata$outboundSchema: z.ZodType<
  GetMediaPostersMetadata$Outbound,
  z.ZodTypeDef,
  GetMediaPostersMetadata
> = z.object({
  key: z.string(),
  provider: z.string().optional(),
  ratingKey: z.string(),
  selected: z.boolean(),
  thumb: z.string(),
});

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

export function getMediaPostersMetadataToJSON(
  getMediaPostersMetadata: GetMediaPostersMetadata,
): string {
  return JSON.stringify(
    GetMediaPostersMetadata$outboundSchema.parse(getMediaPostersMetadata),
  );
}

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

/** @internal */
export const GetMediaPostersMediaContainer$inboundSchema: z.ZodType<
  GetMediaPostersMediaContainer,
  z.ZodTypeDef,
  unknown
> = z.object({
  size: z.number().int(),
  mediaTagVersion: z.number().int(),
  mediaTagPrefix: z.string(),
  identifier: z.string(),
  Metadata: z.array(z.lazy(() => GetMediaPostersMetadata$inboundSchema)),
}).transform((v) => {
  return remap$(v, {
    "Metadata": "metadata",
  });
});

/** @internal */
export type GetMediaPostersMediaContainer$Outbound = {
  size: number;
  mediaTagVersion: number;
  mediaTagPrefix: string;
  identifier: string;
  Metadata: Array<GetMediaPostersMetadata$Outbound>;
};

/** @internal */
export const GetMediaPostersMediaContainer$outboundSchema: z.ZodType<
  GetMediaPostersMediaContainer$Outbound,
  z.ZodTypeDef,
  GetMediaPostersMediaContainer
> = z.object({
  size: z.number().int(),
  mediaTagVersion: z.number().int(),
  mediaTagPrefix: z.string(),
  identifier: z.string(),
  metadata: z.array(z.lazy(() => GetMediaPostersMetadata$outboundSchema)),
}).transform((v) => {
  return remap$(v, {
    metadata: "Metadata",
  });
});

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

export function getMediaPostersMediaContainerToJSON(
  getMediaPostersMediaContainer: GetMediaPostersMediaContainer,
): string {
  return JSON.stringify(
    GetMediaPostersMediaContainer$outboundSchema.parse(
      getMediaPostersMediaContainer,
    ),
  );
}

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

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

/** @internal */
export type GetMediaPostersResponseBody$Outbound = {
  MediaContainer?: GetMediaPostersMediaContainer$Outbound | undefined;
};

/** @internal */
export const GetMediaPostersResponseBody$outboundSchema: z.ZodType<
  GetMediaPostersResponseBody$Outbound,
  z.ZodTypeDef,
  GetMediaPostersResponseBody
> = z.object({
  mediaContainer: z.lazy(() => GetMediaPostersMediaContainer$outboundSchema)
    .optional(),
}).transform((v) => {
  return remap$(v, {
    mediaContainer: "MediaContainer",
  });
});

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

export function getMediaPostersResponseBodyToJSON(
  getMediaPostersResponseBody: GetMediaPostersResponseBody,
): string {
  return JSON.stringify(
    GetMediaPostersResponseBody$outboundSchema.parse(
      getMediaPostersResponseBody,
    ),
  );
}

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

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

/** @internal */
export type GetMediaPostersResponse$Outbound = {
  ContentType: string;
  StatusCode: number;
  RawResponse: never;
  object?: GetMediaPostersResponseBody$Outbound | undefined;
};

/** @internal */
export const GetMediaPostersResponse$outboundSchema: z.ZodType<
  GetMediaPostersResponse$Outbound,
  z.ZodTypeDef,
  GetMediaPostersResponse
> = z.object({
  contentType: z.string(),
  statusCode: z.number().int(),
  rawResponse: z.instanceof(Response).transform(() => {
    throw new Error("Response cannot be serialized");
  }),
  object: z.lazy(() => GetMediaPostersResponseBody$outboundSchema).optional(),
}).transform((v) => {
  return remap$(v, {
    contentType: "ContentType",
    statusCode: "StatusCode",
    rawResponse: "RawResponse",
  });
});

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

export function getMediaPostersResponseToJSON(
  getMediaPostersResponse: GetMediaPostersResponse,
): string {
  return JSON.stringify(
    GetMediaPostersResponse$outboundSchema.parse(getMediaPostersResponse),
  );
}

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