/*
 * 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";

export type StaleFlagData = {
  /**
   * Whether the flag is ready for code removal
   */
  readyForCodeRemoval?: boolean | undefined;
  /**
   * Whether the flag is ready to be archived
   */
  readyToArchive?: boolean | undefined;
  /**
   * If a third-party system helps clean up the flag, the ID from that system
   */
  cleanupId?: string | undefined;
};

/** @internal */
export const StaleFlagData$inboundSchema: z.ZodType<
  StaleFlagData,
  z.ZodTypeDef,
  unknown
> = z.object({
  readyForCodeRemoval: z.boolean().optional(),
  readyToArchive: z.boolean().optional(),
  cleanupId: z.string().optional(),
});
/** @internal */
export type StaleFlagData$Outbound = {
  readyForCodeRemoval?: boolean | undefined;
  readyToArchive?: boolean | undefined;
  cleanupId?: string | undefined;
};

/** @internal */
export const StaleFlagData$outboundSchema: z.ZodType<
  StaleFlagData$Outbound,
  z.ZodTypeDef,
  StaleFlagData
> = z.object({
  readyForCodeRemoval: z.boolean().optional(),
  readyToArchive: z.boolean().optional(),
  cleanupId: z.string().optional(),
});

export function staleFlagDataToJSON(staleFlagData: StaleFlagData): string {
  return JSON.stringify(StaleFlagData$outboundSchema.parse(staleFlagData));
}
export function staleFlagDataFromJSON(
  jsonString: string,
): SafeParseResult<StaleFlagData, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => StaleFlagData$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'StaleFlagData' from JSON`,
  );
}
