ocpi 0.3.5

Unofficial, in progress, OCPI implementation
Documentation
use super::{
    AuthMethod, CdrToken, ChargingPeriod, CiString, CsString, DateTime, Price, SessionStatus,
};

#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Session {
    /// ISO-3166 alpha-2 country code of the CPO that 'owns' this
    /// Session
    pub country_code: CiString<2>,

    /// CPO ID of the CPO that 'owns' this Session (following the ISO-
    /// 15118 standard).
    pub party_id: CiString<3>,

    /// The unique id that identifies the charging session in the CPO
    /// platform.
    pub id: CiString<36>,

    /// The timestamp when the session became ACTIVE in the Charge Point.
    /// When the session is still PENDING, this field SHALL be set to the
    /// time the Session was created at the Charge Point. When a Session
    /// goes from PENDING to ACTIVE, this field SHALL be update to the
    /// moment the Session went to ACTIVE in the Charge Point.
    pub start_date_time: DateTime,

    /// The timestamp when the session was completed/finished, charging
    /// might have finished before the session ends, for example: EV is full,
    /// but parking cost also has to be paid.
    pub end_date_time: Option<DateTime>,

    /// How many kWh were charged.
    pub kwh: f64,

    /// Token used to start this charging session, including all the relevant
    /// information to identify the unique token.
    pub cdr_token: CdrToken,

    /// Method used for authentication.
    pub auth_method: AuthMethod,

    /// Reference to the authorization given by the eMSP. When the eMSP
    /// provided an authorization_reference in either: real-time
    /// authorization or StartSession, this field SHALL contain the same
    /// value. When different authorization_reference values have
    /// been given by the eMSP that are relevant to this Session, the last
    /// given value SHALL be used here.
    pub authorization_reference: Option<CiString<36>>,

    /// Location.id of the Location object of this CPO, on which the
    /// charging session is/was happening.
    pub location_id: CiString<36>,

    /// EVSE.uid of the EVSE of this Location on which the charging
    /// session is/was happening.
    pub evse_uid: CiString<36>,

    /// Optional identification of the kWh meter.
    pub meter_id: Option<CsString<255>>,

    /// ISO 4217 code of the currency used for this session.
    pub currency: CsString<3>,

    /// An optional list of Charging Periods that can be used to calculate
    /// and verify the total cost.
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub charging_periods: Vec<ChargingPeriod>,

    /// The total cost of the session in the specified currency. This is the
    /// price that the eMSP will have to pay to the CPO. A total_cost of
    /// 0.00 means free of charge. When omitted, i.e. no price information
    /// is given in the Session object, it does not imply the session is/was
    /// free of charge.
    pub total_cost: Option<Price>,

    /// The status of the session.
    pub status: SessionStatus,

    /// Timestamp when this Session was last updated (or created).
    pub last_updated: DateTime,
}