/*
 * 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 * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

export type BatchRemoveProjectEnvRequestBody = {
  /**
   * Array of environment variable IDs to delete
   */
  ids: Array<string>;
};

export type BatchRemoveProjectEnvRequest = {
  /**
   * The unique project identifier or the project name
   */
  idOrName: string;
  /**
   * The Team identifier to perform the request on behalf of.
   */
  teamId?: string | undefined;
  /**
   * The Team slug to perform the request on behalf of.
   */
  slug?: string | undefined;
  requestBody?: BatchRemoveProjectEnvRequestBody | undefined;
};

export type BatchRemoveProjectEnvResponseBody = {
  deleted: number;
  ids: Array<string>;
};

/** @internal */
export type BatchRemoveProjectEnvRequestBody$Outbound = {
  ids: Array<string>;
};

/** @internal */
export const BatchRemoveProjectEnvRequestBody$outboundSchema: z.ZodType<
  BatchRemoveProjectEnvRequestBody$Outbound,
  z.ZodTypeDef,
  BatchRemoveProjectEnvRequestBody
> = z.object({
  ids: z.array(z.string()),
});

export function batchRemoveProjectEnvRequestBodyToJSON(
  batchRemoveProjectEnvRequestBody: BatchRemoveProjectEnvRequestBody,
): string {
  return JSON.stringify(
    BatchRemoveProjectEnvRequestBody$outboundSchema.parse(
      batchRemoveProjectEnvRequestBody,
    ),
  );
}

/** @internal */
export type BatchRemoveProjectEnvRequest$Outbound = {
  idOrName: string;
  teamId?: string | undefined;
  slug?: string | undefined;
  RequestBody?: BatchRemoveProjectEnvRequestBody$Outbound | undefined;
};

/** @internal */
export const BatchRemoveProjectEnvRequest$outboundSchema: z.ZodType<
  BatchRemoveProjectEnvRequest$Outbound,
  z.ZodTypeDef,
  BatchRemoveProjectEnvRequest
> = z.object({
  idOrName: z.string(),
  teamId: z.string().optional(),
  slug: z.string().optional(),
  requestBody: z.lazy(() => BatchRemoveProjectEnvRequestBody$outboundSchema)
    .optional(),
}).transform((v) => {
  return remap$(v, {
    requestBody: "RequestBody",
  });
});

export function batchRemoveProjectEnvRequestToJSON(
  batchRemoveProjectEnvRequest: BatchRemoveProjectEnvRequest,
): string {
  return JSON.stringify(
    BatchRemoveProjectEnvRequest$outboundSchema.parse(
      batchRemoveProjectEnvRequest,
    ),
  );
}

/** @internal */
export const BatchRemoveProjectEnvResponseBody$inboundSchema: z.ZodType<
  BatchRemoveProjectEnvResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  deleted: types.number(),
  ids: z.array(types.string()),
});

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