/*
 * 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 CreateWebInsightsToggleRequestBody = {
  value: boolean;
};

export type CreateWebInsightsToggleRequest = {
  projectId: string;
  requestBody?: CreateWebInsightsToggleRequestBody | undefined;
};

export type CreateWebInsightsToggleResponseBody = {
  value: boolean;
};

/** @internal */
export type CreateWebInsightsToggleRequestBody$Outbound = {
  value: boolean;
};

/** @internal */
export const CreateWebInsightsToggleRequestBody$outboundSchema: z.ZodType<
  CreateWebInsightsToggleRequestBody$Outbound,
  z.ZodTypeDef,
  CreateWebInsightsToggleRequestBody
> = z.object({
  value: z.boolean(),
});

export function createWebInsightsToggleRequestBodyToJSON(
  createWebInsightsToggleRequestBody: CreateWebInsightsToggleRequestBody,
): string {
  return JSON.stringify(
    CreateWebInsightsToggleRequestBody$outboundSchema.parse(
      createWebInsightsToggleRequestBody,
    ),
  );
}

/** @internal */
export type CreateWebInsightsToggleRequest$Outbound = {
  projectId: string;
  RequestBody?: CreateWebInsightsToggleRequestBody$Outbound | undefined;
};

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

export function createWebInsightsToggleRequestToJSON(
  createWebInsightsToggleRequest: CreateWebInsightsToggleRequest,
): string {
  return JSON.stringify(
    CreateWebInsightsToggleRequest$outboundSchema.parse(
      createWebInsightsToggleRequest,
    ),
  );
}

/** @internal */
export const CreateWebInsightsToggleResponseBody$inboundSchema: z.ZodType<
  CreateWebInsightsToggleResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  value: types.boolean(),
});

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