#![allow(unused_imports, clippy::doc_markdown, clippy::struct_excessive_bools)]
#![allow(
clippy::too_many_lines,
clippy::too_many_arguments,
clippy::wildcard_imports
)]
#![allow(clippy::match_same_arms, clippy::fn_params_excessive_bools)]
use alloc::string::String;
use alloc::vec::Vec;
use serde::{Deserialize, Serialize};
use super::enums::*;
use crate::validate::{self, Validate, ValidationPath, Violations};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct AuthorizationData {
#[serde(rename = "idTag")]
pub id_tag: String,
#[serde(rename = "idTagInfo")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub id_tag_info: Option<IdTagInfo>,
}
impl AuthorizationData {
#[must_use]
pub fn new(id_tag: impl Into<String>) -> Self {
Self {
id_tag: id_tag.into(),
id_tag_info: None,
}
}
#[must_use]
pub fn with_id_tag_info(mut self, value: IdTagInfo) -> Self {
self.id_tag_info = Some(value);
self
}
}
impl Validate for AuthorizationData {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("idTag");
validate::string(self.id_tag.as_str(), None, Some(20), path, out);
path.pop();
path.push_key("idTagInfo");
if let Some(value) = &self.id_tag_info {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct CertificateHashData {
#[serde(rename = "hashAlgorithm")]
pub hash_algorithm: HashAlgorithm,
#[serde(rename = "issuerNameHash")]
pub issuer_name_hash: String,
#[serde(rename = "issuerKeyHash")]
pub issuer_key_hash: String,
#[serde(rename = "serialNumber")]
pub serial_number: String,
}
impl CertificateHashData {
#[must_use]
pub fn new(
hash_algorithm: HashAlgorithm,
issuer_name_hash: impl Into<String>,
issuer_key_hash: impl Into<String>,
serial_number: impl Into<String>,
) -> Self {
Self {
hash_algorithm,
issuer_name_hash: issuer_name_hash.into(),
issuer_key_hash: issuer_key_hash.into(),
serial_number: serial_number.into(),
}
}
}
impl Validate for CertificateHashData {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("hashAlgorithm");
Validate::validate_at(&self.hash_algorithm, path, out);
path.pop();
path.push_key("issuerNameHash");
validate::string(self.issuer_name_hash.as_str(), None, Some(128), path, out);
path.pop();
path.push_key("issuerKeyHash");
validate::string(self.issuer_key_hash.as_str(), None, Some(128), path, out);
path.pop();
path.push_key("serialNumber");
validate::string(self.serial_number.as_str(), None, Some(40), path, out);
path.pop();
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ChargingProfile {
#[serde(rename = "chargingProfileId")]
pub charging_profile_id: i32,
#[serde(rename = "stackLevel")]
pub stack_level: i32,
#[serde(rename = "chargingProfilePurpose")]
pub charging_profile_purpose: ChargingProfilePurpose,
#[serde(rename = "chargingProfileKind")]
pub charging_profile_kind: ChargingProfileKind,
#[serde(rename = "chargingSchedule")]
pub charging_schedule: ChargingSchedule,
#[serde(rename = "transactionId")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub transaction_id: Option<i32>,
#[serde(rename = "recurrencyKind")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub recurrency_kind: Option<RecurrencyKind>,
#[serde(rename = "validFrom")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub valid_from: Option<crate::types::DateTime>,
#[serde(rename = "validTo")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub valid_to: Option<crate::types::DateTime>,
}
impl ChargingProfile {
#[must_use]
pub fn new(
charging_profile_id: i32,
stack_level: i32,
charging_profile_purpose: ChargingProfilePurpose,
charging_profile_kind: ChargingProfileKind,
charging_schedule: ChargingSchedule,
) -> Self {
Self {
charging_profile_id,
stack_level,
charging_profile_purpose,
charging_profile_kind,
charging_schedule,
transaction_id: None,
recurrency_kind: None,
valid_from: None,
valid_to: None,
}
}
#[must_use]
pub fn with_transaction_id(mut self, value: i32) -> Self {
self.transaction_id = Some(value);
self
}
#[must_use]
pub fn with_recurrency_kind(mut self, value: RecurrencyKind) -> Self {
self.recurrency_kind = Some(value);
self
}
#[must_use]
pub fn with_valid_from(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.valid_from = Some(value.into());
self
}
#[must_use]
pub fn with_valid_to(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.valid_to = Some(value.into());
self
}
}
impl Validate for ChargingProfile {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("chargingProfilePurpose");
Validate::validate_at(&self.charging_profile_purpose, path, out);
path.pop();
path.push_key("chargingProfileKind");
Validate::validate_at(&self.charging_profile_kind, path, out);
path.pop();
path.push_key("chargingSchedule");
Validate::validate_at(&self.charging_schedule, path, out);
path.pop();
path.push_key("recurrencyKind");
if let Some(value) = &self.recurrency_kind {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ChargingSchedule {
#[serde(rename = "chargingRateUnit")]
pub charging_rate_unit: ChargingRateUnit,
#[serde(rename = "chargingSchedulePeriod")]
pub charging_schedule_period: Vec<ChargingSchedulePeriod>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub duration: Option<i32>,
#[serde(rename = "startSchedule")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub start_schedule: Option<crate::types::DateTime>,
#[serde(rename = "minChargingRate")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_charging_rate: Option<crate::types::Decimal>,
}
impl ChargingSchedule {
#[must_use]
pub fn new(
charging_rate_unit: ChargingRateUnit,
charging_schedule_period: Vec<ChargingSchedulePeriod>,
) -> Self {
Self {
charging_rate_unit,
charging_schedule_period,
duration: None,
start_schedule: None,
min_charging_rate: None,
}
}
#[must_use]
pub fn with_duration(mut self, value: i32) -> Self {
self.duration = Some(value);
self
}
#[must_use]
pub fn with_start_schedule(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.start_schedule = Some(value.into());
self
}
#[must_use]
pub fn with_min_charging_rate(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_charging_rate = Some(value.into());
self
}
}
impl Validate for ChargingSchedule {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("chargingRateUnit");
Validate::validate_at(&self.charging_rate_unit, path, out);
path.pop();
path.push_key("chargingSchedulePeriod");
for (index, item) in self.charging_schedule_period.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ChargingSchedulePeriod {
#[serde(rename = "startPeriod")]
pub start_period: i32,
pub limit: crate::types::Decimal,
#[serde(rename = "numberPhases")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub number_phases: Option<i32>,
}
impl ChargingSchedulePeriod {
#[must_use]
pub fn new(start_period: i32, limit: impl Into<crate::types::Decimal>) -> Self {
Self {
start_period,
limit: limit.into(),
number_phases: None,
}
}
#[must_use]
pub fn with_number_phases(mut self, value: i32) -> Self {
self.number_phases = Some(value);
self
}
}
impl Validate for ChargingSchedulePeriod {
fn validate_at(&self, _path: &mut ValidationPath, _out: &mut Violations) {}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Firmware {
pub location: String,
#[serde(rename = "retrieveDateTime")]
pub retrieve_date_time: crate::types::DateTime,
#[serde(rename = "signingCertificate")]
pub signing_certificate: String,
pub signature: String,
#[serde(rename = "installDateTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub install_date_time: Option<crate::types::DateTime>,
}
impl Firmware {
#[must_use]
pub fn new(
location: impl Into<String>,
retrieve_date_time: impl Into<crate::types::DateTime>,
signing_certificate: impl Into<String>,
signature: impl Into<String>,
) -> Self {
Self {
location: location.into(),
retrieve_date_time: retrieve_date_time.into(),
signing_certificate: signing_certificate.into(),
signature: signature.into(),
install_date_time: None,
}
}
#[must_use]
pub fn with_install_date_time(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.install_date_time = Some(value.into());
self
}
}
impl Validate for Firmware {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("location");
validate::string(self.location.as_str(), None, Some(512), path, out);
path.pop();
path.push_key("signingCertificate");
validate::string(
self.signing_certificate.as_str(),
None,
Some(5500),
path,
out,
);
path.pop();
path.push_key("signature");
validate::string(self.signature.as_str(), None, Some(800), path, out);
path.pop();
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct IdTagInfo {
pub status: AuthorizationStatus,
#[serde(rename = "expiryDate")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub expiry_date: Option<crate::types::DateTime>,
#[serde(rename = "parentIdTag")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub parent_id_tag: Option<String>,
}
impl IdTagInfo {
#[must_use]
pub fn new(status: AuthorizationStatus) -> Self {
Self {
status,
expiry_date: None,
parent_id_tag: None,
}
}
#[must_use]
pub fn with_expiry_date(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.expiry_date = Some(value.into());
self
}
#[must_use]
pub fn with_parent_id_tag(mut self, value: impl Into<String>) -> Self {
self.parent_id_tag = Some(value.into());
self
}
}
impl Validate for IdTagInfo {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("status");
Validate::validate_at(&self.status, path, out);
path.pop();
path.push_key("parentIdTag");
if let Some(value) = &self.parent_id_tag {
validate::string(value.as_str(), None, Some(20), path, out);
}
path.pop();
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct KeyValue {
pub key: String,
pub readonly: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
}
impl KeyValue {
#[must_use]
pub fn new(key: impl Into<String>, readonly: bool) -> Self {
Self {
key: key.into(),
readonly,
value: None,
}
}
#[must_use]
pub fn with_value(mut self, value: impl Into<String>) -> Self {
self.value = Some(value.into());
self
}
}
impl Validate for KeyValue {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("key");
validate::string(self.key.as_str(), None, Some(50), path, out);
path.pop();
path.push_key("value");
if let Some(value) = &self.value {
validate::string(value.as_str(), None, Some(500), path, out);
}
path.pop();
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct LogParameters {
#[serde(rename = "remoteLocation")]
pub remote_location: String,
#[serde(rename = "oldestTimestamp")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub oldest_timestamp: Option<crate::types::DateTime>,
#[serde(rename = "latestTimestamp")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub latest_timestamp: Option<crate::types::DateTime>,
}
impl LogParameters {
#[must_use]
pub fn new(remote_location: impl Into<String>) -> Self {
Self {
remote_location: remote_location.into(),
oldest_timestamp: None,
latest_timestamp: None,
}
}
#[must_use]
pub fn with_oldest_timestamp(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.oldest_timestamp = Some(value.into());
self
}
#[must_use]
pub fn with_latest_timestamp(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.latest_timestamp = Some(value.into());
self
}
}
impl Validate for LogParameters {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("remoteLocation");
validate::string(self.remote_location.as_str(), None, Some(512), path, out);
path.pop();
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MeterValue {
pub timestamp: crate::types::DateTime,
#[serde(rename = "sampledValue")]
pub sampled_value: Vec<SampledValue>,
}
impl MeterValue {
#[must_use]
pub fn new(
timestamp: impl Into<crate::types::DateTime>,
sampled_value: Vec<SampledValue>,
) -> Self {
Self {
timestamp: timestamp.into(),
sampled_value,
}
}
}
impl Validate for MeterValue {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("sampledValue");
validate::list_len(self.sampled_value.len(), Some(1), None, path, out);
for (index, item) in self.sampled_value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SampledValue {
pub value: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub context: Option<ReadingContext>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub format: Option<ValueFormat>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub measurand: Option<Measurand>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub phase: Option<Phase>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub location: Option<Location>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub unit: Option<UnitOfMeasure>,
}
impl SampledValue {
#[must_use]
pub fn new(value: impl Into<String>) -> Self {
Self {
value: value.into(),
context: None,
format: None,
measurand: None,
phase: None,
location: None,
unit: None,
}
}
#[must_use]
pub fn with_context(mut self, value: ReadingContext) -> Self {
self.context = Some(value);
self
}
#[must_use]
pub fn with_format(mut self, value: ValueFormat) -> Self {
self.format = Some(value);
self
}
#[must_use]
pub fn with_measurand(mut self, value: Measurand) -> Self {
self.measurand = Some(value);
self
}
#[must_use]
pub fn with_phase(mut self, value: Phase) -> Self {
self.phase = Some(value);
self
}
#[must_use]
pub fn with_location(mut self, value: Location) -> Self {
self.location = Some(value);
self
}
#[must_use]
pub fn with_unit(mut self, value: UnitOfMeasure) -> Self {
self.unit = Some(value);
self
}
}
impl Validate for SampledValue {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("context");
if let Some(value) = &self.context {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("format");
if let Some(value) = &self.format {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("measurand");
if let Some(value) = &self.measurand {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("phase");
if let Some(value) = &self.phase {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("location");
if let Some(value) = &self.location {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("unit");
if let Some(value) = &self.unit {
Validate::validate_at(value, path, out);
}
path.pop();
}
}