/* * 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 { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The status of the time off request. */ export const EmbeddedTimeOffRequestStatus = { Pending: "pending", Approved: "approved", Declined: "declined", Consumed: "consumed", } as const; /** * The status of the time off request. */ export type EmbeddedTimeOffRequestStatus = ClosedEnum< typeof EmbeddedTimeOffRequestStatus >; export type EmbeddedTimeOffRequestEmployee = { /** * The UUID of the employee the time off request is for. */ uuid?: string | undefined; /** * The full name of the employee the time off request is for. */ fullName?: string | undefined; }; export type Initiator = { /** * The UUID of the employee who initiated the time off request. */ uuid?: string | undefined; /** * The full name of the employee who initiated the time off request. */ fullName?: string | undefined; }; /** * This value will be null if the request has not been approved. */ export type Approver = { /** * The UUID of the employee who approved the time off request. */ uuid?: string | undefined; /** * The full name of the employee who approved the time off request. */ fullName?: string | undefined; }; /** * The representation of a time off request. */ export type EmbeddedTimeOffRequest = { /** * The UUID of the time off request. */ uuid: string; /** * The status of the time off request. */ status: EmbeddedTimeOffRequestStatus; /** * A note about the time off request, from the employee to the employer. */ employeeNote: string | null; /** * A note about the time off request, from the employer to the employee. */ employerNote: string | null; /** * The type of the time off policy (e.g. vacation, sick). */ policyType: string | null; /** * The UUID of the time off policy associated with this request. */ policyUuid: string | null; /** * An object where keys are dates in YYYY-MM-DD format and values are hours as string decimals (e.g. {"2025-01-20": "8.000"}). */ days: { [k: string]: string }; employee: EmbeddedTimeOffRequestEmployee; initiator: Initiator | null; /** * This value will be null if the request has not been approved. */ approver: Approver | null; }; /** @internal */ export const EmbeddedTimeOffRequestStatus$inboundSchema: z.ZodNativeEnum< typeof EmbeddedTimeOffRequestStatus > = z.nativeEnum(EmbeddedTimeOffRequestStatus); /** @internal */ export const EmbeddedTimeOffRequestEmployee$inboundSchema: z.ZodType< EmbeddedTimeOffRequestEmployee, z.ZodTypeDef, unknown > = z.object({ uuid: z.string().optional(), full_name: z.string().optional(), }).transform((v) => { return remap$(v, { "full_name": "fullName", }); }); export function embeddedTimeOffRequestEmployeeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EmbeddedTimeOffRequestEmployee$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EmbeddedTimeOffRequestEmployee' from JSON`, ); } /** @internal */ export const Initiator$inboundSchema: z.ZodType< Initiator, z.ZodTypeDef, unknown > = z.object({ uuid: z.string().optional(), full_name: z.string().optional(), }).transform((v) => { return remap$(v, { "full_name": "fullName", }); }); export function initiatorFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Initiator$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Initiator' from JSON`, ); } /** @internal */ export const Approver$inboundSchema: z.ZodType< Approver, z.ZodTypeDef, unknown > = z.object({ uuid: z.string().optional(), full_name: z.string().optional(), }).transform((v) => { return remap$(v, { "full_name": "fullName", }); }); export function approverFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Approver$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Approver' from JSON`, ); } /** @internal */ export const EmbeddedTimeOffRequest$inboundSchema: z.ZodType< EmbeddedTimeOffRequest, z.ZodTypeDef, unknown > = z.object({ uuid: z.string(), status: EmbeddedTimeOffRequestStatus$inboundSchema, employee_note: z.nullable(z.string()), employer_note: z.nullable(z.string()), policy_type: z.nullable(z.string()), policy_uuid: z.nullable(z.string()), days: z.record(z.string()), employee: z.lazy(() => EmbeddedTimeOffRequestEmployee$inboundSchema), initiator: z.nullable(z.lazy(() => Initiator$inboundSchema)), approver: z.nullable(z.lazy(() => Approver$inboundSchema)), }).transform((v) => { return remap$(v, { "employee_note": "employeeNote", "employer_note": "employerNote", "policy_type": "policyType", "policy_uuid": "policyUuid", }); }); export function embeddedTimeOffRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EmbeddedTimeOffRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EmbeddedTimeOffRequest' from JSON`, ); }