/*
 * 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 GetAllLibrariesLocation = {
  id: number;
  path: string;
};

export type GetAllLibrariesDirectory = {
  allowSync: boolean;
  art: string;
  composite: string;
  filters: boolean;
  refreshing: boolean;
  thumb: string;
  key: string;
  type: string;
  title: string;
  agent: string;
  scanner: string;
  language: string;
  uuid: string;
  /**
   * Unix epoch datetime in seconds
   */
  updatedAt: number;
  /**
   * Unix epoch datetime in seconds
   */
  createdAt: number;
  /**
   * Unix epoch datetime in seconds
   */
  scannedAt: number;
  content: boolean;
  directory: boolean;
  /**
   * Unix epoch datetime in seconds
   */
  contentChangedAt: number;
  hidden: number;
  location: Array<GetAllLibrariesLocation>;
};

export type GetAllLibrariesMediaContainer = {
  size: number;
  allowSync: boolean;
  title1: string;
  directory: Array<GetAllLibrariesDirectory>;
};

/**
 * The libraries available on the Server
 */
export type GetAllLibrariesResponseBody = {
  mediaContainer: GetAllLibrariesMediaContainer;
};

export type GetAllLibrariesResponse = {
  /**
   * 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 libraries available on the Server
   */
  object?: GetAllLibrariesResponseBody | undefined;
};

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

/** @internal */
export type GetAllLibrariesLocation$Outbound = {
  id: number;
  path: string;
};

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

export function getAllLibrariesLocationToJSON(
  getAllLibrariesLocation: GetAllLibrariesLocation,
): string {
  return JSON.stringify(
    GetAllLibrariesLocation$outboundSchema.parse(getAllLibrariesLocation),
  );
}

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

/** @internal */
export const GetAllLibrariesDirectory$inboundSchema: z.ZodType<
  GetAllLibrariesDirectory,
  z.ZodTypeDef,
  unknown
> = z.object({
  allowSync: z.boolean(),
  art: z.string(),
  composite: z.string(),
  filters: z.boolean(),
  refreshing: z.boolean(),
  thumb: z.string(),
  key: z.string(),
  type: z.string(),
  title: z.string(),
  agent: z.string(),
  scanner: z.string(),
  language: z.string(),
  uuid: z.string(),
  updatedAt: z.number().int(),
  createdAt: z.number().int(),
  scannedAt: z.number().int(),
  content: z.boolean(),
  directory: z.boolean(),
  contentChangedAt: z.number().int(),
  hidden: z.number().int(),
  Location: z.array(z.lazy(() => GetAllLibrariesLocation$inboundSchema)),
}).transform((v) => {
  return remap$(v, {
    "Location": "location",
  });
});

/** @internal */
export type GetAllLibrariesDirectory$Outbound = {
  allowSync: boolean;
  art: string;
  composite: string;
  filters: boolean;
  refreshing: boolean;
  thumb: string;
  key: string;
  type: string;
  title: string;
  agent: string;
  scanner: string;
  language: string;
  uuid: string;
  updatedAt: number;
  createdAt: number;
  scannedAt: number;
  content: boolean;
  directory: boolean;
  contentChangedAt: number;
  hidden: number;
  Location: Array<GetAllLibrariesLocation$Outbound>;
};

/** @internal */
export const GetAllLibrariesDirectory$outboundSchema: z.ZodType<
  GetAllLibrariesDirectory$Outbound,
  z.ZodTypeDef,
  GetAllLibrariesDirectory
> = z.object({
  allowSync: z.boolean(),
  art: z.string(),
  composite: z.string(),
  filters: z.boolean(),
  refreshing: z.boolean(),
  thumb: z.string(),
  key: z.string(),
  type: z.string(),
  title: z.string(),
  agent: z.string(),
  scanner: z.string(),
  language: z.string(),
  uuid: z.string(),
  updatedAt: z.number().int(),
  createdAt: z.number().int(),
  scannedAt: z.number().int(),
  content: z.boolean(),
  directory: z.boolean(),
  contentChangedAt: z.number().int(),
  hidden: z.number().int(),
  location: z.array(z.lazy(() => GetAllLibrariesLocation$outboundSchema)),
}).transform((v) => {
  return remap$(v, {
    location: "Location",
  });
});

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

export function getAllLibrariesDirectoryToJSON(
  getAllLibrariesDirectory: GetAllLibrariesDirectory,
): string {
  return JSON.stringify(
    GetAllLibrariesDirectory$outboundSchema.parse(getAllLibrariesDirectory),
  );
}

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

/** @internal */
export const GetAllLibrariesMediaContainer$inboundSchema: z.ZodType<
  GetAllLibrariesMediaContainer,
  z.ZodTypeDef,
  unknown
> = z.object({
  size: z.number().int(),
  allowSync: z.boolean(),
  title1: z.string(),
  Directory: z.array(z.lazy(() => GetAllLibrariesDirectory$inboundSchema)),
}).transform((v) => {
  return remap$(v, {
    "Directory": "directory",
  });
});

/** @internal */
export type GetAllLibrariesMediaContainer$Outbound = {
  size: number;
  allowSync: boolean;
  title1: string;
  Directory: Array<GetAllLibrariesDirectory$Outbound>;
};

/** @internal */
export const GetAllLibrariesMediaContainer$outboundSchema: z.ZodType<
  GetAllLibrariesMediaContainer$Outbound,
  z.ZodTypeDef,
  GetAllLibrariesMediaContainer
> = z.object({
  size: z.number().int(),
  allowSync: z.boolean(),
  title1: z.string(),
  directory: z.array(z.lazy(() => GetAllLibrariesDirectory$outboundSchema)),
}).transform((v) => {
  return remap$(v, {
    directory: "Directory",
  });
});

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

export function getAllLibrariesMediaContainerToJSON(
  getAllLibrariesMediaContainer: GetAllLibrariesMediaContainer,
): string {
  return JSON.stringify(
    GetAllLibrariesMediaContainer$outboundSchema.parse(
      getAllLibrariesMediaContainer,
    ),
  );
}

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

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

/** @internal */
export type GetAllLibrariesResponseBody$Outbound = {
  MediaContainer: GetAllLibrariesMediaContainer$Outbound;
};

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

export function getAllLibrariesResponseBodyToJSON(
  getAllLibrariesResponseBody: GetAllLibrariesResponseBody,
): string {
  return JSON.stringify(
    GetAllLibrariesResponseBody$outboundSchema.parse(
      getAllLibrariesResponseBody,
    ),
  );
}

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

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

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

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

export function getAllLibrariesResponseToJSON(
  getAllLibrariesResponse: GetAllLibrariesResponse,
): string {
  return JSON.stringify(
    GetAllLibrariesResponse$outboundSchema.parse(getAllLibrariesResponse),
  );
}

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