/*
 * 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 GetMediaArtsRequest = {
  /**
   * the id of the library item to return the artwork of.
   */
  ratingKey: number;
};

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

export type GetMediaArtsMediaContainer = {
  /**
   * 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<GetMediaArtsMetadata>;
};

/**
 * The available background artwork for the library item.
 */
export type GetMediaArtsResponseBody = {
  mediaContainer?: GetMediaArtsMediaContainer | undefined;
};

export type GetMediaArtsResponse = {
  /**
   * 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 background artwork for the library item.
   */
  object?: GetMediaArtsResponseBody | undefined;
};

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

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

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

export function getMediaArtsRequestToJSON(
  getMediaArtsRequest: GetMediaArtsRequest,
): string {
  return JSON.stringify(
    GetMediaArtsRequest$outboundSchema.parse(getMediaArtsRequest),
  );
}

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

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

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

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

export function getMediaArtsMetadataToJSON(
  getMediaArtsMetadata: GetMediaArtsMetadata,
): string {
  return JSON.stringify(
    GetMediaArtsMetadata$outboundSchema.parse(getMediaArtsMetadata),
  );
}

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

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

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

/** @internal */
export const GetMediaArtsMediaContainer$outboundSchema: z.ZodType<
  GetMediaArtsMediaContainer$Outbound,
  z.ZodTypeDef,
  GetMediaArtsMediaContainer
> = z.object({
  size: z.number().int(),
  mediaTagVersion: z.number().int(),
  mediaTagPrefix: z.string(),
  identifier: z.string(),
  metadata: z.array(z.lazy(() => GetMediaArtsMetadata$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 GetMediaArtsMediaContainer$ {
  /** @deprecated use `GetMediaArtsMediaContainer$inboundSchema` instead. */
  export const inboundSchema = GetMediaArtsMediaContainer$inboundSchema;
  /** @deprecated use `GetMediaArtsMediaContainer$outboundSchema` instead. */
  export const outboundSchema = GetMediaArtsMediaContainer$outboundSchema;
  /** @deprecated use `GetMediaArtsMediaContainer$Outbound` instead. */
  export type Outbound = GetMediaArtsMediaContainer$Outbound;
}

export function getMediaArtsMediaContainerToJSON(
  getMediaArtsMediaContainer: GetMediaArtsMediaContainer,
): string {
  return JSON.stringify(
    GetMediaArtsMediaContainer$outboundSchema.parse(getMediaArtsMediaContainer),
  );
}

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

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

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

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

export function getMediaArtsResponseBodyToJSON(
  getMediaArtsResponseBody: GetMediaArtsResponseBody,
): string {
  return JSON.stringify(
    GetMediaArtsResponseBody$outboundSchema.parse(getMediaArtsResponseBody),
  );
}

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

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

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

/** @internal */
export const GetMediaArtsResponse$outboundSchema: z.ZodType<
  GetMediaArtsResponse$Outbound,
  z.ZodTypeDef,
  GetMediaArtsResponse
> = z.object({
  contentType: z.string(),
  statusCode: z.number().int(),
  rawResponse: z.instanceof(Response).transform(() => {
    throw new Error("Response cannot be serialized");
  }),
  object: z.lazy(() => GetMediaArtsResponseBody$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 GetMediaArtsResponse$ {
  /** @deprecated use `GetMediaArtsResponse$inboundSchema` instead. */
  export const inboundSchema = GetMediaArtsResponse$inboundSchema;
  /** @deprecated use `GetMediaArtsResponse$outboundSchema` instead. */
  export const outboundSchema = GetMediaArtsResponse$outboundSchema;
  /** @deprecated use `GetMediaArtsResponse$Outbound` instead. */
  export type Outbound = GetMediaArtsResponse$Outbound;
}

export function getMediaArtsResponseToJSON(
  getMediaArtsResponse: GetMediaArtsResponse,
): string {
  return JSON.stringify(
    GetMediaArtsResponse$outboundSchema.parse(getMediaArtsResponse),
  );
}

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