/* * 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"; import { ActorFeedItemDto, ActorFeedItemDto$inboundSchema, } from "./actorfeeditemdto.js"; import { ChannelTypeEnum, ChannelTypeEnum$inboundSchema, } from "./channeltypeenum.js"; import { MessageCTA, MessageCTA$inboundSchema } from "./messagecta.js"; import { SubscriberFeedResponseDto, SubscriberFeedResponseDto$inboundSchema, } from "./subscriberfeedresponsedto.js"; /** * Current status of the notification. */ export const NotificationFeedItemDtoStatus = { Sent: "sent", Error: "error", Warning: "warning", } as const; /** * Current status of the notification. */ export type NotificationFeedItemDtoStatus = ClosedEnum< typeof NotificationFeedItemDtoStatus >; export type NotificationFeedItemDto = { /** * Unique identifier for the notification. */ id: string; /** * Identifier for the template used to generate the notification. */ templateId: string; /** * Identifier for the environment where the notification is sent. */ environmentId: string; /** * Identifier for the message template used. */ messageTemplateId?: string | undefined; /** * Identifier for the organization sending the notification. */ organizationId: string; /** * Unique identifier for the notification instance. */ notificationId: string; /** * Unique identifier for the subscriber receiving the notification. */ subscriberId: string; /** * Identifier for the feed associated with the notification. */ feedId?: string | null | undefined; /** * Identifier for the job that triggered the notification. */ jobId: string; /** * Timestamp indicating when the notification was created. */ createdAt?: Date | null | undefined; /** * Timestamp indicating when the notification was last updated. */ updatedAt?: Date | null | undefined; /** * Actor details related to the notification, if applicable. */ actor?: ActorFeedItemDto | undefined; /** * Subscriber details associated with this notification. */ subscriber?: SubscriberFeedResponseDto | undefined; /** * Unique identifier for the transaction associated with the notification. */ transactionId: string; /** * Identifier for the template used, if applicable. */ templateIdentifier?: string | null | undefined; /** * Identifier for the provider that sends the notification. */ providerId?: string | null | undefined; /** * The main content of the notification. */ content: string; /** * The subject line for email notifications, if applicable. */ subject?: string | null | undefined; /** * Channel type through which the message is sent */ channel: ChannelTypeEnum; /** * Indicates whether the notification has been read by the subscriber. */ read: boolean; /** * Indicates whether the notification has been seen by the subscriber. */ seen: boolean; /** * Indicates whether the notification has been archived by the subscriber. */ archived: boolean; /** * Device tokens for push notifications, if applicable. */ deviceTokens?: Array | null | undefined; /** * Call-to-action information associated with the notification. */ cta: MessageCTA; /** * Current status of the notification. */ status: NotificationFeedItemDtoStatus; /** * The payload that was used to send the notification trigger. */ payload?: { [k: string]: any } | undefined; /** * The data sent with the notification. */ data?: { [k: string]: any } | null | undefined; /** * Provider-specific overrides used when triggering the notification. */ overrides?: { [k: string]: any } | undefined; /** * Tags associated with the workflow that triggered the notification. */ tags?: Array | null | undefined; }; /** @internal */ export const NotificationFeedItemDtoStatus$inboundSchema: z.ZodNativeEnum< typeof NotificationFeedItemDtoStatus > = z.nativeEnum(NotificationFeedItemDtoStatus); /** @internal */ export const NotificationFeedItemDto$inboundSchema: z.ZodType< NotificationFeedItemDto, z.ZodTypeDef, unknown > = z.object({ _id: z.string(), _templateId: z.string(), _environmentId: z.string(), _messageTemplateId: z.string().optional(), _organizationId: z.string(), _notificationId: z.string(), _subscriberId: z.string(), _feedId: z.nullable(z.string()).optional(), _jobId: z.string(), createdAt: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), updatedAt: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), actor: ActorFeedItemDto$inboundSchema.optional(), subscriber: SubscriberFeedResponseDto$inboundSchema.optional(), transactionId: z.string(), templateIdentifier: z.nullable(z.string()).optional(), providerId: z.nullable(z.string()).optional(), content: z.string(), subject: z.nullable(z.string()).optional(), channel: ChannelTypeEnum$inboundSchema, read: z.boolean(), seen: z.boolean(), archived: z.boolean(), deviceTokens: z.nullable(z.array(z.string())).optional(), cta: MessageCTA$inboundSchema, status: NotificationFeedItemDtoStatus$inboundSchema, payload: z.record(z.any()).optional(), data: z.nullable(z.record(z.any())).optional(), overrides: z.record(z.any()).optional(), tags: z.nullable(z.array(z.string())).optional(), }).transform((v) => { return remap$(v, { "_id": "id", "_templateId": "templateId", "_environmentId": "environmentId", "_messageTemplateId": "messageTemplateId", "_organizationId": "organizationId", "_notificationId": "notificationId", "_subscriberId": "subscriberId", "_feedId": "feedId", "_jobId": "jobId", }); }); export function notificationFeedItemDtoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => NotificationFeedItemDto$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'NotificationFeedItemDto' from JSON`, ); }