/* * 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$, safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Currency, Currency$inboundSchema } from "./currency.js"; import { CustomField, CustomField$inboundSchema } from "./customfield.js"; import { PassThroughBody, PassThroughBody$inboundSchema, } from "./passthroughbody.js"; export type Opportunity = { /** * A unique identifier for the opportunity. */ id?: string | undefined; /** * 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 expected revenue from the opportunity */ expectedRevenue?: 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; /** * The number of interactions with the opportunity. */ interactionCount?: number | null | undefined; customFields?: Array | undefined; /** * The date and time when the stage of the opportunity was last changed. */ stageLastChangedAt?: Date | null | undefined; /** * The date and time of the last activity associated with the opportunity. */ lastActivityAt?: string | null | undefined; /** * Indicates whether the opportunity has been deleted. */ deleted?: boolean | undefined; /** * The date and time when the stage of the opportunity was last changed. */ dateStageChanged?: Date | null | undefined; /** * The date and time when the opportunity was last contacted. */ dateLastContacted?: Date | null | undefined; /** * The date and time when the lead associated with the opportunity was created. */ dateLeadCreated?: Date | null | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: { [k: string]: any } | null | undefined; /** * The unique identifier of the user who last updated the opportunity. */ updatedBy?: string | null | undefined; /** * The unique identifier of the user who created the opportunity. */ createdBy?: string | null | undefined; /** * The date and time when the opportunity was last updated. */ updatedAt?: Date | null | undefined; /** * The date and time when the opportunity 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 Opportunity$inboundSchema: z.ZodType< Opportunity, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), title: types.string(), primary_contact_id: z.nullable(types.string()).optional(), description: z.nullable(types.string()).optional(), type: z.nullable(types.string()).optional(), monetary_amount: z.nullable(types.number()).optional(), currency: z.nullable(Currency$inboundSchema).optional(), win_probability: z.nullable(types.number()).optional(), expected_revenue: z.nullable(types.number()).optional(), close_date: z.nullable(types.date()).optional(), loss_reason_id: z.nullable(types.string()).optional(), loss_reason: z.nullable(types.string()).optional(), won_reason_id: z.nullable(types.string()).optional(), won_reason: z.nullable(types.string()).optional(), pipeline_id: z.nullable(types.string()).optional(), pipeline_stage_id: z.nullable(types.string()).optional(), source_id: z.nullable(types.string()).optional(), lead_id: z.nullable(types.string()).optional(), lead_source: z.nullable(types.string()).optional(), contact_id: z.nullable(types.string()).optional(), contact_ids: types.optional(z.array(types.string())), company_id: z.nullable(types.string()).optional(), company_name: z.nullable(types.string()).optional(), owner_id: z.nullable(types.string()).optional(), priority: z.nullable(types.string()).optional(), status: z.nullable(types.string()).optional(), status_id: z.nullable(types.string()).optional(), tags: z.nullable(z.array(types.string())).optional(), interaction_count: z.nullable(types.number()).optional(), custom_fields: types.optional(z.array(CustomField$inboundSchema)), stage_last_changed_at: z.nullable(types.date()).optional(), last_activity_at: z.nullable(types.string()).optional(), deleted: types.optional(types.boolean()), date_stage_changed: z.nullable(types.date()).optional(), date_last_contacted: z.nullable(types.date()).optional(), date_lead_created: z.nullable(types.date()).optional(), custom_mappings: z.nullable(z.record(z.any())).optional(), updated_by: z.nullable(types.string()).optional(), created_by: z.nullable(types.string()).optional(), updated_at: z.nullable(types.date()).optional(), created_at: z.nullable(types.date()).optional(), pass_through: types.optional(z.array(PassThroughBody$inboundSchema)), }).transform((v) => { return remap$(v, { "primary_contact_id": "primaryContactId", "monetary_amount": "monetaryAmount", "win_probability": "winProbability", "expected_revenue": "expectedRevenue", "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", "interaction_count": "interactionCount", "custom_fields": "customFields", "stage_last_changed_at": "stageLastChangedAt", "last_activity_at": "lastActivityAt", "date_stage_changed": "dateStageChanged", "date_last_contacted": "dateLastContacted", "date_lead_created": "dateLeadCreated", "custom_mappings": "customMappings", "updated_by": "updatedBy", "created_by": "createdBy", "updated_at": "updatedAt", "created_at": "createdAt", "pass_through": "passThrough", }); }) ); export function opportunityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Opportunity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Opportunity' from JSON`, ); }