strava_wrapper/
models.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
4pub struct Activity {
5    pub id: i64,
6    pub resource_state: u8,
7    pub external_id: Option<String>,
8    pub upload_id: Option<i64>,
9    pub athlete: SimpleAthlete,
10    pub name: String,
11    pub distance: f64,
12    pub moving_time: i32,
13    pub elapsed_time: i32,
14    pub total_elevation_gain: f64,
15    #[serde(rename = "type")]
16    pub activity_type: String,
17    pub sport_type: String,
18    pub start_date: String,
19    pub start_date_local: String,
20    pub timezone: String,
21    pub utc_offset: f64,
22    pub achievement_count: i32,
23    pub kudos_count: i32,
24    pub comment_count: i32,
25    pub athlete_count: i32,
26    pub photo_count: i32,
27    pub map: Map,
28    pub trainer: bool,
29    pub commute: bool,
30    pub manual: bool,
31    pub private: bool,
32    pub flagged: bool,
33    pub gear_id: Option<String>,
34    pub from_accepted_tag: Option<bool>,
35    pub average_speed: f64,
36    pub max_speed: f64,
37    pub device_watts: bool,
38    pub has_heartrate: bool,
39    pub pr_count: i32,
40    pub total_photo_count: i32,
41    pub has_kudoed: bool,
42    pub workout_type: Option<i32>,
43    pub description: Option<String>,
44    pub calories: Option<f64>,
45    pub segment_efforts: Option<Vec<SegmentEffort>>,
46}
47
48#[derive(Serialize, Debug)]
49pub struct CreateActivity {
50    pub name: String,
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub activity_type: Option<String>,
53    pub sport_type: String,
54    pub start_date_local: String,
55    pub elapsed_time: i32,
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub description: Option<String>,
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub distance: Option<f64>,
60    #[serde(skip_serializing_if = "Option::is_none")]
61    pub trainer: Option<i32>,
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub commute: Option<i32>,
64}
65
66#[derive(Debug, Deserialize)]
67struct SimpleActivity {
68    id: i64,
69    resource_state: i32,
70}
71
72#[derive(Debug, Deserialize)]
73pub struct Lap {
74    id: i64,
75    resource_state: i32,
76    name: String,
77    activity: SimpleActivity,
78    athlete: SimpleAthlete,
79    elapsed_time: i32,
80    moving_time: i32,
81    start_date: String,
82    start_date_local: String,
83    distance: f64,
84    start_index: i32,
85    end_index: i32,
86    total_elevation_gain: f64,
87    average_speed: f64,
88    max_speed: f64,
89    average_cadence: f64,
90    device_watts: bool,
91    average_watts: f64,
92    lap_index: i32,
93    split: i32,
94}
95
96#[derive(Debug, Serialize, Deserialize)]
97pub struct Zones {
98    score: i32,
99    sensor_based: bool,
100    custom_zones: bool,
101    max: i32,
102    distribution_buckets: String,
103    #[serde(rename = "type")]
104    data_type: String,
105    points: i32,
106}
107
108#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
109pub struct SimpleAthlete {
110    pub id: i64,
111    pub resource_state: u8,
112}
113
114#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
115pub struct Map {
116    pub id: String,
117    pub polyline: Option<String>,
118    pub resource_state: u8,
119}
120
121#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
122pub struct SegmentEffort {}
123
124#[derive(Debug, Deserialize, PartialEq)]
125pub struct Comment {
126    id: i64,
127    activity_id: i64,
128    post_id: Option<i64>,
129    resource_state: i32,
130    text: String,
131    mentions_metadata: Option<String>,
132    created_at: String,
133    athlete: User,
134    cursor: Option<String>,
135    reaction_count: i32,
136    has_reacted: bool,
137}
138
139#[derive(Debug, Deserialize, PartialEq)]
140pub struct User {
141    firstname: String,
142    lastname: String,
143    resource_state: Option<i32>,
144}