-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrk - Mostly added a bunch of messages (#11)
Clippy pedantic Added site power request message. Addeded site_data_period. Added site_energy request and response. Added SiteTimeFrameEnergy request. Check response status before trying to parse json. Added SitePowerReq/Resp. Added SiteList request / response. Added site_overview. Added site_power_flow. Added site_storage_data. Added site_environmental_benefits.
- Loading branch information
Showing
26 changed files
with
1,423 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
//! Module for querying the energy production start and end dates of the site. | ||
use crate::{SendReq, MONITORING_API_URL}; | ||
use serde::Deserialize; | ||
|
||
/// site_data_period request | ||
#[derive(Clone, Debug, PartialEq)] | ||
pub struct Req; | ||
|
||
/// site_data_period response | ||
#[derive(Clone, Deserialize, Debug, Default, PartialEq)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Resp { | ||
/// Period of time site has been producing. | ||
pub data_period: SiteDataPeriod, | ||
} | ||
|
||
/// Period of time site has been producing. | ||
#[derive(Clone, Deserialize, Debug, Default, PartialEq)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct SiteDataPeriod { | ||
/// Start date of energy production. | ||
pub start_date: Option<String>, | ||
/// End date of energy production. | ||
pub end_date: Option<String>, | ||
} | ||
|
||
impl Req { | ||
/// Create a site_data_period request message that can be sent to SolarEdge. | ||
#[must_use] | ||
pub fn new() -> Self { | ||
Req {} | ||
} | ||
} | ||
|
||
impl SendReq<Resp> for Req { | ||
fn build_url(&self, site_id: &str, api_key: &str) -> String { | ||
format!( | ||
"{}site/{}/dataPeriod?{}", | ||
*MONITORING_API_URL, site_id, api_key, | ||
) | ||
} | ||
} | ||
|
||
impl Default for Req { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use crate::is_normal; | ||
|
||
#[test] | ||
fn normal_types_unit_test() { | ||
is_normal::<Req>(); | ||
is_normal::<Resp>(); | ||
is_normal::<SiteDataPeriod>(); | ||
} | ||
} |
Oops, something went wrong.