Skip to content

Commit

Permalink
separate Program from IdInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Tropix126 committed Dec 17, 2023
1 parent 20f5a6c commit fdf1fdf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 27 deletions.
28 changes: 2 additions & 26 deletions src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod ranking;
pub mod season;
pub mod skill;
pub mod team;
pub mod program;

pub use award::*;
pub use event::*;
Expand All @@ -15,6 +16,7 @@ pub use ranking::*;
pub use season::*;
pub use skill::*;
pub use team::*;
pub use program::*;

use crate::{RobotEvents, V2_API_BASE};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
Expand Down Expand Up @@ -108,31 +110,5 @@ impl<T: DeserializeOwned> PaginatedResponse<T> {
pub struct IdInfo {
pub id: i32,
pub name: String,
#[serde(alias = "abbr")]
pub code: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Grade {
College,

#[serde(rename = "High School")]
HighSchool,

#[serde(rename = "Middle School")]
MiddleSchool,

#[serde(rename = "Elementary School")]
ElementarySchool,
}

impl std::fmt::Display for Grade {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(match self {
Self::College => "College",
Self::HighSchool => "High School",
Self::MiddleSchool => "Middle School",
Self::ElementarySchool => "Elementary School",
})
}
}
8 changes: 8 additions & 0 deletions src/schema/program.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Program {
pub id: i32,
pub name: String,
pub abbr: String,
}
27 changes: 26 additions & 1 deletion src/schema/team.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,35 @@ use crate::{
filters::{
TeamAwardsFilter, TeamEventsFilter, TeamMatchesFilter, TeamRankingsFilter, TeamSkillsFilter,
},
schema::{Award, Event, Grade, IdInfo, Location, Match, PaginatedResponse, Ranking, Skill},
schema::{Award, Event, IdInfo, Location, Match, PaginatedResponse, Ranking, Skill},
};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Grade {
College,

#[serde(rename = "High School")]
HighSchool,

#[serde(rename = "Middle School")]
MiddleSchool,

#[serde(rename = "Elementary School")]
ElementarySchool,
}

impl std::fmt::Display for Grade {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(match self {
Self::College => "College",
Self::HighSchool => "High School",
Self::MiddleSchool => "Middle School",
Self::ElementarySchool => "Elementary School",
})
}
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Team {
pub id: i32,
Expand Down

0 comments on commit fdf1fdf

Please sign in to comment.