/* * 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"; import { Currency, Currency$inboundSchema, Currency$outboundSchema, } from "./currency.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; export type Stages = { /** * The unique identifier of the Pipeline Stage. */ id?: string | null | undefined; /** * The name of the Pipeline Stage. */ name?: string | null | undefined; /** * The value of the Pipeline Stage. */ value?: string | null | undefined; /** * The expected probability of winning an Opportunity in this Pipeline Stage. Valid values are [0-100]. */ winProbability?: number | null | undefined; /** * The order in which the Pipeline Stage is displayed in the UI. */ displayOrder?: number | null | undefined; }; export type Pipeline = { /** * The unique identifier of the Pipeline. */ id?: string | undefined; /** * The name of the Pipeline. */ name: string; /** * Indicates the associated currency for an amount of money. Values correspond to [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217). */ currency?: Currency | null | undefined; /** * Whether the Pipeline is archived or not. */ archived?: boolean | undefined; /** * Whether the Pipeline is active or not. */ active?: boolean | undefined; /** * The order in which the Pipeline is displayed in the UI. */ displayOrder?: number | null | undefined; /** * Whether the Pipeline has win probability enabled or not. */ winProbabilityEnabled?: boolean | undefined; /** * The Pipeline Stages. */ stages?: Array | undefined; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; /** * The date and time when the object was created. */ createdAt?: Date | null | undefined; /** * The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. */ passThrough?: Array | undefined; }; /** @internal */ export const Stages$inboundSchema: z.ZodType = z .object({ id: z.nullable(z.string()).optional(), name: z.nullable(z.string()).optional(), value: z.nullable(z.string()).optional(), win_probability: z.nullable(z.number().int()).optional(), display_order: z.nullable(z.number().int()).optional(), }).transform((v) => { return remap$(v, { "win_probability": "winProbability", "display_order": "displayOrder", }); }); /** @internal */ export type Stages$Outbound = { id?: string | null | undefined; name?: string | null | undefined; value?: string | null | undefined; win_probability?: number | null | undefined; display_order?: number | null | undefined; }; /** @internal */ export const Stages$outboundSchema: z.ZodType< Stages$Outbound, z.ZodTypeDef, Stages > = z.object({ id: z.nullable(z.string()).optional(), name: z.nullable(z.string()).optional(), value: z.nullable(z.string()).optional(), winProbability: z.nullable(z.number().int()).optional(), displayOrder: z.nullable(z.number().int()).optional(), }).transform((v) => { return remap$(v, { winProbability: "win_probability", displayOrder: "display_order", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Stages$ { /** @deprecated use `Stages$inboundSchema` instead. */ export const inboundSchema = Stages$inboundSchema; /** @deprecated use `Stages$outboundSchema` instead. */ export const outboundSchema = Stages$outboundSchema; /** @deprecated use `Stages$Outbound` instead. */ export type Outbound = Stages$Outbound; } export function stagesToJSON(stages: Stages): string { return JSON.stringify(Stages$outboundSchema.parse(stages)); } export function stagesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Stages$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Stages' from JSON`, ); } /** @internal */ export const Pipeline$inboundSchema: z.ZodType< Pipeline, z.ZodTypeDef, unknown > = z.object({ id: z.string().optional(), name: z.string(), currency: z.nullable(Currency$inboundSchema).optional(), archived: z.boolean().optional(), active: z.boolean().optional(), display_order: z.nullable(z.number().int()).optional(), win_probability_enabled: z.boolean().optional(), stages: z.array(z.lazy(() => Stages$inboundSchema)).optional(), updated_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), created_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), pass_through: z.array(PassThroughBody$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "display_order": "displayOrder", "win_probability_enabled": "winProbabilityEnabled", "updated_at": "updatedAt", "created_at": "createdAt", "pass_through": "passThrough", }); }); /** @internal */ export type Pipeline$Outbound = { id?: string | undefined; name: string; currency?: string | null | undefined; archived?: boolean | undefined; active?: boolean | undefined; display_order?: number | null | undefined; win_probability_enabled?: boolean | undefined; stages?: Array | undefined; updated_at?: string | null | undefined; created_at?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const Pipeline$outboundSchema: z.ZodType< Pipeline$Outbound, z.ZodTypeDef, Pipeline > = z.object({ id: z.string().optional(), name: z.string(), currency: z.nullable(Currency$outboundSchema).optional(), archived: z.boolean().optional(), active: z.boolean().optional(), displayOrder: z.nullable(z.number().int()).optional(), winProbabilityEnabled: z.boolean().optional(), stages: z.array(z.lazy(() => Stages$outboundSchema)).optional(), updatedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), createdAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { displayOrder: "display_order", winProbabilityEnabled: "win_probability_enabled", updatedAt: "updated_at", createdAt: "created_at", passThrough: "pass_through", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Pipeline$ { /** @deprecated use `Pipeline$inboundSchema` instead. */ export const inboundSchema = Pipeline$inboundSchema; /** @deprecated use `Pipeline$outboundSchema` instead. */ export const outboundSchema = Pipeline$outboundSchema; /** @deprecated use `Pipeline$Outbound` instead. */ export type Outbound = Pipeline$Outbound; } export function pipelineToJSON(pipeline: Pipeline): string { return JSON.stringify(Pipeline$outboundSchema.parse(pipeline)); } export function pipelineFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Pipeline$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Pipeline' from JSON`, ); }