/*
 * 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 GetBannerImageRequest = {
  /**
   * the id of the library item to return the children of.
   */
  ratingKey: number;
  width: number;
  height: number;
  minSize: number;
  upscale: number;
  /**
   * An authentication token, obtained from plex.tv
   */
  xPlexToken: string;
};

export type GetBannerImageResponse = {
  /**
   * 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;
  /**
   * Successful response returning an image
   */
  responseStream?: ReadableStream<Uint8Array> | undefined;
  headers: { [k: string]: Array<string> };
};

/** @internal */
export const GetBannerImageRequest$inboundSchema: z.ZodType<
  GetBannerImageRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  ratingKey: z.number().int(),
  width: z.number().int(),
  height: z.number().int(),
  minSize: z.number().int(),
  upscale: z.number().int(),
  "X-Plex-Token": z.string(),
}).transform((v) => {
  return remap$(v, {
    "X-Plex-Token": "xPlexToken",
  });
});

/** @internal */
export type GetBannerImageRequest$Outbound = {
  ratingKey: number;
  width: number;
  height: number;
  minSize: number;
  upscale: number;
  "X-Plex-Token": string;
};

/** @internal */
export const GetBannerImageRequest$outboundSchema: z.ZodType<
  GetBannerImageRequest$Outbound,
  z.ZodTypeDef,
  GetBannerImageRequest
> = z.object({
  ratingKey: z.number().int(),
  width: z.number().int(),
  height: z.number().int(),
  minSize: z.number().int(),
  upscale: z.number().int(),
  xPlexToken: z.string(),
}).transform((v) => {
  return remap$(v, {
    xPlexToken: "X-Plex-Token",
  });
});

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

export function getBannerImageRequestToJSON(
  getBannerImageRequest: GetBannerImageRequest,
): string {
  return JSON.stringify(
    GetBannerImageRequest$outboundSchema.parse(getBannerImageRequest),
  );
}

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

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

/** @internal */
export type GetBannerImageResponse$Outbound = {
  ContentType: string;
  StatusCode: number;
  RawResponse: never;
  "response-stream"?: ReadableStream<Uint8Array> | undefined;
  Headers: { [k: string]: Array<string> };
};

/** @internal */
export const GetBannerImageResponse$outboundSchema: z.ZodType<
  GetBannerImageResponse$Outbound,
  z.ZodTypeDef,
  GetBannerImageResponse
> = z.object({
  contentType: z.string(),
  statusCode: z.number().int(),
  rawResponse: z.instanceof(Response).transform(() => {
    throw new Error("Response cannot be serialized");
  }),
  responseStream: z.instanceof(ReadableStream<Uint8Array>).optional(),
  headers: z.record(z.array(z.string())),
}).transform((v) => {
  return remap$(v, {
    contentType: "ContentType",
    statusCode: "StatusCode",
    rawResponse: "RawResponse",
    responseStream: "response-stream",
    headers: "Headers",
  });
});

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

export function getBannerImageResponseToJSON(
  getBannerImageResponse: GetBannerImageResponse,
): string {
  return JSON.stringify(
    GetBannerImageResponse$outboundSchema.parse(getBannerImageResponse),
  );
}

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