ocpi 0.3.5

Unofficial, in progress, OCPI implementation
Documentation
use super::{CiString, Token};

/// # 13.3.5. StartSession Object
///
/// The evse_uid is optional. If no EVSE is specified, the Charge Point can itself decide on
/// which EVSE to start a new session. (this might not be supported by all Charge Points).
///
/// The eMSP provides a Token that has to be used by the Charge Point.
/// The Token provided by the eMSP for the StartSession SHALL be authorized by the eMSP
/// before sending it to the CPO.
/// Therefor the CPO SHALL NOT check the validity of the Token provided before sending the
/// request to the Charge Point.
///
/// If this is an OCPP Charge Point, the Charge Point decides if it needs to
/// validate the given Token,
/// in such case:
///
/// * If this Token is of type: AD_HOC_USER or APP_USER
///   the CPO SHALL NOT do a realtime authorization at the eMSP for this .
///
/// * If this Token is of type: RFID,
///   the CPO SHALL NOT do a realtime authorization at the eMSP for this Token at the given
///
/// EVSE/Charge Point within 15 minutes after having received this StartSession.
/// (This means that if the driver decided to use his RFID within 15 minutes at
/// the same Charge Point, because the app is not working somehow, the RFID is already authorized)
///
/// The eMSP MAY use Tokens that have not been pushed via the Token module,
/// especially AD_HOC_USER or APP_USER Tokens are only used by commands send by an eMSP.
/// As these are never used locally at the Charge Point like RFID.
///
/// Unknown Tokens received by the CPO in the StartSession Object don’t need to be
/// stored in the Token module. In other words, when a Token has been received via StartSession,
/// the same Token does not have to be returned in a Token GET request from the eMSP.
/// However, the information of the Token SHALL be put in the Session and CDR.
///
/// An eMSP sending a StartSession SHALL only use Token that are owned by this
/// eMSP in StartSession, using Tokens of other eMSPs is not allowed.
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct StartSession {
    /// URL that the CommandResult POST should be sent to. This URL might
    /// contain an unique ID to be able to distinguish between StartSession
    /// requests.
    pub response_url: url::Url,

    /// Token object the Charge Point has to use to start a new session. The
    /// Token provided in this request is authorized by the eMSP.
    pub token: Token,

    /// Location.id of the Location (belonging to the CPO this request is send to)
    /// on which a session is to be started.
    pub location_id: CiString<36>,

    /// Optional EVSE.uid of the EVSE of this Location on which a session is to be started.
    pub evse_uid: Option<CiString<36>>,

    /// Reference to the authorization given by the eMSP, when given, this
    /// reference will be provided in the relevant Session and/or CDR.
    pub authorization_reference: Option<CiString<36>>,
}