/*
 * 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";

/**
 * The state of the media item
 */
export enum State {
  Playing = "playing",
  Paused = "paused",
  Stopped = "stopped",
}

export type GetTimelineRequest = {
  /**
   * The rating key of the media item
   */
  ratingKey: number;
  /**
   * The key of the media item to get the timeline for
   */
  key: string;
  /**
   * The state of the media item
   */
  state: State;
  /**
   * Whether the media item has MDE
   */
  hasMDE: number;
  /**
   * The time of the media item
   */
  time: number;
  /**
   * The duration of the media item
   */
  duration: number;
  /**
   * The context of the media item
   */
  context: string;
  /**
   * The play queue item ID of the media item
   */
  playQueueItemID: number;
  /**
   * The playback time of the media item
   */
  playBackTime: number;
  /**
   * The row of the media item
   */
  row: number;
};

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

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

/** @internal */
export const State$outboundSchema: z.ZodNativeEnum<typeof State> =
  State$inboundSchema;

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

/** @internal */
export const GetTimelineRequest$inboundSchema: z.ZodType<
  GetTimelineRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  ratingKey: z.number(),
  key: z.string(),
  state: State$inboundSchema,
  hasMDE: z.number(),
  time: z.number(),
  duration: z.number(),
  context: z.string(),
  playQueueItemID: z.number(),
  playBackTime: z.number(),
  row: z.number(),
});

/** @internal */
export type GetTimelineRequest$Outbound = {
  ratingKey: number;
  key: string;
  state: string;
  hasMDE: number;
  time: number;
  duration: number;
  context: string;
  playQueueItemID: number;
  playBackTime: number;
  row: number;
};

/** @internal */
export const GetTimelineRequest$outboundSchema: z.ZodType<
  GetTimelineRequest$Outbound,
  z.ZodTypeDef,
  GetTimelineRequest
> = z.object({
  ratingKey: z.number(),
  key: z.string(),
  state: State$outboundSchema,
  hasMDE: z.number(),
  time: z.number(),
  duration: z.number(),
  context: z.string(),
  playQueueItemID: z.number(),
  playBackTime: z.number(),
  row: z.number(),
});

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

export function getTimelineRequestToJSON(
  getTimelineRequest: GetTimelineRequest,
): string {
  return JSON.stringify(
    GetTimelineRequest$outboundSchema.parse(getTimelineRequest),
  );
}

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

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

/** @internal */
export type GetTimelineResponse$Outbound = {
  ContentType: string;
  StatusCode: number;
  RawResponse: never;
};

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

export function getTimelineResponseToJSON(
  getTimelineResponse: GetTimelineResponse,
): string {
  return JSON.stringify(
    GetTimelineResponse$outboundSchema.parse(getTimelineResponse),
  );
}

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