Skip to content

Commit

Permalink
Don't expose Vereinsflieger internal protocol types
Browse files Browse the repository at this point in the history
  • Loading branch information
zargony committed Dec 10, 2024
1 parent 8a6c55b commit bd6ddbb
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 81 deletions.
22 changes: 11 additions & 11 deletions firmware/src/vereinsflieger/proto_articles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ impl<const N: usize> FromJsonObject for ArticleListResponse<N> {

/// Article
#[derive(Debug, Default)]
pub struct Article {
pub articleid: String,
pub designation: String,
pub unittype: String,
pub prices: Vec<ArticlePrice>,
struct Article {
articleid: String,
designation: String,
unittype: String,
prices: Vec<ArticlePrice>,
}

impl FromJsonObject for Article {
Expand All @@ -102,7 +102,7 @@ impl FromJsonObject for Article {

impl Article {
/// Get today's price
pub fn price(&self) -> Option<f32> {
fn price(&self) -> Option<f32> {
// TODO: Get a current date and do a real price selection based on validity dates.
// For now, we make sure to end up with the last entry valid until 9999-12-31, if any, or
// any last entry otherwise.
Expand All @@ -118,11 +118,11 @@ impl Article {

/// Article price
#[derive(Debug, Default)]
pub struct ArticlePrice {
pub validfrom: String, // "yyyy-mm-dd"
pub validto: String, // "yyyy-mm-dd"
pub salestax: f32,
pub unitprice: f32,
struct ArticlePrice {
validfrom: String, // "yyyy-mm-dd"
validto: String, // "yyyy-mm-dd"
salestax: f32,
unitprice: f32,
}

impl FromJsonObject for ArticlePrice {
Expand Down
140 changes: 70 additions & 70 deletions firmware/src/vereinsflieger/proto_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,70 +82,70 @@ impl FromJsonObject for UserListResponse {

/// User
#[derive(Debug, Default)]
pub struct User {
// pub uid: u32,
// pub title: String,
pub firstname: String,
pub lastname: String,
// pub careof: String,
// pub street: String,
// pub postofficebox: String, // undocumented
// pub zipcode: String,
// pub town: String,
// pub email: String,
// pub gender: String,
// pub birthday: String, // "dd.mm.yyyy"
// pub birthplace: String,
// pub homenumber: String,
// pub mobilenumber: String,
// pub phonenumber: String,
// pub phonenumber2: String,
// pub carlicenseplate: String,
// pub identification: String,
// pub natoid: String,
// pub policecert_validto: String, // "yyyy-mm-dd"
// pub ice_contact1: String,
// pub ice_contact2: String,
pub memberid: u32,
// pub msid: String, // undocumented
// pub memberbegin: String, // "dd.mm.yyyy"
// pub memberend: String, // "yyyy-mm-dd"
// pub lettertitle: String,
// pub cid: String, // undocumented
// pub nickname: String, // undocumented
// pub clid: String, // undocumented
// pub flightrelease: String, // undocumented
// pub flightreleasevalidto: String, // undocumented "yyyy-mm-dd"
// pub flightdiscount: String, // undocumented
// pub flightdiscount2: String, // undocumented
// pub flightdiscount3: String, // undocumented
// pub flightdiscount4: String, // undocumented
// pub flightdiscount5: String, // undocumented
// pub flightdiscount6: String, // undocumented
pub memberstatus: String,
// pub country: String,
// pub bankaccountname: String,
// pub bankaccountinfo: String, // undocumented
// pub directdebitauth: u32,
// pub iban: String,
// pub bic: String,
// pub mandate: String,
// pub roles: Vec<String>,
// pub mandatedate: String, // "yyyy-mm-dd"
// pub mailrecipient: u32,
// pub sector: Vec<String>,
// pub functions: Vec<String>,
// pub educations: Vec<String>,
// pub prop0: [String, String],
// pub prop1: [String, String],
// pub prop2: [String, String],
// pub accounts: Vec<UserAccountDescription>,
pub keymanagement: Vec<Key>,
// pub stateassociation: Vec<String>,
// pub key1designation: String, // undocumented
// pub key2designation: String, // undocumented
// pub keyrfid: String, // undocumented
// pub whtodo: UserWhTodoList, // undocumented
struct User {
// uid: u32,
// title: String,
firstname: String,
lastname: String,
// careof: String,
// street: String,
// postofficebox: String, // undocumented
// zipcode: String,
// town: String,
// email: String,
// gender: String,
// birthday: String, // "dd.mm.yyyy"
// birthplace: String,
// homenumber: String,
// mobilenumber: String,
// phonenumber: String,
// phonenumber2: String,
// carlicenseplate: String,
// identification: String,
// natoid: String,
// policecert_validto: String, // "yyyy-mm-dd"
// ice_contact1: String,
// ice_contact2: String,
memberid: u32,
// msid: String, // undocumented
// memberbegin: String, // "dd.mm.yyyy"
// memberend: String, // "yyyy-mm-dd"
// lettertitle: String,
// cid: String, // undocumented
// nickname: String, // undocumented
// clid: String, // undocumented
// flightrelease: String, // undocumented
// flightreleasevalidto: String, // undocumented "yyyy-mm-dd"
// flightdiscount: String, // undocumented
// flightdiscount2: String, // undocumented
// flightdiscount3: String, // undocumented
// flightdiscount4: String, // undocumented
// flightdiscount5: String, // undocumented
// flightdiscount6: String, // undocumented
memberstatus: String,
// country: String,
// bankaccountname: String,
// bankaccountinfo: String, // undocumented
// directdebitauth: u32,
// iban: String,
// bic: String,
// mandate: String,
// roles: Vec<String>,
// mandatedate: String, // "yyyy-mm-dd"
// mailrecipient: u32,
// sector: Vec<String>,
// functions: Vec<String>,
// educations: Vec<String>,
// prop0: [String, String],
// prop1: [String, String],
// prop2: [String, String],
// accounts: Vec<UserAccountDescription>,
keymanagement: Vec<Key>,
// stateassociation: Vec<String>,
// key1designation: String, // undocumented
// key2designation: String, // undocumented
// keyrfid: String, // undocumented
// whtodo: UserWhTodoList, // undocumented
}

impl FromJsonObject for User {
Expand All @@ -171,12 +171,12 @@ impl FromJsonObject for User {

impl User {
/// Whether the user has/was retired ("ausgeschieden")
pub fn is_retired(&self) -> bool {
fn is_retired(&self) -> bool {
self.memberstatus.to_lowercase().contains("ausgeschieden")
}

/// Get key numbers with the given label prefix
pub fn keys_named_with_prefix(&self, prefix: &str) -> Vec<&str> {
fn keys_named_with_prefix(&self, prefix: &str) -> Vec<&str> {
self.keymanagement
.iter()
.filter(|key| key.title.starts_with(prefix))
Expand All @@ -187,12 +187,12 @@ impl User {

/// User keymanagement
#[derive(Debug, Default)]
pub struct Key {
struct Key {
/// Key label
pub title: String,
title: String,
/// Key number
pub keyname: String,
// pub rfidkey: u32, // undocumented
keyname: String,
// rfidkey: u32, // undocumented
}

impl FromJsonObject for Key {
Expand Down

0 comments on commit bd6ddbb

Please sign in to comment.