1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize, Serialize)]
pub struct News {
    /// Name of the rubric to send to
    #[serde(rename = "rubricName")]
    pub rubric: String,

    /// Message text of the news item
    pub text: String,

    /// News position (1-10) for Skyper pagers
    pub number: Option<i8>,

    /// Time at which the news was sent
    pub timestamp: Option<DateTime<Utc>>,

    /// User who submitted the news
    #[serde(rename = "ownerName")]
    pub sender: Option<String>,
}

impl News {
    /// Crates a new news item to be sent
    pub fn new(rubric: String, text: String) -> News {
        News {
            rubric,
            text,
            number: Some(1),
            timestamp: None,
            sender: None,
        }
    }
}