/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import { safeParse } from "../../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
SourceAccountWebhookPayload,
SourceAccountWebhookPayload$inboundSchema,
SourceAccountWebhookPayload$Outbound,
SourceAccountWebhookPayload$outboundSchema,
} from "./sourceaccountwebhookpayload.js";
export type SourceAccountWebhook = {
/**
* Unique identifier of the event.
*/
id?: string | undefined;
/**
* The type of event.
*/
eventType?: string | undefined;
/**
* In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:
*
* @remarks
*
* ```
* 2020-10-08T22:40:50Z
* 2021-01-01T00:00:00
* ```
*
* When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:
*
* - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
* - Unqualified local time: `2021-11-15T01:00:00`
* - UTC time offsets: `2021-11-15T01:00:00-05:00`
*
* > Time zones
* >
* > Not all dates from Codat will contain information about time zones.
* > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced.
*/
generatedDate?: string | undefined;
payload?: SourceAccountWebhookPayload | undefined;
};
/** @internal */
export const SourceAccountWebhook$inboundSchema: z.ZodType<
SourceAccountWebhook,
z.ZodTypeDef,
unknown
> = z.object({
id: z.string().optional(),
eventType: z.string().optional(),
generatedDate: z.string().optional(),
payload: SourceAccountWebhookPayload$inboundSchema.optional(),
});
/** @internal */
export type SourceAccountWebhook$Outbound = {
id?: string | undefined;
eventType?: string | undefined;
generatedDate?: string | undefined;
payload?: SourceAccountWebhookPayload$Outbound | undefined;
};
/** @internal */
export const SourceAccountWebhook$outboundSchema: z.ZodType<
SourceAccountWebhook$Outbound,
z.ZodTypeDef,
SourceAccountWebhook
> = z.object({
id: z.string().optional(),
eventType: z.string().optional(),
generatedDate: z.string().optional(),
payload: SourceAccountWebhookPayload$outboundSchema.optional(),
});
export function sourceAccountWebhookToJSON(
sourceAccountWebhook: SourceAccountWebhook,
): string {
return JSON.stringify(
SourceAccountWebhook$outboundSchema.parse(sourceAccountWebhook),
);
}
export function sourceAccountWebhookFromJSON(
jsonString: string,
): SafeParseResult {
return safeParse(
jsonString,
(x) => SourceAccountWebhook$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'SourceAccountWebhook' from JSON`,
);
}