use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct InboxWebhookMessage {
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "conversationId")]
pub conversation_id: String,
#[serde(rename = "platform")]
pub platform: Platform,
#[serde(rename = "platformMessageId")]
pub platform_message_id: String,
#[serde(rename = "direction")]
pub direction: Direction,
#[serde(rename = "text")]
pub text: String,
#[serde(rename = "attachments")]
pub attachments: Vec<models::InboxWebhookMessageAttachmentsInner>,
#[serde(rename = "sender")]
pub sender: Box<models::InboxWebhookMessageSender>,
#[serde(rename = "sentAt")]
pub sent_at: String,
#[serde(rename = "isRead")]
pub is_read: bool,
}
impl InboxWebhookMessage {
pub fn new(
id: String,
conversation_id: String,
platform: Platform,
platform_message_id: String,
direction: Direction,
text: String,
attachments: Vec<models::InboxWebhookMessageAttachmentsInner>,
sender: models::InboxWebhookMessageSender,
sent_at: String,
is_read: bool,
) -> InboxWebhookMessage {
InboxWebhookMessage {
id,
conversation_id,
platform,
platform_message_id,
direction,
text,
attachments,
sender: Box::new(sender),
sent_at,
is_read,
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Platform {
#[serde(rename = "instagram")]
Instagram,
#[serde(rename = "facebook")]
Facebook,
#[serde(rename = "telegram")]
Telegram,
#[serde(rename = "whatsapp")]
Whatsapp,
}
impl Default for Platform {
fn default() -> Platform {
Self::Instagram
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Direction {
#[serde(rename = "incoming")]
Incoming,
#[serde(rename = "outgoing")]
Outgoing,
}
impl Default for Direction {
fn default() -> Direction {
Self::Incoming
}
}