use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FinancialStatements {
pub symbol: String,
pub financials: Vec<HashMap<String, serde_json::Value>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BasicFinancials {
pub symbol: String,
pub metric: HashMap<String, serde_json::Value>,
#[serde(rename = "metricType")]
pub metric_type: String,
pub series: Option<serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FinancialReport {
#[serde(rename = "accessNumber")]
pub access_number: Option<String>,
pub symbol: Option<String>,
pub cik: Option<String>,
pub year: Option<i64>,
pub quarter: Option<i64>,
pub form: Option<String>,
#[serde(rename = "startDate")]
pub start_date: Option<String>,
#[serde(rename = "endDate")]
pub end_date: Option<String>,
#[serde(rename = "filedDate")]
pub filed_date: Option<String>,
#[serde(rename = "acceptedDate")]
pub accepted_date: Option<String>,
pub report: Option<serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FinancialsAsReported {
pub symbol: Option<String>,
pub cik: Option<String>,
pub data: Vec<FinancialReport>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Earnings {
pub actual: Option<f64>,
pub estimate: Option<f64>,
pub period: String,
pub surprise: Option<f64>,
#[serde(rename = "surprisePercent")]
pub surprise_percent: Option<f64>,
pub symbol: String,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum StatementType {
#[serde(rename = "bs")]
BalanceSheet,
#[serde(rename = "ic")]
IncomeStatement,
#[serde(rename = "cf")]
CashFlow,
}
impl fmt::Display for StatementType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
StatementType::BalanceSheet => write!(f, "bs"),
StatementType::IncomeStatement => write!(f, "ic"),
StatementType::CashFlow => write!(f, "cf"),
}
}
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum StatementFrequency {
#[serde(rename = "annual")]
Annual,
#[serde(rename = "quarterly")]
Quarterly,
#[serde(rename = "ttm")]
TTM,
}
impl fmt::Display for StatementFrequency {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
StatementFrequency::Annual => write!(f, "annual"),
StatementFrequency::Quarterly => write!(f, "quarterly"),
StatementFrequency::TTM => write!(f, "ttm"),
}
}
}