/* * 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 { lazySchema as lazySchema$ } from "../../lib/schemas.js"; import { Currency, Currency$outboundSchema } from "./currency.js"; import { CustomField, CustomField$Outbound, CustomField$outboundSchema, } from "./customfield.js"; import { PassThroughBody, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; export type OpportunityInput = { /** * The title or name of the opportunity. */ title: string; /** * The unique identifier of the primary contact associated with the opportunity. */ primaryContactId?: string | null | undefined; /** * A description of the opportunity. */ description?: string | null | undefined; /** * The type of the opportunity */ type?: string | null | undefined; /** * The monetary value associated with the opportunity */ monetaryAmount?: number | null | undefined; /** * 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; /** * The probability of winning the opportunity, expressed as a percentage. */ winProbability?: number | null | undefined; /** * The actual closing date for the opportunity. If close_date is null, the opportunity is not closed yet. */ closeDate?: Date | null | undefined; /** * The unique identifier of the reason why the opportunity was lost. */ lossReasonId?: string | null | undefined; /** * The reason why the opportunity was lost. */ lossReason?: string | null | undefined; /** * The unique identifier of the reason why the opportunity was won. */ wonReasonId?: string | null | undefined; /** * The reason why the opportunity was won. */ wonReason?: string | null | undefined; /** * The unique identifier of the pipeline associated with the opportunity */ pipelineId?: string | null | undefined; /** * The unique identifier of the stage in the pipeline associated with the opportunity. */ pipelineStageId?: string | null | undefined; /** * The unique identifier of the source of the opportunity. */ sourceId?: string | null | undefined; /** * The unique identifier of the lead associated with the opportunity. */ leadId?: string | null | undefined; /** * The source of the lead associated with the opportunity. */ leadSource?: string | null | undefined; /** * The unique identifier of the contact associated with the opportunity. */ contactId?: string | null | undefined; /** * An array of unique identifiers of all contacts associated with the opportunity. */ contactIds?: Array | undefined; /** * The unique identifier of the company associated with the opportunity. */ companyId?: string | null | undefined; /** * The name of the company associated with the opportunity. */ companyName?: string | null | undefined; /** * The unique identifier of the user who owns the opportunity. */ ownerId?: string | null | undefined; /** * The priority level of the opportunity. */ priority?: string | null | undefined; /** * The current status of the opportunity. */ status?: string | null | undefined; /** * The unique identifier of the current status of the opportunity. */ statusId?: string | null | undefined; tags?: Array | null | undefined; customFields?: Array | undefined; /** * The date and time when the stage of the opportunity was last changed. */ stageLastChangedAt?: 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 type OpportunityInput$Outbound = { title: string; primary_contact_id?: string | null | undefined; description?: string | null | undefined; type?: string | null | undefined; monetary_amount?: number | null | undefined; currency?: string | null | undefined; win_probability?: number | null | undefined; close_date?: string | null | undefined; loss_reason_id?: string | null | undefined; loss_reason?: string | null | undefined; won_reason_id?: string | null | undefined; won_reason?: string | null | undefined; pipeline_id?: string | null | undefined; pipeline_stage_id?: string | null | undefined; source_id?: string | null | undefined; lead_id?: string | null | undefined; lead_source?: string | null | undefined; contact_id?: string | null | undefined; contact_ids?: Array | undefined; company_id?: string | null | undefined; company_name?: string | null | undefined; owner_id?: string | null | undefined; priority?: string | null | undefined; status?: string | null | undefined; status_id?: string | null | undefined; tags?: Array | null | undefined; custom_fields?: Array | undefined; stage_last_changed_at?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const OpportunityInput$outboundSchema: z.ZodType< OpportunityInput$Outbound, z.ZodTypeDef, OpportunityInput > = /* @__PURE__ */ lazySchema$(() => z.object({ title: z.string(), primaryContactId: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), type: z.nullable(z.string()).optional(), monetaryAmount: z.nullable(z.number()).optional(), currency: z.nullable(Currency$outboundSchema).optional(), winProbability: z.nullable(z.number()).optional(), closeDate: z.nullable( z.date().transform(v => v.toISOString().slice(0, "YYYY-MM-DD".length)), ).optional(), lossReasonId: z.nullable(z.string()).optional(), lossReason: z.nullable(z.string()).optional(), wonReasonId: z.nullable(z.string()).optional(), wonReason: z.nullable(z.string()).optional(), pipelineId: z.nullable(z.string()).optional(), pipelineStageId: z.nullable(z.string()).optional(), sourceId: z.nullable(z.string()).optional(), leadId: z.nullable(z.string()).optional(), leadSource: z.nullable(z.string()).optional(), contactId: z.nullable(z.string()).optional(), contactIds: z.array(z.string()).optional(), companyId: z.nullable(z.string()).optional(), companyName: z.nullable(z.string()).optional(), ownerId: z.nullable(z.string()).optional(), priority: z.nullable(z.string()).optional(), status: z.nullable(z.string()).optional(), statusId: z.nullable(z.string()).optional(), tags: z.nullable(z.array(z.string())).optional(), customFields: z.array(CustomField$outboundSchema).optional(), stageLastChangedAt: z.nullable(z.date().transform(v => v.toISOString())) .optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { primaryContactId: "primary_contact_id", monetaryAmount: "monetary_amount", winProbability: "win_probability", closeDate: "close_date", lossReasonId: "loss_reason_id", lossReason: "loss_reason", wonReasonId: "won_reason_id", wonReason: "won_reason", pipelineId: "pipeline_id", pipelineStageId: "pipeline_stage_id", sourceId: "source_id", leadId: "lead_id", leadSource: "lead_source", contactId: "contact_id", contactIds: "contact_ids", companyId: "company_id", companyName: "company_name", ownerId: "owner_id", statusId: "status_id", customFields: "custom_fields", stageLastChangedAt: "stage_last_changed_at", passThrough: "pass_through", }); }) ); export function opportunityInputToJSON( opportunityInput: OpportunityInput, ): string { return JSON.stringify( OpportunityInput$outboundSchema.parse(opportunityInput), ); }