/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { safeParse } from "../../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

/**
 * The location of the client
 */
export enum SessionLocation {
  Lan = "lan",
  Wan = "wan",
}

/**
 * Information about the playback session
 */
export type Session = {
  /**
   * The bandwidth used by this client's playback in kbps
   */
  bandwidth?: number | undefined;
  /**
   * The id of the playback session
   */
  id?: string | undefined;
  /**
   * The location of the client
   */
  location?: SessionLocation | undefined;
};

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

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

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