ocpi 0.3.5

Unofficial, in progress, OCPI implementation
Documentation
use super::{
    CiString, CsString, DateTime, EnergyContract, Language, ProfileType, TokenType, WhitelistType,
};

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

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

    /// Unique ID by which this Token can be identified.
    /// This is the field used by CPO system (RFID reader on the Charge Point) to
    /// identify this token.
    /// Currently, in most cases: type=RFID, this is the RFID hidden ID as read by the
    /// RFID reader, but that is not a requirement.
    /// If this is a APP_USER or AD_HOC_USER Token, it will be a uniquely, by the eMSP,
    /// generated ID.
    /// This field is named uid instead of id to prevent confusion with: contract_id.
    pub uid: CiString<36>,

    #[serde(rename = "type")]
    pub typ: TokenType,

    /// Uniquely identifies the EV Driver contract token within the eMSP’s platform (and
    /// suboperator platforms). Recommended to follow the specification for eMA ID
    /// from "eMI3 standard version V1.0" (http://emi3group.com/documents-links/)
    /// "Part 2: business objects."
    pub contract_id: CiString<36>,

    /// Visual readable number/identification as printed on the Token (RFID card),
    /// might be equal to the contract_id.
    pub visual_number: Option<CsString<64>>,

    /// Issuing company, most of the times the name of the company printed on the
    /// token (RFID card), not necessarily the eMSP.
    pub issuer: CsString<64>,

    /// This ID groups a couple of tokens. This can be used to make two or more
    /// tokens work as one, so that a session can be started with one token and
    /// stopped with another, handy when a card and key-fob are given to the EV-driver.
    /// Beware that OCPP 1.5/1.6 only support group_ids (it is called parentId in OCPP 1.5/1.6)
    /// with a maximum length of 20.
    pub group_id: Option<CiString<36>>,

    pub valid: bool,
    /// Indicates what type of white-listing is allowed.
    pub whitelist: WhitelistType,

    /// Language Code ISO 639-1. This optional field indicates the Token owner’s
    /// preferred interface language.
    /// If the language is not provided or not supported then the
    /// CPO is free to choose its own language.
    pub language: Option<Language>,

    /// The default Charging Preference. When this is provided, and a charging session
    /// is started on an Charge Point that support Preference base Smart Charging and
    /// support this ProfileType, the Charge Point can start using this ProfileType,
    /// without this having to be set via: Set Charging Preferences.
    pub default_profile_type: Option<ProfileType>,

    /// When the Charge Point supports using your own energy supplier/contract at a
    /// Charge Point, information about the energy supplier/contract is needed so the
    /// CPO knows which energy supplier to use.
    ///  **NOTE**: In a lot of countries it is currently not allowed/possible to use a drivers
    /// own energy supplier/contract at a Charge Point.
    pub energy_contract: Option<EnergyContract>,

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