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

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

/**
 * Indicate that you want to start download any updates found.
 */
export enum Download {
  Zero = 0,
  One = 1,
}

export type CheckForUpdatesRequest = {
  /**
   * Indicate that you want to start download any updates found.
   */
  download?: Download | undefined;
};

export type CheckForUpdatesResponse = {
  /**
   * HTTP response content type for this operation
   */
  contentType: string;
  /**
   * HTTP response status code for this operation
   */
  statusCode: number;
  /**
   * Raw HTTP response; suitable for custom response parsing
   */
  rawResponse: Response;
};

/** @internal */
export const Download$inboundSchema: z.ZodNativeEnum<typeof Download> = z
  .nativeEnum(Download);

/** @internal */
export const Download$outboundSchema: z.ZodNativeEnum<typeof Download> =
  Download$inboundSchema;

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace Download$ {
  /** @deprecated use `Download$inboundSchema` instead. */
  export const inboundSchema = Download$inboundSchema;
  /** @deprecated use `Download$outboundSchema` instead. */
  export const outboundSchema = Download$outboundSchema;
}

/** @internal */
export const CheckForUpdatesRequest$inboundSchema: z.ZodType<
  CheckForUpdatesRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  download: Download$inboundSchema.optional(),
});

/** @internal */
export type CheckForUpdatesRequest$Outbound = {
  download?: number | undefined;
};

/** @internal */
export const CheckForUpdatesRequest$outboundSchema: z.ZodType<
  CheckForUpdatesRequest$Outbound,
  z.ZodTypeDef,
  CheckForUpdatesRequest
> = z.object({
  download: Download$outboundSchema.optional(),
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace CheckForUpdatesRequest$ {
  /** @deprecated use `CheckForUpdatesRequest$inboundSchema` instead. */
  export const inboundSchema = CheckForUpdatesRequest$inboundSchema;
  /** @deprecated use `CheckForUpdatesRequest$outboundSchema` instead. */
  export const outboundSchema = CheckForUpdatesRequest$outboundSchema;
  /** @deprecated use `CheckForUpdatesRequest$Outbound` instead. */
  export type Outbound = CheckForUpdatesRequest$Outbound;
}

export function checkForUpdatesRequestToJSON(
  checkForUpdatesRequest: CheckForUpdatesRequest,
): string {
  return JSON.stringify(
    CheckForUpdatesRequest$outboundSchema.parse(checkForUpdatesRequest),
  );
}

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

/** @internal */
export const CheckForUpdatesResponse$inboundSchema: z.ZodType<
  CheckForUpdatesResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  ContentType: z.string(),
  StatusCode: z.number().int(),
  RawResponse: z.instanceof(Response),
}).transform((v) => {
  return remap$(v, {
    "ContentType": "contentType",
    "StatusCode": "statusCode",
    "RawResponse": "rawResponse",
  });
});

/** @internal */
export type CheckForUpdatesResponse$Outbound = {
  ContentType: string;
  StatusCode: number;
  RawResponse: never;
};

/** @internal */
export const CheckForUpdatesResponse$outboundSchema: z.ZodType<
  CheckForUpdatesResponse$Outbound,
  z.ZodTypeDef,
  CheckForUpdatesResponse
> = z.object({
  contentType: z.string(),
  statusCode: z.number().int(),
  rawResponse: z.instanceof(Response).transform(() => {
    throw new Error("Response cannot be serialized");
  }),
}).transform((v) => {
  return remap$(v, {
    contentType: "ContentType",
    statusCode: "StatusCode",
    rawResponse: "RawResponse",
  });
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace CheckForUpdatesResponse$ {
  /** @deprecated use `CheckForUpdatesResponse$inboundSchema` instead. */
  export const inboundSchema = CheckForUpdatesResponse$inboundSchema;
  /** @deprecated use `CheckForUpdatesResponse$outboundSchema` instead. */
  export const outboundSchema = CheckForUpdatesResponse$outboundSchema;
  /** @deprecated use `CheckForUpdatesResponse$Outbound` instead. */
  export type Outbound = CheckForUpdatesResponse$Outbound;
}

export function checkForUpdatesResponseToJSON(
  checkForUpdatesResponse: CheckForUpdatesResponse,
): string {
  return JSON.stringify(
    CheckForUpdatesResponse$outboundSchema.parse(checkForUpdatesResponse),
  );
}

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