/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChannelTypeEnum, ChannelTypeEnum$inboundSchema, } from "./channeltypeenum.js"; import { EmailBlock, EmailBlock$inboundSchema } from "./emailblock.js"; import { MessageCTA, MessageCTA$inboundSchema } from "./messagecta.js"; import { MessageStatusEnum, MessageStatusEnum$inboundSchema, } from "./messagestatusenum.js"; import { SubscriberResponseDto, SubscriberResponseDto$inboundSchema, } from "./subscriberresponsedto.js"; import { WorkflowResponse, WorkflowResponse$inboundSchema, } from "./workflowresponse.js"; /** * Content of the message, can be an email block or a string */ export type Content = Array | string; export type MessageResponseDto = { /** * Unique identifier for the message */ id?: string | undefined; /** * Template ID associated with the message */ templateId?: string | null | undefined; /** * Environment ID where the message is sent */ environmentId: string; /** * Message template ID */ messageTemplateId?: string | null | undefined; /** * Organization ID associated with the message */ organizationId: string; /** * Notification ID associated with the message */ notificationId: string; /** * Subscriber ID associated with the message */ subscriberId: string; /** * Subscriber details, if available */ subscriber?: SubscriberResponseDto | undefined; /** * Workflow template associated with the message */ template?: WorkflowResponse | undefined; /** * Identifier for the message template */ templateIdentifier?: string | undefined; /** * Creation date of the message */ createdAt: string; /** * Array of delivery dates for the message, if the message has multiple delivery dates, for example after being snoozed */ deliveredAt?: Array | undefined; /** * Last seen date of the message, if available */ lastSeenDate?: string | undefined; /** * Last read date of the message, if available */ lastReadDate?: string | undefined; /** * Content of the message, can be an email block or a string */ content?: Array | string | null | undefined; /** * Transaction ID associated with the message */ transactionId: string; /** * Subject of the message, if applicable */ subject?: string | undefined; /** * Channel type through which the message is sent */ channel: ChannelTypeEnum; /** * Indicates if the message has been read */ read: boolean; /** * Indicates if the message has been seen */ seen: boolean; /** * Date when the message will be unsnoozed */ snoozedUntil?: string | undefined; /** * Email address associated with the message, if applicable */ email?: string | undefined; /** * Phone number associated with the message, if applicable */ phone?: string | undefined; /** * Direct webhook URL for the message, if applicable */ directWebhookUrl?: string | undefined; /** * Provider ID associated with the message, if applicable */ providerId?: string | undefined; /** * Device tokens associated with the message, if applicable */ deviceTokens?: Array | undefined; /** * Title of the message, if applicable */ title?: string | undefined; /** * Call to action associated with the message */ cta: MessageCTA; /** * Feed ID associated with the message, if applicable */ feedId?: string | null | undefined; /** * Status of the message */ status: MessageStatusEnum; /** * Error ID if the message has an error */ errorId?: string | undefined; /** * Error text if the message has an error */ errorText?: string | undefined; /** * The payload that was used to send the notification trigger */ payload?: { [k: string]: any } | undefined; /** * Provider specific overrides used when triggering the notification */ overrides?: { [k: string]: any } | undefined; /** * Context (single or multi) in which the message was sent */ contextKeys?: Array | undefined; }; /** @internal */ export const Content$inboundSchema: z.ZodType = z.union([z.array(EmailBlock$inboundSchema), z.string()]); export function contentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Content$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Content' from JSON`, ); } /** @internal */ export const MessageResponseDto$inboundSchema: z.ZodType< MessageResponseDto, z.ZodTypeDef, unknown > = z.object({ _id: z.string().optional(), _templateId: z.nullable(z.string()).optional(), _environmentId: z.string(), _messageTemplateId: z.nullable(z.string()).optional(), _organizationId: z.string(), _notificationId: z.string(), _subscriberId: z.string(), subscriber: SubscriberResponseDto$inboundSchema.optional(), template: WorkflowResponse$inboundSchema.optional(), templateIdentifier: z.string().optional(), createdAt: z.string(), deliveredAt: z.array(z.string()).optional(), lastSeenDate: z.string().optional(), lastReadDate: z.string().optional(), content: z.nullable(z.union([z.array(EmailBlock$inboundSchema), z.string()])) .optional(), transactionId: z.string(), subject: z.string().optional(), channel: ChannelTypeEnum$inboundSchema, read: z.boolean(), seen: z.boolean(), snoozedUntil: z.string().optional(), email: z.string().optional(), phone: z.string().optional(), directWebhookUrl: z.string().optional(), providerId: z.string().optional(), deviceTokens: z.array(z.string()).optional(), title: z.string().optional(), cta: MessageCTA$inboundSchema, _feedId: z.nullable(z.string()).optional(), status: MessageStatusEnum$inboundSchema, errorId: z.string().optional(), errorText: z.string().optional(), payload: z.record(z.any()).optional(), overrides: z.record(z.any()).optional(), contextKeys: 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", }); }); export function messageResponseDtoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => MessageResponseDto$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'MessageResponseDto' from JSON`, ); }