add barcodes

This commit is contained in:
JMARyA 2024-10-08 10:42:21 +02:00
parent 64e23cc4ab
commit b057c46cbe
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -43,6 +43,8 @@ pub struct Variant {
pub min: Option<i64>,
/// Days until expiry
pub expiry: Option<i64>,
/// Associated barcodes
pub barcodes: Option<Vec<i64>>
}
impl Variant {
@ -69,6 +71,9 @@ impl Variant {
.unwrap()
.get("expiry")
.map(|x| x.as_i64().unwrap()),
barcodes: json.as_mapping().unwrap().get("barcodes").map(|x| {
x.as_sequence().unwrap().into_iter().map(|x| x.as_i64().unwrap()).collect()
})
}
}
@ -294,7 +299,8 @@ impl Variant {
"variant": self.variant,
"name": self.name,
"min": self.min,
"expiry": self.expiry
"expiry": self.expiry,
"barcodes": self.barcodes
})
}
}