/*
 * 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 GetFeatureFlagRequest = {
  /**
   * The project key
   */
  projectKey: string;
  /**
   * The feature flag key
   */
  featureFlagKey: string;
  /**
   * Filter configurations by environment
   */
  env?: string | undefined;
  /**
   * A comma-separated list of fields to expand in the response. Supported fields are explained above.
   */
  expand?: string | undefined;
};

/** @internal */
export const GetFeatureFlagRequest$inboundSchema: z.ZodType<
  GetFeatureFlagRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  projectKey: z.string(),
  featureFlagKey: z.string(),
  env: z.string().optional(),
  expand: z.string().optional(),
});
/** @internal */
export type GetFeatureFlagRequest$Outbound = {
  projectKey: string;
  featureFlagKey: string;
  env?: string | undefined;
  expand?: string | undefined;
};

/** @internal */
export const GetFeatureFlagRequest$outboundSchema: z.ZodType<
  GetFeatureFlagRequest$Outbound,
  z.ZodTypeDef,
  GetFeatureFlagRequest
> = z.object({
  projectKey: z.string(),
  featureFlagKey: z.string(),
  env: z.string().optional(),
  expand: z.string().optional(),
});

export function getFeatureFlagRequestToJSON(
  getFeatureFlagRequest: GetFeatureFlagRequest,
): string {
  return JSON.stringify(
    GetFeatureFlagRequest$outboundSchema.parse(getFeatureFlagRequest),
  );
}
export function getFeatureFlagRequestFromJSON(
  jsonString: string,
): SafeParseResult<GetFeatureFlagRequest, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GetFeatureFlagRequest$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GetFeatureFlagRequest' from JSON`,
  );
}
