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

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

/**
 * API is healthy
 */
export type HealthCheckResponse = {
  status?: string | undefined;
  timestamp?: Date | undefined;
};

/** @internal */
export const HealthCheckResponse$inboundSchema: z.ZodType<
  HealthCheckResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  status: z.string().optional(),
  timestamp: z.string().datetime({ offset: true }).transform(v => new Date(v))
    .optional(),
});

/** @internal */
export type HealthCheckResponse$Outbound = {
  status?: string | undefined;
  timestamp?: string | undefined;
};

/** @internal */
export const HealthCheckResponse$outboundSchema: z.ZodType<
  HealthCheckResponse$Outbound,
  z.ZodTypeDef,
  HealthCheckResponse
> = z.object({
  status: z.string().optional(),
  timestamp: z.date().transform(v => v.toISOString()).optional(),
});

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

export function healthCheckResponseToJSON(
  healthCheckResponse: HealthCheckResponse,
): string {
  return JSON.stringify(
    HealthCheckResponse$outboundSchema.parse(healthCheckResponse),
  );
}

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