/*
 * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type GetTasksButlerTask = {
  /**
   * A user-friendly description of the task
   */
  description?: string | undefined;
  /**
   * Whether this task is enabled or not
   */
  enabled?: boolean | undefined;
  /**
   * The interval (in days) of when this task is run.  A value of 1 is run every day, 7 is every week, etc.
   */
  interval?: number | undefined;
  /**
   * The name of the task
   */
  name?: string | undefined;
  /**
   * Indicates whether the timing of the task is randomized within the butler interval
   */
  scheduleRandomized?: boolean | undefined;
  /**
   * A user-friendly title of the task
   */
  title?: string | undefined;
};

export type ButlerTasks = {
  butlerTask?: Array<GetTasksButlerTask> | undefined;
};

/**
 * Butler tasks
 */
export type GetTasksResponseBody = {
  butlerTasks?: ButlerTasks | undefined;
};

export type GetTasksResponse = {
  /**
   * 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;
  /**
   * Butler tasks
   */
  object?: GetTasksResponseBody | undefined;
};

/** @internal */
export const GetTasksButlerTask$inboundSchema: z.ZodType<
  GetTasksButlerTask,
  z.ZodTypeDef,
  unknown
> = z.object({
  description: z.string().optional(),
  enabled: z.boolean().optional(),
  interval: z.number().int().optional(),
  name: z.string().optional(),
  scheduleRandomized: z.boolean().optional(),
  title: z.string().optional(),
});

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

/** @internal */
export const ButlerTasks$inboundSchema: z.ZodType<
  ButlerTasks,
  z.ZodTypeDef,
  unknown
> = z.object({
  ButlerTask: z.array(z.lazy(() => GetTasksButlerTask$inboundSchema))
    .optional(),
}).transform((v) => {
  return remap$(v, {
    "ButlerTask": "butlerTask",
  });
});

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

/** @internal */
export const GetTasksResponseBody$inboundSchema: z.ZodType<
  GetTasksResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  ButlerTasks: z.lazy(() => ButlerTasks$inboundSchema).optional(),
}).transform((v) => {
  return remap$(v, {
    "ButlerTasks": "butlerTasks",
  });
});

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

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

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