use std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::trackers::BlockedTracker;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Plan {
#[serde(default)]
pub id: String,
#[serde(default)]
pub name: String,
#[serde(flatten)]
pub extra: BTreeMap<String, Value>,
}
#[derive(Debug, Clone)]
pub struct Account {
pub id: String,
pub plan_id: String,
pub created_at: String,
pub plan: Plan,
}
#[derive(Debug, Clone)]
pub struct Address {
pub id: String,
pub email_address: String,
pub status: String,
pub created_at: String,
pub retention_days: u32,
pub assigned_worker_id: Option<String>,
pub paused_at: Option<String>,
pub label: Option<String>,
pub receives: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Domain {
#[serde(default)]
pub domain: String,
#[serde(default)]
pub reserved: bool,
#[serde(flatten)]
pub extra: BTreeMap<String, Value>,
}
#[derive(Debug, Clone)]
pub struct Attachment {
pub index: usize,
pub filename: String,
pub mime_type: String,
pub size: u64,
pub content_id: Option<String>,
pub stored: bool,
}
#[derive(Debug, Clone)]
pub struct Message {
pub id: String,
pub address_id: String,
pub received_at: String,
pub read: bool,
pub starred: bool,
pub folder: String,
pub size_bytes: u64,
pub sent_via: Option<String>,
pub opened: bool,
pub from_address: String,
pub from_name: String,
pub reply_to: String,
pub to: String,
pub subject: String,
pub text: String,
pub html: String,
pub safe_html: String,
pub blocked: Vec<BlockedTracker>,
pub message_id: String,
pub attachments: Vec<Attachment>,
}
#[derive(Debug, Clone)]
pub struct MessagePage {
pub messages: Vec<Message>,
pub next_cursor: Option<String>,
}
#[derive(Debug, Clone)]
pub struct SendResult {
pub message_id: String,
pub sent_copy_id: Option<String>,
}
#[derive(Debug, Clone)]
pub struct Device {
pub id: String,
pub platform: String,
pub kind: String,
pub send_mode: String,
pub status: String,
pub created_at: String,
pub last_active_at: Option<String>,
pub paused_at: Option<String>,
pub name: Option<String>,
pub tags: Vec<String>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ActivityEntry {
#[serde(default)]
pub id: String,
#[serde(default)]
pub kind: String,
#[serde(default, rename = "createdAt")]
pub created_at: String,
#[serde(default, rename = "inboxId")]
pub address_id: Option<String>,
#[serde(default, rename = "workerId")]
pub worker_id: Option<String>,
}
#[derive(Debug, Clone)]
pub struct ActivityPage {
pub activity: Vec<ActivityEntry>,
pub next_cursor: Option<String>,
}
#[derive(Debug, Clone, Default, Deserialize)]
pub struct AccountEvent {
#[serde(default)]
pub id: String,
#[serde(default, rename = "type")]
pub event_type: String,
#[serde(default, rename = "createdAt")]
pub created_at: String,
#[serde(default)]
pub payload: BTreeMap<String, Value>,
}
#[derive(Debug, Clone)]
pub struct ApiKey {
pub id: String,
pub name: Option<String>,
pub hint: String,
pub created_at: String,
pub last_used_at: Option<String>,
}
#[derive(Debug, Clone)]
pub struct CreatedApiKey {
pub api_key: ApiKey,
pub token: String,
}
#[derive(Debug, Clone)]
pub struct Webhook {
pub id: String,
pub name: Option<String>,
pub url: String,
pub events: Vec<String>,
pub status: String,
pub disabled_reason: Option<String>,
pub failing_since: Option<String>,
pub last_success_at: Option<String>,
pub created_at: String,
}
#[derive(Debug, Clone)]
pub struct WebhookList {
pub webhooks: Vec<Webhook>,
pub event_types: Vec<String>,
}
#[derive(Debug, Clone)]
pub struct CreatedWebhook {
pub webhook: Webhook,
pub secret: String,
}
#[derive(Debug, Clone, Default)]
pub struct WebhookUpdate {
pub url: Option<String>,
pub events: Option<Vec<String>>,
pub name: Option<String>,
pub enabled: Option<bool>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WebhookDelivery {
#[serde(default)]
pub id: String,
#[serde(default)]
pub event_id: String,
#[serde(default)]
pub event_type: String,
#[serde(default)]
pub event: AccountEvent,
#[serde(default)]
pub status: String,
#[serde(default)]
pub attempts: u32,
#[serde(default)]
pub response_status: Option<u16>,
#[serde(default)]
pub error: Option<String>,
#[serde(default)]
pub created_at: String,
#[serde(default)]
pub last_attempt_at: Option<String>,
#[serde(default)]
pub next_attempt_at: Option<String>,
}
#[derive(Debug, Clone)]
pub struct DeliveryPage {
pub deliveries: Vec<WebhookDelivery>,
pub next_cursor: Option<String>,
}
#[derive(Debug, Clone)]
pub struct QueuedDelivery {
pub delivery_id: String,
pub event_id: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Session {
#[serde(default)]
pub id: String,
#[serde(default)]
pub created_at: String,
#[serde(default)]
pub expires_at: String,
#[serde(default)]
pub current: bool,
}
#[derive(Debug, Clone)]
pub struct Subscription {
pub id: String,
pub plan_id: String,
pub status: String,
pub renewal_date: String,
pub pending_plan_id: Option<String>,
pub balance_minor: i64,
pub pause: Option<Value>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum NameStyle {
Person,
Business,
Team,
#[default]
Neutral,
}
impl NameStyle {
pub fn as_str(self) -> &'static str {
match self {
NameStyle::Person => "person",
NameStyle::Business => "business",
NameStyle::Team => "team",
NameStyle::Neutral => "neutral",
}
}
}