use crate::ids::{InstrumentId, MarketId};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(transparent)]
pub struct NewsId(pub i64);
impl std::fmt::Display for NewsId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}
impl From<i64> for NewsId {
fn from(v: i64) -> Self {
Self(v)
}
}
impl From<NewsId> for i64 {
fn from(v: NewsId) -> Self {
v.0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(transparent)]
pub struct NewsSourceId(pub i64);
impl std::fmt::Display for NewsSourceId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}
impl From<i64> for NewsSourceId {
fn from(v: i64) -> Self {
Self(v)
}
}
impl From<NewsSourceId> for i64 {
fn from(v: NewsSourceId) -> Self {
v.0
}
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
pub struct NewsArticle {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub body: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub byline: Option<String>,
pub headline: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub instruments: Option<Vec<InstrumentId>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub isin_codes: Option<Vec<String>>,
pub lang: String,
pub markdown_format: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub markets: Option<Vec<MarketId>>,
pub news_id: NewsId,
pub news_type: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub sectors: Option<Vec<String>>,
pub source_id: NewsSourceId,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub summary: Option<String>,
pub timestamp: i64,
#[serde(rename = "type")]
pub r#type: String,
pub version: i64,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
pub struct NewsSource {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub countries: Option<Vec<String>>,
pub level: String,
pub name: String,
pub source_id: NewsSourceId,
}