/*
 * 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 UpdatePlayProgressRequest = {
  /**
   * the media key
   */
  key: string;
  /**
   * The time, in milliseconds, used to set the media playback progress.
   */
  time: number;
  /**
   * The playback state of the media item.
   */
  state: string;
};

export type UpdatePlayProgressResponse = {
  /**
   * 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 UpdatePlayProgressRequest$inboundSchema: z.ZodType<
  UpdatePlayProgressRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  key: z.string(),
  time: z.number(),
  state: z.string(),
});

/** @internal */
export type UpdatePlayProgressRequest$Outbound = {
  key: string;
  time: number;
  state: string;
};

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

export function updatePlayProgressRequestToJSON(
  updatePlayProgressRequest: UpdatePlayProgressRequest,
): string {
  return JSON.stringify(
    UpdatePlayProgressRequest$outboundSchema.parse(updatePlayProgressRequest),
  );
}

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

/** @internal */
export const UpdatePlayProgressResponse$inboundSchema: z.ZodType<
  UpdatePlayProgressResponse,
  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 UpdatePlayProgressResponse$Outbound = {
  ContentType: string;
  StatusCode: number;
  RawResponse: never;
};

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

export function updatePlayProgressResponseToJSON(
  updatePlayProgressResponse: UpdatePlayProgressResponse,
): string {
  return JSON.stringify(
    UpdatePlayProgressResponse$outboundSchema.parse(updatePlayProgressResponse),
  );
}

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