/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { PreferenceLevelEnum, PreferenceLevelEnum$inboundSchema, } from "./preferencelevelenum.js"; import { SeverityLevelEnum, SeverityLevelEnum$inboundSchema, } from "./severitylevelenum.js"; import { SubscriberPreferenceChannels, SubscriberPreferenceChannels$inboundSchema, } from "./subscriberpreferencechannels.js"; /** * Custom data associated with the workflow */ export type GetPreferencesResponseDtoData = {}; /** * Workflow information if this is a template-level preference */ export type Workflow = { /** * Unique identifier of the workflow */ id: string; /** * Workflow identifier used for triggering */ identifier: string; /** * Human-readable name of the workflow */ name: string; /** * Whether this workflow is marked as critical */ critical: boolean; /** * Tags associated with the workflow */ tags?: Array | undefined; /** * Custom data associated with the workflow */ data?: GetPreferencesResponseDtoData | undefined; /** * Severity of the workflow */ severity: SeverityLevelEnum; }; /** * Condition using JSON Logic rules */ export type Condition = {}; export type GetPreferencesResponseDto = { /** * The level of the preference (global or template) */ level: PreferenceLevelEnum; /** * Workflow information if this is a template-level preference */ workflow?: Workflow | null | undefined; /** * Whether the preference is enabled */ enabled: boolean; /** * Channel-specific preference settings */ channels: SubscriberPreferenceChannels; /** * Condition using JSON Logic rules */ condition?: Condition | null | undefined; }; /** @internal */ export const GetPreferencesResponseDtoData$inboundSchema: z.ZodType< GetPreferencesResponseDtoData, z.ZodTypeDef, unknown > = z.object({}); export function getPreferencesResponseDtoDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetPreferencesResponseDtoData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetPreferencesResponseDtoData' from JSON`, ); } /** @internal */ export const Workflow$inboundSchema: z.ZodType< Workflow, z.ZodTypeDef, unknown > = z.object({ id: z.string(), identifier: z.string(), name: z.string(), critical: z.boolean(), tags: z.array(z.string()).optional(), data: z.lazy(() => GetPreferencesResponseDtoData$inboundSchema).optional(), severity: SeverityLevelEnum$inboundSchema, }); export function workflowFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Workflow$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Workflow' from JSON`, ); } /** @internal */ export const Condition$inboundSchema: z.ZodType< Condition, z.ZodTypeDef, unknown > = z.object({}); export function conditionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Condition$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Condition' from JSON`, ); } /** @internal */ export const GetPreferencesResponseDto$inboundSchema: z.ZodType< GetPreferencesResponseDto, z.ZodTypeDef, unknown > = z.object({ level: PreferenceLevelEnum$inboundSchema, workflow: z.nullable(z.lazy(() => Workflow$inboundSchema)).optional(), enabled: z.boolean(), channels: SubscriberPreferenceChannels$inboundSchema, condition: z.nullable(z.lazy(() => Condition$inboundSchema)).optional(), }); export function getPreferencesResponseDtoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetPreferencesResponseDto$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetPreferencesResponseDto' from JSON`, ); }