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

import * as z from "zod/v3";
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";
import {
  ChannelMapping,
  ChannelMapping$inboundSchema,
} from "./channelmapping.js";

export type Device = {
  channelMapping?: Array<ChannelMapping> | undefined;
  key?: string | undefined;
  lastSeenAt?: number | undefined;
  make?: string | undefined;
  model?: string | undefined;
  modelNumber?: string | undefined;
  protocol?: string | undefined;
  sources?: string | undefined;
  state?: string | undefined;
  status?: string | undefined;
  tuners?: string | undefined;
  uri?: string | undefined;
  uuid?: string | undefined;
};

/** @internal */
export const Device$inboundSchema: z.ZodType<Device, z.ZodTypeDef, unknown> = z
  .object({
    ChannelMapping: z.array(ChannelMapping$inboundSchema).optional(),
    key: z.string().optional(),
    lastSeenAt: z.number().int().optional(),
    make: z.string().optional(),
    model: z.string().optional(),
    modelNumber: z.string().optional(),
    protocol: z.string().optional(),
    sources: z.string().optional(),
    state: z.string().optional(),
    status: z.string().optional(),
    tuners: z.string().optional(),
    uri: z.string().optional(),
    uuid: z.string().optional(),
  }).transform((v) => {
    return remap$(v, {
      "ChannelMapping": "channelMapping",
    });
  });

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