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

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

export type ScheduleInterval = {
  every: string;
  offset?: string | null | undefined;
};

/** @internal */
export const ScheduleInterval$inboundSchema: z.ZodType<
  ScheduleInterval,
  unknown
> = z.object({
  every: z.string(),
  offset: z.nullable(z.string()).optional(),
});
/** @internal */
export type ScheduleInterval$Outbound = {
  every: string;
  offset?: string | null | undefined;
};

/** @internal */
export const ScheduleInterval$outboundSchema: z.ZodType<
  ScheduleInterval$Outbound,
  ScheduleInterval
> = z.object({
  every: z.string(),
  offset: z.nullable(z.string()).optional(),
});

export function scheduleIntervalToJSON(
  scheduleInterval: ScheduleInterval,
): string {
  return JSON.stringify(
    ScheduleInterval$outboundSchema.parse(scheduleInterval),
  );
}
export function scheduleIntervalFromJSON(
  jsonString: string,
): SafeParseResult<ScheduleInterval, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ScheduleInterval$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ScheduleInterval' from JSON`,
  );
}
