rust-ocpp 3.0.4

ocpp 1.6, 2.0.1 and 2.1 libraries
Documentation
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use validator::Validate;

use crate::v2_1::datatypes::{AddressType, CustomDataType};
use crate::v2_1::enumerations::PaymentStatusEnumType;

/// Request to notify the CSMS about a settlement attempt.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Validate)]
#[serde(rename_all = "camelCase")]
pub struct NotifySettlementRequest {
    /// Optional. The transactionId that the settlement belongs to. Can be empty if the payment transaction is canceled prior to the start of the OCPP transaction.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[validate(length(max = 36))]
    pub transaction_id: Option<String>,

    /// Required. The payment reference received from the payment terminal and is used as the value for idToken.
    #[validate(length(max = 255))]
    pub psp_ref: String,

    /// Required. The status of the settlement attempt.
    pub status: PaymentStatusEnumType,

    /// Optional. Additional information from payment terminal/payment process.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[validate(length(max = 500))]
    pub status_info: Option<String>,

    /// Required. The amount that was settled, or attempted to be settled (in case of failure).
    pub settlement_amount: f64,

    /// Required. The time when the settlement was done.
    pub settlement_time: DateTime<Utc>,

    /// Optional. Receipt ID for this settlement.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[validate(length(max = 50))]
    pub receipt_id: Option<String>,

    /// Optional. The receipt URL, to be used if the receipt is generated by the payment terminal or the CS.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[validate(length(max = 2000))]
    pub receipt_url: Option<String>,

    /// Optional. VAT company information for a company receipt.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub vat_company: Option<AddressType>,

    /// Optional. VAT number for a company receipt.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[validate(length(max = 20))]
    pub vat_number: Option<String>,

    /// Optional. Custom data specific to this class.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub custom_data: Option<CustomDataType>,
}

/// Response to a NotifySettlementRequest.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Validate)]
#[serde(rename_all = "camelCase")]
pub struct NotifySettlementResponse {
    /// Optional. The receipt URL if receipt generated by CSMS. The Charging Station can QR encode it and show it to the EV Driver.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[validate(length(max = 2000))]
    pub receipt_url: Option<String>,

    /// Optional. The receipt id if the receipt is generated by CSMS.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[validate(length(max = 50))]
    pub receipt_id: Option<String>,

    /// Optional. Custom data specific to this class.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub custom_data: Option<CustomDataType>,
}