From 984223c287711731c2c24dba5eb901b7de658691 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Sat, 23 May 2026 00:56:10 +0000 Subject: [PATCH] Add definition for messages from the API --- ts/type/api.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/ts/type/api.ts b/ts/type/api.ts index 9805a59c..6c336e81 100644 --- a/ts/type/api.ts +++ b/ts/type/api.ts @@ -606,6 +606,40 @@ export class Communication { } } +export enum MessageType { + Unknown = 0, + Email = 1, + Mailer = 2, + Text = 3, +} + +export interface MessageDTO { + content: string; + created: string; + destination: string; + source: string; + type: number; +} + +export class Message { + constructor( + public content: string, + public created: Date, + public destination: string, + public source: string, + public type: MessageType, + ) {} + static fromJSON(json: MessageDTO): Message { + return new Message( + json.content, + new Date(json.created), + json.destination, + json.source, + json.type as MessageType, + ); + } +} + export interface Pool { condition: string; id: number;