Skip to main content

tmflib/tmf909/
usage_volume_balance.rs

1use super::Quantity;
2use crate::TimePeriod;
3use serde::{Deserialize, Serialize};
4
5///The balance (called UsageVolumeBalance in the SID model) defines the remaining allowed product usage quantity in terms of volume, time, currency or events. It corresponds to the initial allowed usage quantity minus the usage consumed on the bucket.
6#[derive(Debug, Clone, Serialize, Deserialize, Default)]
7pub struct UsageVolumeBalance {
8    ///When sub-classing, this defines the super-class
9    #[serde(rename = "@baseType")]
10    #[serde(default, skip_serializing_if = "Option::is_none")]
11    pub base_type: Option<String>,
12    ///A URI to a JSON-Schema file that defines additional attributes and relationships
13    #[serde(rename = "@schemaLocation")]
14    #[serde(default, skip_serializing_if = "Option::is_none")]
15    pub schema_location: Option<String>,
16    ///When sub-classing, this defines the sub-class Extensible name
17    #[serde(rename = "@type")]
18    #[serde(default, skip_serializing_if = "Option::is_none")]
19    pub type_: Option<String>,
20    ///Hyperlink reference
21    #[serde(default, skip_serializing_if = "Option::is_none")]
22    pub href: Option<String>,
23    ///unique identifier
24    #[serde(default, skip_serializing_if = "Option::is_none")]
25    pub id: Option<String>,
26    ///An amount in a given unit
27    #[serde(rename = "remainingValue")]
28    #[serde(default, skip_serializing_if = "Option::is_none")]
29    pub remaining_value: Option<Quantity>,
30    ///Remaining value in a formatted string for the bucket given in the balance unit (for example 1.9 Gb). This formatted string could be used for display needs for example
31    #[serde(rename = "remainingValueName")]
32    #[serde(default, skip_serializing_if = "Option::is_none")]
33    pub remaining_value_name: Option<String>,
34    ///A period of time, either as a deadline (endDateTime only) a startDateTime only, or both
35    #[serde(rename = "validFor")]
36    #[serde(default, skip_serializing_if = "Option::is_none")]
37    pub valid_for: Option<TimePeriod>,
38}
39impl std::fmt::Display for UsageVolumeBalance {
40    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
41        write!(f, "{}", serde_json::to_string(self).unwrap())
42    }
43}