buena-typescript-sdk
Version:
Official TypeScript SDK for Buena.ai API - LinkedIn automation and lead management
179 lines (166 loc) • 4.85 kB
text/typescript
/*
* 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 { ClosedEnum } from "../types/enums.js";
import { Result as SafeParseResult } from "../types/fp.js";
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
/**
* Current status of the lead
*/
export const Status = {
New: "new",
Contacted: "contacted",
Responded: "responded",
Converted: "converted",
Unqualified: "unqualified",
} as const;
/**
* Current status of the lead
*/
export type Status = ClosedEnum<typeof Status>;
export type Lead = {
/**
* Unique identifier for the lead
*/
id?: string | undefined;
/**
* First name of the lead
*/
firstName?: string | undefined;
/**
* Last name of the lead
*/
lastName?: string | undefined;
/**
* Email address of the lead
*/
email?: string | undefined;
/**
* Company name
*/
company?: string | undefined;
/**
* Job title
*/
title?: string | undefined;
/**
* LinkedIn profile URL
*/
linkedinUrl?: string | undefined;
/**
* Current status of the lead
*/
status?: Status | undefined;
/**
* When the lead was created
*/
createdAt?: Date | undefined;
/**
* When the lead was last updated
*/
updatedAt?: Date | undefined;
};
/** @internal */
export const Status$inboundSchema: z.ZodNativeEnum<typeof Status> = z
.nativeEnum(Status);
/** @internal */
export const Status$outboundSchema: z.ZodNativeEnum<typeof Status> =
Status$inboundSchema;
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace Status$ {
/** @deprecated use `Status$inboundSchema` instead. */
export const inboundSchema = Status$inboundSchema;
/** @deprecated use `Status$outboundSchema` instead. */
export const outboundSchema = Status$outboundSchema;
}
/** @internal */
export const Lead$inboundSchema: z.ZodType<Lead, z.ZodTypeDef, unknown> = z
.object({
id: z.string().optional(),
first_name: z.string().optional(),
last_name: z.string().optional(),
email: z.string().optional(),
company: z.string().optional(),
title: z.string().optional(),
linkedin_url: z.string().optional(),
status: Status$inboundSchema.optional(),
created_at: z.string().datetime({ offset: true }).transform(v =>
new Date(v)
).optional(),
updated_at: z.string().datetime({ offset: true }).transform(v =>
new Date(v)
).optional(),
}).transform((v) => {
return remap$(v, {
"first_name": "firstName",
"last_name": "lastName",
"linkedin_url": "linkedinUrl",
"created_at": "createdAt",
"updated_at": "updatedAt",
});
});
/** @internal */
export type Lead$Outbound = {
id?: string | undefined;
first_name?: string | undefined;
last_name?: string | undefined;
email?: string | undefined;
company?: string | undefined;
title?: string | undefined;
linkedin_url?: string | undefined;
status?: string | undefined;
created_at?: string | undefined;
updated_at?: string | undefined;
};
/** @internal */
export const Lead$outboundSchema: z.ZodType<Lead$Outbound, z.ZodTypeDef, Lead> =
z.object({
id: z.string().optional(),
firstName: z.string().optional(),
lastName: z.string().optional(),
email: z.string().optional(),
company: z.string().optional(),
title: z.string().optional(),
linkedinUrl: z.string().optional(),
status: Status$outboundSchema.optional(),
createdAt: z.date().transform(v => v.toISOString()).optional(),
updatedAt: z.date().transform(v => v.toISOString()).optional(),
}).transform((v) => {
return remap$(v, {
firstName: "first_name",
lastName: "last_name",
linkedinUrl: "linkedin_url",
createdAt: "created_at",
updatedAt: "updated_at",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace Lead$ {
/** @deprecated use `Lead$inboundSchema` instead. */
export const inboundSchema = Lead$inboundSchema;
/** @deprecated use `Lead$outboundSchema` instead. */
export const outboundSchema = Lead$outboundSchema;
/** @deprecated use `Lead$Outbound` instead. */
export type Outbound = Lead$Outbound;
}
export function leadToJSON(lead: Lead): string {
return JSON.stringify(Lead$outboundSchema.parse(lead));
}
export function leadFromJSON(
jsonString: string,
): SafeParseResult<Lead, SDKValidationError> {
return safeParse(
jsonString,
(x) => Lead$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Lead' from JSON`,
);
}