Skip to main content

mlbt_api/
team.rs

1use crate::live::{FullPlayer, PrimaryPosition};
2
3use serde::Deserialize;
4use std::fmt;
5
6#[derive(Clone, Copy, Debug, Eq, PartialEq)]
7pub enum RosterType {
8    Active,
9    FortyMan,
10}
11
12impl fmt::Display for RosterType {
13    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
14        match self {
15            RosterType::Active => write!(f, "active"),
16            RosterType::FortyMan => write!(f, "40Man"),
17        }
18    }
19}
20
21#[derive(Default, Debug, Deserialize)]
22pub struct RosterResponse {
23    pub roster: Vec<RosterEntry>,
24}
25
26#[derive(Debug, Deserialize)]
27#[serde(rename_all = "camelCase")]
28pub struct RosterEntry {
29    pub person: FullPlayer,
30    pub jersey_number: Option<String>,
31    pub position: PrimaryPosition,
32    pub status: RosterStatus,
33    pub parent_team_id: Option<u16>,
34}
35
36#[derive(Debug, Deserialize)]
37pub struct RosterStatus {
38    pub code: String,
39    pub description: String,
40}
41
42#[derive(Default, Debug, Deserialize)]
43pub struct TransactionsResponse {
44    pub transactions: Vec<Transaction>,
45}
46
47#[derive(Debug, Deserialize)]
48#[serde(rename_all = "camelCase")]
49pub struct Transaction {
50    pub id: u64,
51    pub person: Option<TransactionEntity>,
52    pub from_team: Option<TransactionEntity>,
53    pub to_team: Option<TransactionEntity>,
54    pub date: Option<String>,
55    pub effective_date: Option<String>,
56    pub resolution_date: Option<String>,
57    pub type_code: Option<String>,
58    pub type_desc: Option<String>,
59    pub description: Option<String>,
60}
61
62/// Lightweight id+name reference used in transaction records.
63/// Separate from `IdNameLink` because person ids exceed u16.
64#[derive(Debug, Deserialize)]
65pub struct TransactionEntity {
66    pub id: u64,
67    pub name: Option<String>,
68}