use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use crate::enums::{
EligibilityFramework, EligibilitySignalProvenance, EligibilitySignalVerdict, Estimator,
FlowDirection, IntensityIndex, Interval, Methodology, ThresholdDirection, WebhookStatus,
};
use crate::region::Region;
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct IntensityValue {
pub value: f64,
pub unit: String,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct IntensityResponse {
pub region: Region,
#[serde(with = "time::serde::rfc3339")]
pub timestamp: OffsetDateTime,
pub intensity: IntensityValue,
#[serde(default)]
pub index: Option<IntensityIndex>,
pub methodology: Methodology,
pub methodology_version: u32,
pub vintage: String,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct IntensityAllResponse {
pub methodology: Methodology,
pub methodology_version: u32,
pub count: u32,
pub regions: Vec<IntensityResponse>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct HistoryPoint {
#[serde(with = "time::serde::rfc3339")]
pub timestamp: OffsetDateTime,
pub intensity: f64,
#[serde(default)]
pub index: Option<IntensityIndex>,
pub vintage: String,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct HistoryResponse {
pub region: Region,
#[serde(with = "time::serde::rfc3339")]
pub from: OffsetDateTime,
#[serde(with = "time::serde::rfc3339")]
pub to: OffsetDateTime,
pub unit: String,
pub methodology: Methodology,
pub count: u32,
pub data: Vec<HistoryPoint>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct StatsBucket {
#[serde(with = "time::serde::rfc3339")]
pub start: OffsetDateTime,
pub average: f64,
pub min: f64,
pub max: f64,
pub count: u64,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct StatsResponse {
pub region: Region,
#[serde(with = "time::serde::rfc3339")]
pub from: OffsetDateTime,
#[serde(with = "time::serde::rfc3339")]
pub to: OffsetDateTime,
pub unit: String,
pub methodology: Methodology,
pub average: f64,
pub min: f64,
pub max: f64,
pub count: u64,
pub interval: Option<Interval>,
pub intervals: Option<Vec<StatsBucket>>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct SlotBody {
#[serde(with = "time::serde::rfc3339")]
pub timestamp: OffsetDateTime,
pub intensity: f64,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct SlotsResponse {
pub region: Region,
pub methodology: Methodology,
pub model: String,
pub estimator: Estimator,
pub unit: String,
pub count: u32,
pub slots: Vec<SlotBody>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct ForecastPointBody {
#[serde(with = "time::serde::rfc3339")]
pub timestamp: OffsetDateTime,
pub expected: f64,
pub lower: f64,
pub upper: f64,
#[serde(default)]
pub index: Option<IntensityIndex>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct ForecastResponse {
pub region: Region,
pub methodology: Methodology,
pub model: String,
#[serde(with = "time::serde::rfc3339")]
pub from: OffsetDateTime,
pub horizon_hours: u32,
pub unit: String,
pub count: u32,
pub data: Vec<ForecastPointBody>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct EligibilitySignalBody {
pub pillar: String,
pub verdict: EligibilitySignalVerdict,
pub basis: String,
pub provenance: Option<EligibilitySignalProvenance>,
pub reason: Option<String>,
pub threshold: Option<f64>,
pub value: Option<f64>,
pub value_lower: Option<f64>,
pub value_upper: Option<f64>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct EligibilitySlotBody {
#[serde(with = "time::serde::rfc3339")]
pub timestamp: OffsetDateTime,
pub eligible: bool,
pub intensity: f64,
pub intensity_lower: f64,
pub intensity_upper: f64,
pub score: f64,
pub signals: Vec<EligibilitySignalBody>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct EligibleSlotBody {
#[serde(with = "time::serde::rfc3339")]
pub timestamp: OffsetDateTime,
pub intensity: f64,
pub intensity_lower: f64,
pub intensity_upper: f64,
pub score: f64,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct EligibilityBody {
pub framework: EligibilityFramework,
pub ruleset_version: String,
pub ruleset_status: String,
pub overridden: bool,
pub bidding_zone: String,
pub disclaimer: String,
pub window_eligible: bool,
pub count_eligible: u32,
pub count_indeterminate: u32,
pub slots: Vec<EligibilitySlotBody>,
pub best_eligible: Option<EligibleSlotBody>,
pub share_model: Option<String>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct GreenestWindowResponse {
pub region: Region,
pub methodology: Methodology,
pub model: String,
#[serde(with = "time::serde::rfc3339")]
pub start: OffsetDateTime,
#[serde(with = "time::serde::rfc3339")]
pub end: OffsetDateTime,
pub unit: String,
pub average_intensity: f64,
pub eligibility: Option<EligibilityBody>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct SavingsBody {
pub now: f64,
pub scheduled: f64,
pub intensity_delta: f64,
pub reduction_percent: f64,
pub absolute_saved_g: Option<f64>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct ScheduleResponse {
pub region: Region,
pub methodology: Methodology,
pub model: String,
pub estimator: Estimator,
pub unit: String,
#[serde(with = "time::serde::rfc3339")]
pub start: OffsetDateTime,
#[serde(with = "time::serde::rfc3339")]
pub end: OffsetDateTime,
pub average_intensity: f64,
pub savings: SavingsBody,
}
#[derive(Debug, Clone, Copy, PartialEq, Deserialize)]
pub struct MixBody {
pub nucleaire: f64,
pub gaz: f64,
pub charbon: f64,
pub fioul: f64,
pub hydraulique: f64,
pub eolien: f64,
pub solaire: f64,
pub bioenergies: f64,
pub pompage: f64,
pub echanges: f64,
pub thermique: Option<f64>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct MixShareBody {
pub filiere: String,
pub label: String,
pub share: f64,
pub output_mw: f64,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct MixResponse {
pub region: Region,
#[serde(with = "time::serde::rfc3339")]
pub timestamp: OffsetDateTime,
pub unit: String,
pub mix: MixBody,
#[serde(default)]
pub shares: Vec<MixShareBody>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct ExchangeEntry {
pub country: String,
pub country_name: String,
pub flow_mw: f64,
pub direction: FlowDirection,
pub intensity: IntensityValue,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct ExchangesResponse {
#[serde(with = "time::serde::rfc3339")]
pub timestamp: OffsetDateTime,
pub net_flow_mw: f64,
pub direction: FlowDirection,
pub imports_mw: f64,
pub exports_mw: f64,
pub exchanges: Vec<ExchangeEntry>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct ExchangesHistoryResponse {
#[serde(with = "time::serde::rfc3339")]
pub from: OffsetDateTime,
#[serde(with = "time::serde::rfc3339")]
pub to: OffsetDateTime,
pub count: u32,
pub snapshots: Vec<ExchangesResponse>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct WeatherPoint {
#[serde(with = "time::serde::rfc3339")]
pub valid_at: OffsetDateTime,
#[serde(with = "time::serde::rfc3339")]
pub run_at: OffsetDateTime,
pub wind_kmh: f64,
pub irradiance_wm2: f64,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct WeatherResponse {
pub source: String,
#[serde(with = "time::serde::rfc3339")]
pub valid_at: OffsetDateTime,
#[serde(with = "time::serde::rfc3339")]
pub run_at: OffsetDateTime,
pub wind_kmh: f64,
pub irradiance_wm2: f64,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct WeatherHistoryResponse {
pub source: String,
#[serde(with = "time::serde::rfc3339")]
pub from: OffsetDateTime,
#[serde(with = "time::serde::rfc3339")]
pub to: OffsetDateTime,
pub count: u32,
pub points: Vec<WeatherPoint>,
}
#[derive(Debug, Clone, Copy, PartialEq, Deserialize)]
pub struct RenewableModelInfo {
pub wind_capacity_mw: f64,
pub solar_capacity_mw: f64,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct RenewableResponse {
pub source: String,
#[serde(with = "time::serde::rfc3339")]
pub at: OffsetDateTime,
pub wind_mw: f64,
pub solar_mw: f64,
pub wind_capacity_factor: f64,
pub solar_capacity_factor: f64,
pub model: RenewableModelInfo,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct MethodologyInfo {
pub id: String,
pub version: u32,
pub basis: String,
pub scope: String,
pub default: bool,
pub status: String,
pub adr: String,
pub description: String,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct MethodologiesResponse {
pub methodologies: Vec<MethodologyInfo>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct RegionInfo {
pub slug: Region,
pub label: String,
pub insee_code: Option<String>,
pub national: bool,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct RegionsResponse {
pub regions: Vec<RegionInfo>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct FactorEntry {
pub filiere: String,
pub factor: f64,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct FactorsResponse {
pub methodology: Methodology,
pub methodology_version: u32,
pub unit: String,
pub source: String,
pub td_loss_factor: Option<f64>,
pub factors: Vec<FactorEntry>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct IndexBand {
pub label: IntensityIndex,
pub min: Option<f64>,
pub max: Option<f64>,
pub description: String,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct IndexThreshold {
pub value: f64,
pub below: IntensityIndex,
pub above: IntensityIndex,
pub source: String,
pub url: String,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct IntensityIndexResponse {
pub version: u32,
pub unit: String,
pub bands: Vec<IndexBand>,
pub thresholds: Vec<IndexThreshold>,
pub note: String,
pub source: String,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct PriceComponentBody {
pub kind: String,
pub label: String,
pub amount_eur_mwh: f64,
pub source: String,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct PriceMixShareBody {
pub filiere: String,
pub label: String,
pub share: f64,
pub output_mw: f64,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct MarginalTechnologyBody {
pub filiere: String,
pub label: String,
pub estimated: bool,
pub method: String,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct PriceContextBody {
pub mix: Vec<PriceMixShareBody>,
pub marginal_technology: Option<MarginalTechnologyBody>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct PriceResponse {
pub region: Region,
#[serde(with = "time::serde::rfc3339")]
pub timestamp: OffsetDateTime,
pub vintage: String,
pub unit: String,
pub currency: String,
pub total_eur_mwh: f64,
pub total_eur_kwh: f64,
pub components: Vec<PriceComponentBody>,
pub context: PriceContextBody,
pub disclaimer: String,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct PricePointBody {
#[serde(with = "time::serde::rfc3339")]
pub timestamp: OffsetDateTime,
pub energie_eur_mwh: f64,
pub total_eur_mwh: f64,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct PriceHistoryResponse {
#[serde(with = "time::serde::rfc3339")]
pub from: OffsetDateTime,
#[serde(with = "time::serde::rfc3339")]
pub to: OffsetDateTime,
pub count: u32,
pub unit: String,
pub currency: String,
pub points: Vec<PricePointBody>,
}
#[derive(Debug, Clone, Copy, PartialEq, Deserialize)]
pub struct CostAssumptionsBody {
pub discount_rate: Option<f64>,
pub lifetime_years: Option<u32>,
pub load_factor: Option<f64>,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct LcoeRangeBody {
pub min: f64,
pub median: f64,
pub max: f64,
pub unit: String,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct CostReferenceEntry {
pub technology: String,
pub technology_label: String,
pub source: String,
pub source_label: String,
pub source_attribution: String,
pub geography: String,
pub perimeter: String,
pub perimeter_label: String,
pub basis: String,
pub basis_label: String,
pub technology_source_count: u32,
pub vintage: u32,
pub kind: String,
pub range: LcoeRangeBody,
pub hypotheses: CostAssumptionsBody,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct CostReferenceResponse {
pub unit: String,
pub currency: String,
pub kind: String,
pub disclaimer: String,
pub count: u32,
pub entries: Vec<CostReferenceEntry>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct RulesetInfo {
pub framework: EligibilityFramework,
pub version: String,
pub status: String,
pub adr: String,
pub granularity: String,
pub article4_renewable_threshold: Option<f64>,
pub surplus_price_eur_mwh: Option<f64>,
pub hourly_switchover: Option<String>,
pub low_carbon_intensity_threshold_g_per_kwh: Option<f64>,
pub low_carbon_intensity_is_indicative: bool,
pub electrolyzer_kwh_per_kg: Option<f64>,
pub legal_basis: String,
pub description: String,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct RulesetsResponse {
pub rulesets: Vec<RulesetInfo>,
pub disclaimer: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct VisitStatsResponse {
pub unique: u64,
pub total: u64,
pub since: Option<String>,
}
#[derive(Debug, Clone, Serialize, PartialEq)]
pub struct CreateWebhookRequest {
pub threshold: f64,
pub direction: ThresholdDirection,
pub callback_url: String,
pub region: Option<Region>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct CreatedWebhookResponse {
pub id: String,
pub secret: String,
pub region: Region,
pub threshold: f64,
pub direction: ThresholdDirection,
pub callback_url: String,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct WebhookSummary {
pub id: String,
pub region: Region,
pub threshold: f64,
pub direction: ThresholdDirection,
pub callback_url: String,
pub status: WebhookStatus,
#[serde(with = "time::serde::rfc3339::option")]
pub disabled_at: Option<OffsetDateTime>,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct WebhookListResponse {
pub count: u32,
pub webhooks: Vec<WebhookSummary>,
}