import { RpcMethod } from './commonTypes'; export type MessagesService_List = RpcMethod; export type MessagesService_Get = RpcMethod; export type MessagesService_Cancel = RpcMethod; export type MessagesService_Delete = RpcMethod; export type MessagesService_GetStatistics = RpcMethod; export type MessagesService_GetBlockRevenue = RpcMethod; export type MessagesService_GetLinkClicksStatistics = RpcMethod; export type MessagesService_GetDeliveryReport = RpcMethod; export type MessagesService_FindRecipients = RpcMethod; export type MessagesService_GetDeviceReceivedMessages = RpcMethod; export type MessagesService_GetDevicesList = RpcMethod; export type MessagesService_GetUserInboxMessages = RpcMethod; export interface MessagesService { /** Lists messages (push, email or SMS sends) for an application, newest first, with paging, free-text search and an optional type filter. Use to browse sends or find a message code before fetching details or statistics. */ List: MessagesService_List; /** Returns a single message by its message code, including type, status, schedule and channel content. Use after list_messages to inspect one send. */ Get: MessagesService_Get; /** Cancels a scheduled message by code, setting its status to cancelled so it is not sent. Allowed only while the message is still pending, waiting or processing; an already-sent message cannot be cancelled. Keeps the message record — use delete_message to remove it. */ Cancel: MessagesService_Cancel; /** Deletes a scheduled message by code, removing its record and cancelling the send. Allowed only while the message is still pending, waiting or processing; an already-sent message cannot be deleted. */ Delete: MessagesService_Delete; /** Returns aggregate delivery and open time-series plus recipient counts for a single message (by message_code) or a whole campaign, over an optional time range. For one send's delivered/opened numbers pass message_code. */ GetStatistics: MessagesService_GetStatistics; /** Returns per-block clicks and the revenue of the recipients who clicked them, for one message's products blocks. Revenues are multi-touch and do not add up to the message total. */ GetBlockRevenue: MessagesService_GetBlockRevenue; /** Returns per-link click counts (total and unique) for a message or campaign. Use to see which links in the content were clicked and how often. */ GetLinkClicksStatistics: MessagesService_GetLinkClicksStatistics; /** Returns per-platform delivery error breakdowns (sender and mailbox errors) for a message or campaign over a time range. Use to diagnose why a send under-delivered. */ GetDeliveryReport: MessagesService_GetDeliveryReport; /** Searches the recipients of a message by hwid or user id and returns their send and open times. Use to check whether and when a specific device or user received a message. */ FindRecipients: MessagesService_FindRecipients; /** Lists the messages a single device (by hwid) received in an application, optionally filtered to broadcast or transactional. Use to reconstruct one device's message history. */ GetDeviceReceivedMessages: MessagesService_GetDeviceReceivedMessages; /** Returns the device hwids and user ids targeted by a message code. Use to see the exact audience a message was sent to. */ GetDevicesList: MessagesService_GetDevicesList; /** Lists the message inbox of a single user (by user id): what the app's inbox screen would show, with per-message inbox status, send date and expiration. Use to check what a user still has in their inbox, as opposed to what was sent to their device. */ GetUserInboxMessages: MessagesService_GetUserInboxMessages; } export type Type = 'All' | 'Push' | 'Email' | 'Sms'; export type PushInfo = { content: string; title: string; subtitle: string; banner: string; icon: string; }; export type EmailInfo = { subject: string; sendFrom: string; sendFromName: string; }; export type Message_SchedulingType = 'now' | 'device_tz' | 'custom_tz' | 'optimal_time'; export type Message_Status = 'status_unknown' | 'creating' | 'waiting' | 'pending' | 'processing' | 'done' | 'canceled' | 'fail' | 'deleted'; export type Message_info_pushInfo = { type: 'pushInfo'; data: PushInfo; }; export type Message_info_emailInfo = { type: 'emailInfo'; data: EmailInfo; }; export type Message_info = Message_info_pushInfo | Message_info_emailInfo; export type Message = { id: number; code: string; sendDate: Date; platforms: number[]; type: Type; preset: string; status: Message_Status; createdDate: Date; properties: Record; schedulingType: Message_SchedulingType; childMessages: Message[]; info: Message_info; }; export type ListMessagesRequest_OrderBy = 'NAME' | 'CREATED' | 'SEND_DATE' | 'UPDATED'; export type ListMessagesRequest_OrderDirection = 'ASC' | 'DESC'; export type ListMessagesRequest = { /** Application code (format XXXXX-XXXXX) whose messages to list. */ application?: string; orderBy?: ListMessagesRequest_OrderBy; orderDirection?: ListMessagesRequest_OrderDirection; page?: number; perPage?: number; /** Free-text search over message content and code. */ search?: string; /** Restrict to these message ids. */ ids?: number[]; type?: Type; }; export type ListMessagesResponse = { messages: Message[]; page: number; perPage: number; total: number; }; export type GetMessageRequest = { /** Message code of the message to fetch. */ code?: string; }; export type GetMessageResponse = { message: Message; }; export type CancelMessageRequest = { /** Message code of the message to cancel. */ code?: string; }; export type CancelMessageResponse = {}; export type DeleteMessageRequest = { /** Message code of the message to delete. */ code?: string; }; export type DeleteMessageResponse = {}; export type GetStatisticsRequest = { /** Application code (format XXXXX-XXXXX). Optional if application_group is set. */ application?: string; /** Application group code; aggregates statistics across the group. */ applicationGroup?: string; /** Message code to scope statistics to a single send. Leave empty for campaign-level numbers. */ messageCode?: string; /** Campaign code to scope statistics to a whole campaign. */ campaign?: string; timestampFrom?: Date; timestampTo?: Date; }; export type GetStatisticsResponse_PlatformTimeSeries_Breakdown = { platform: string; values: number[]; }; export type GetStatisticsResponse_PlatformTimeSeries = { timestamps: Date[]; breakdowns: GetStatisticsResponse_PlatformTimeSeries_Breakdown[]; totals: number; }; export type GetStatisticsResponse_Metrics = { sends: GetStatisticsResponse_PlatformTimeSeries; deliveries: GetStatisticsResponse_PlatformTimeSeries; opens: GetStatisticsResponse_PlatformTimeSeries; recipientsByPlatform: Record; recipients: number; totalOpens: GetStatisticsResponse_PlatformTimeSeries; totalDeliveries: number; frequencyCappingUniqueUsers: number; frequencyCappingSuppressions: number; opensAmpp: GetStatisticsResponse_PlatformTimeSeries; }; export type GetStatisticsResponse = { metrics: GetStatisticsResponse_Metrics; }; export type GetBlockRevenueRequest = { /** Application code (format XXXXX-XXXXX). */ application?: string; /** Message code to scope the report to a single send. */ messageCode?: string; timestampFrom?: Date; timestampTo?: Date; }; /** * One products block of the message and the revenue of the recipients who * clicked it. */ export type GetBlockRevenueResponse_BlockRevenue = { /** Block id carried by the product links (pw_block). */ block: string; /** Ranking that produced the items (pw_strategy); empty for manual products. */ strategy: string; clicks: number; uniqClicks: number; /** * Multi-touch: a buyer who clicked several blocks credits each of them in * full, so block revenues do NOT add up to the message's total revenue. */ revenue: number; /** ISO 4217 code the revenue events carried. */ currency: string; }; export type GetBlockRevenueResponse = { blocks: GetBlockRevenueResponse_BlockRevenue[]; /** * False when the account tracks no revenue: the UI says so instead of showing * a zero, which would read as "the block earned nothing". */ revenueTrackingConfigured: boolean; }; export type GetLinkClicksStatisticsRequest = { /** Application code (format XXXXX-XXXXX). Optional if application_group is set. */ application?: string; /** Application group code; aggregates across the group. */ applicationGroup?: string; /** Message code to scope link clicks to a single send. */ messageCode?: string; /** Campaign code to scope link clicks to a whole campaign. */ campaign?: string; timestampFrom?: Date; timestampTo?: Date; }; export type GetLinkClicksStatisticsResponse_LinkClick_Attributes = { attributes: string[]; clicks: number; }; /** * example: 'https://google.com?name=sam&age=20' * https://google.com it's link * ['name=sam', 'age=20'] it's attributes */ export type GetLinkClicksStatisticsResponse_LinkClick = { link: string; clicks: number; attributes: GetLinkClicksStatisticsResponse_LinkClick_Attributes[]; }; export type GetLinkClicksStatisticsResponse = { links: GetLinkClicksStatisticsResponse_LinkClick[]; totalClicks: number; uniqClick: number; }; export type GetDeliveryReportRequest = { /** Application code (format XXXXX-XXXXX). Optional if application_group is set. */ application?: string; /** Application group code; aggregates across the group. */ applicationGroup?: string; /** Message code to scope the delivery report to a single send. */ messageCode?: string; /** Campaign code to scope the delivery report to a whole campaign. */ campaign?: string; timestampFrom?: Date; timestampTo?: Date; }; export type GetDeliveryReportResponse_ProcessingErrorsType = /** Any error types */ 'processing_unknown' /** Error during sending */ | 'send' /** Error during publishing */ | 'publish'; export type GetDeliveryReportResponse_MailboxErrorType = /** for compatibility with types in the export service */ 'all' | 'complaints' | 'soft_bounces' | 'hard_bounces'; export type GetDeliveryReportResponse_DeliveryReport_ReportError = { error: string; tooltip: string; count: number; statusCode: number; mailboxErrorType: GetDeliveryReportResponse_MailboxErrorType; processingErrorType: GetDeliveryReportResponse_ProcessingErrorsType; mailboxErrorStatus: number; }; export type GetDeliveryReportResponse_DeliveryReport = { platform: number; total: number; errors: GetDeliveryReportResponse_DeliveryReport_ReportError[]; }; export type GetDeliveryReportResponse = { senderErrors: GetDeliveryReportResponse_DeliveryReport[]; mailErrors: GetDeliveryReportResponse_DeliveryReport; }; export type FindRecipientsRequest = { /** Application code (format XXXXX-XXXXX). */ application?: string; /** Message code to search recipients within. */ messageCode?: string; /** Campaign code to search recipients within. */ campaign?: string; /** hwid or user id to search recipients by (not free-text). */ search?: string; }; export type FindRecipientsResponse_SearchBy = 'hwid' | 'user_id'; export type FindRecipientsResponse_Recipient = { hwid: string; userId: string; pushAlertsEnabled: boolean; sendTime: Date; openedTime: Date; }; export type FindRecipientsResponse = { recipients: FindRecipientsResponse_Recipient[]; searchBy: FindRecipientsResponse_SearchBy; }; export type GetDeviceReceivedMessagesRequest_MessageType = 'unspecified' | 'all' | 'broadcast' | 'transactional'; export type GetDeviceReceivedMessagesRequest = { /** Application code (format XXXXX-XXXXX). */ application?: string; /** Device hardware id (HWID) whose received messages to list. */ hwid?: string; messageType?: GetDeviceReceivedMessagesRequest_MessageType; }; export type GetDeviceReceivedMessagesResponse_Message_Type = 'broadcast' | 'journey' | 'transactional'; export type GetDeviceReceivedMessagesResponse_Message = { messageId: number; messageCode: string; campaignCode: string; title: string; content: string; pushAlertsEnabled: boolean; type: GetDeviceReceivedMessagesResponse_Message_Type; sendTime: Date; openedTime: Date; isEmail: boolean; errorMessage: string; }; export type GetDeviceReceivedMessagesResponse = { messages: GetDeviceReceivedMessagesResponse_Message[]; }; export type GetUserInboxMessagesRequest = { /** Application code (format XXXXX-XXXXX). */ application?: string; /** Inbox owner: user id set by the SDK, or the device hwid for anonymous users. */ userId?: string; /** Platform (device type) to filter by; 0 returns every platform. */ platform?: number; }; /** * Inbox lifecycle status reported by the SDK. Messages deleted by the user are * dropped from the inbox, so they are never returned. */ export type GetUserInboxMessagesResponse_InboxMessage_Status = 'created' | 'delivered' | 'read' | 'opened' | 'deleted_by_user' | 'deleted'; export type GetUserInboxMessagesResponse_InboxMessage = { inboxId: string; messageId: number; title: string; text: string; image: string; status: GetUserInboxMessagesResponse_InboxMessage_Status; platform: number; sendDate: Date; expireAt: Date; }; export type GetUserInboxMessagesResponse = { messages: GetUserInboxMessagesResponse_InboxMessage[]; }; export type GetDevicesListRequest = { /** Message code whose targeted device hwids and user ids to return. */ messageCode?: string; }; export type GetDevicesListResponse = { devices: string[]; users: string[]; };