fathom-typescript
Version:
Fathom's official TypeScript SDK.
76 lines (69 loc) • 2.28 kB
text/typescript
/*
* 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 { 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";
export const TriggeredFor = {
MyRecordings: "my_recordings",
SharedExternalRecordings: "shared_external_recordings",
MySharedWithTeamRecordings: "my_shared_with_team_recordings",
SharedTeamRecordings: "shared_team_recordings",
} as const;
export type TriggeredFor = ClosedEnum<typeof TriggeredFor>;
export type Webhook = {
id: string;
url: string;
/**
* The secret used to verify the webhook signature.
*/
secret: string;
/**
* The date and time the webhook was created in ISO 8601 format.
*/
createdAt: Date;
includeTranscript: boolean;
includeCrmMatches: boolean;
includeSummary: boolean;
includeActionItems: boolean;
triggeredFor: Array<TriggeredFor>;
};
/** @internal */
export const TriggeredFor$inboundSchema: z.ZodNativeEnum<typeof TriggeredFor> =
z.nativeEnum(TriggeredFor);
/** @internal */
export const Webhook$inboundSchema: z.ZodType<Webhook, z.ZodTypeDef, unknown> =
z.object({
id: z.string(),
url: z.string(),
secret: z.string(),
created_at: z.string().datetime({ offset: true }).transform(v =>
new Date(v)
),
include_transcript: z.boolean(),
include_crm_matches: z.boolean(),
include_summary: z.boolean(),
include_action_items: z.boolean(),
triggered_for: z.array(TriggeredFor$inboundSchema),
}).transform((v) => {
return remap$(v, {
"created_at": "createdAt",
"include_transcript": "includeTranscript",
"include_crm_matches": "includeCrmMatches",
"include_summary": "includeSummary",
"include_action_items": "includeActionItems",
"triggered_for": "triggeredFor",
});
});
export function webhookFromJSON(
jsonString: string,
): SafeParseResult<Webhook, SDKValidationError> {
return safeParse(
jsonString,
(x) => Webhook$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Webhook' from JSON`,
);
}