/* * 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 { RFCDate } from "../../types/rfcdate.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Currency, Currency$inboundSchema, Currency$outboundSchema, } from "./currency.js"; import { CustomField, CustomField$inboundSchema, CustomField$Outbound, CustomField$outboundSchema, } from "./customfield.js"; import { PassThroughBody, PassThroughBody$inboundSchema, 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; /** * 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?: RFCDate | 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 const OpportunityInput$inboundSchema: z.ZodType< OpportunityInput, z.ZodTypeDef, unknown > = z.object({ title: z.string(), primary_contact_id: z.nullable(z.string()), description: z.nullable(z.string()).optional(), type: z.nullable(z.string()).optional(), monetary_amount: z.nullable(z.number()).optional(), currency: z.nullable(Currency$inboundSchema).optional(), win_probability: z.nullable(z.number()).optional(), close_date: z.nullable(z.string().transform(v => new RFCDate(v))).optional(), loss_reason_id: z.nullable(z.string()).optional(), loss_reason: z.nullable(z.string()).optional(), won_reason_id: z.nullable(z.string()).optional(), won_reason: z.nullable(z.string()).optional(), pipeline_id: z.nullable(z.string()).optional(), pipeline_stage_id: z.nullable(z.string()).optional(), source_id: z.nullable(z.string()).optional(), lead_id: z.nullable(z.string()).optional(), lead_source: z.nullable(z.string()).optional(), contact_id: z.nullable(z.string()).optional(), contact_ids: z.array(z.string()).optional(), company_id: z.nullable(z.string()).optional(), company_name: z.nullable(z.string()).optional(), owner_id: z.nullable(z.string()).optional(), priority: z.nullable(z.string()).optional(), status: z.nullable(z.string()).optional(), status_id: z.nullable(z.string()).optional(), tags: z.nullable(z.array(z.string())).optional(), custom_fields: z.array(CustomField$inboundSchema).optional(), stage_last_changed_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, { "primary_contact_id": "primaryContactId", "monetary_amount": "monetaryAmount", "win_probability": "winProbability", "close_date": "closeDate", "loss_reason_id": "lossReasonId", "loss_reason": "lossReason", "won_reason_id": "wonReasonId", "won_reason": "wonReason", "pipeline_id": "pipelineId", "pipeline_stage_id": "pipelineStageId", "source_id": "sourceId", "lead_id": "leadId", "lead_source": "leadSource", "contact_id": "contactId", "contact_ids": "contactIds", "company_id": "companyId", "company_name": "companyName", "owner_id": "ownerId", "status_id": "statusId", "custom_fields": "customFields", "stage_last_changed_at": "stageLastChangedAt", "pass_through": "passThrough", }); }); /** @internal */ export type OpportunityInput$Outbound = { title: string; primary_contact_id: string | null; 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 > = z.object({ title: z.string(), primaryContactId: z.nullable(z.string()), 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.instanceof(RFCDate).transform(v => v.toString())) .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", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OpportunityInput$ { /** @deprecated use `OpportunityInput$inboundSchema` instead. */ export const inboundSchema = OpportunityInput$inboundSchema; /** @deprecated use `OpportunityInput$outboundSchema` instead. */ export const outboundSchema = OpportunityInput$outboundSchema; /** @deprecated use `OpportunityInput$Outbound` instead. */ export type Outbound = OpportunityInput$Outbound; } export function opportunityInputToJSON( opportunityInput: OpportunityInput, ): string { return JSON.stringify( OpportunityInput$outboundSchema.parse(opportunityInput), ); } export function opportunityInputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OpportunityInput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OpportunityInput' from JSON`, ); }