strava_wrapper/
endpoints.rs

1use crate::filters::activities::GetActivity;
2use crate::filters::activity_zones::ListActivityZones;
3use crate::filters::athlete::{GetAthlete, ListAthleteActivities, ListAthleteClubs};
4use crate::filters::athlete_zones::GetAthleteZones;
5use crate::filters::clubs::{GetClub, GetClubMembers, ListClubActivities, ListClubAdmins};
6use crate::filters::comments::ListActivityComments;
7use crate::filters::gear::GetGear;
8use crate::filters::kudos::ListActivityKudoers;
9use crate::filters::laps::ListActivityLaps;
10use crate::filters::routes::{ExportGPXRoute, ExportTCXRoute, GetRoute, ListAthleteRoutes};
11use crate::filters::segment_efforts::{GetSegmentEffort, ListSegmentEfforts};
12use crate::filters::segments::{ExploreSegments, GetSegment, ListStarredSegments};
13use crate::filters::stats::GetAthleteStats;
14use crate::query::Endpoint;
15
16pub struct ActivitiesEndpoint {
17    url: String,
18    token: String,
19}
20
21impl ActivitiesEndpoint {
22    pub fn new(url: impl Into<String>, token: impl Into<String>) -> Self {
23        Self {
24            url: url.into(),
25            token: token.into(),
26        }
27    }
28    pub fn get(&self) -> GetActivity {
29        GetActivity::new(&self.url, &self.token, "v3/activities/{id}")
30    }
31
32    pub fn comments(&self) -> ListActivityComments {
33        ListActivityComments::new(&self.url, &self.token, "v3/activities/{id}/comments")
34    }
35
36    pub fn kudos(&self) -> ListActivityKudoers {
37        ListActivityKudoers::new(&self.url, &self.token, "v3/activities/{id}/kudos")
38    }
39    pub fn laps(&self) -> ListActivityLaps {
40        ListActivityLaps::new(&self.url, &self.token, "v3/activities/{id}/laps")
41    }
42
43    pub fn zones(&self) -> ListActivityZones {
44        ListActivityZones::new(&self.url, &self.token, "v3/activities/{id}/zones")
45    }
46
47    pub fn update(&self) -> () {
48        todo!()
49    }
50
51    pub fn create(&self) -> () {
52        todo!()
53    }
54}
55pub struct AthleteEndpoint {
56    url: String,
57    token: String,
58}
59
60impl AthleteEndpoint {
61    pub fn new(url: impl Into<String>, token: impl Into<String>) -> Self {
62        Self {
63            url: url.into(),
64            token: token.into(),
65        }
66    }
67    pub fn get(&self) -> GetAthlete {
68        GetAthlete::new(&self.url, &self.token, "v3/athlete")
69    }
70
71    pub fn zones(&self) -> GetAthleteZones {
72        GetAthleteZones::new(&self.url, &self.token, "v3/athlete/zones")
73    }
74
75    pub fn clubs(&self) -> ListAthleteClubs {
76        ListAthleteClubs::new(&self.url, &self.token, "v3/athlete/clubs")
77    }
78
79    pub fn activities(&self) -> ListAthleteActivities {
80        ListAthleteActivities::new(&self.url, &self.token, "v3/athlete/activities")
81    }
82    pub fn update(&self) -> () {
83        todo!()
84    }
85}
86pub struct AthletesEndpoint {
87    url: String,
88    token: String,
89}
90
91impl AthletesEndpoint {
92    pub fn new(url: impl Into<String>, token: impl Into<String>) -> Self {
93        Self {
94            url: url.into(),
95            token: token.into(),
96        }
97    }
98
99    pub fn stats(&self) -> GetAthleteStats {
100        GetAthleteStats::new(&self.url, &self.token, "v3/athletes/{id}/stats")
101    }
102
103    pub fn routes(&self) -> ListAthleteRoutes {
104        ListAthleteRoutes::new(&self.url, &self.token, "v3/athletes/{id}/routes")
105    }
106}
107
108pub struct ClubsEndpoint {
109    url: String,
110    token: String,
111}
112
113impl ClubsEndpoint {
114    pub fn new(url: impl Into<String>, token: impl Into<String>) -> Self {
115        Self {
116            url: url.into(),
117            token: token.into(),
118        }
119    }
120    pub fn activities(&self) -> ListClubActivities {
121        ListClubActivities::new(&self.url, &self.token, "v3/clubs/{id}/activities")
122    }
123
124    pub fn admins(&self) -> ListClubAdmins {
125        ListClubAdmins::new(&self.url, &self.token, "v3/clubs/{id}/admins")
126    }
127
128    pub fn get(&self) -> GetClub {
129        GetClub::new(&self.url, &self.token, "v3/clubs/{id}")
130    }
131
132    pub fn members(&self) -> GetClubMembers {
133        GetClubMembers::new(&self.url, &self.token, "v3/clubs/{id}/members")
134    }
135}
136
137pub struct GearEndpoint {
138    url: String,
139    token: String,
140}
141
142impl GearEndpoint {
143    pub fn new(url: impl Into<String>, token: impl Into<String>) -> Self {
144        Self {
145            url: url.into(),
146            token: token.into(),
147        }
148    }
149    pub fn get(&self) -> GetGear {
150        GetGear::new(&self.url, &self.token, "v3/gear/{id}")
151    }
152}
153
154pub struct RoutesEndpoint {
155    url: String,
156    token: String,
157}
158
159impl RoutesEndpoint {
160    pub fn new(url: impl Into<String>, token: impl Into<String>) -> Self {
161        Self {
162            url: url.into(),
163            token: token.into(),
164        }
165    }
166    pub fn export(&self) -> ExportRoute {
167        ExportRoute::new(&self.url, &self.token)
168    }
169
170    pub fn get(&self) -> GetRoute {
171        GetRoute::new(&self.url, &self.token, "v3/routes/{id}")
172    }
173}
174
175pub struct ExportRoute {
176    url: String,
177    token: String,
178}
179
180impl ExportRoute {
181    pub fn new(url: impl Into<String>, token: impl Into<String>) -> Self {
182        Self {
183            url: url.into(),
184            token: token.into(),
185        }
186    }
187    pub fn tcx(&self) -> ExportTCXRoute {
188        ExportTCXRoute::new(&self.url, &self.token, "v3/routes/{id}/export_gpx")
189    }
190
191    pub fn gpx(&self) -> ExportGPXRoute {
192        ExportGPXRoute::new(&self.url, &self.token, "v3/routes/{id}/export_tcx")
193    }
194}
195
196pub struct SegmentsEndpoint {
197    url: String,
198    token: String,
199}
200
201impl SegmentsEndpoint {
202    pub fn new(url: impl Into<String>, token: impl Into<String>) -> Self {
203        Self {
204            url: url.into(),
205            token: token.into(),
206        }
207    }
208    pub fn efforts(&self) -> SegmentEffort {
209        SegmentEffort::new(&self.url, &self.token)
210    }
211
212    pub fn explore(&self) -> ExploreSegments {
213        ExploreSegments::new(&self.url, &self.token, "v3/segments/explore")
214    }
215
216    pub fn starred(&self) -> ListStarredSegments {
217        ListStarredSegments::new(&self.url, &self.token, "v3/segments/starred")
218    }
219
220    pub fn get(&self) -> GetSegment {
221        GetSegment::new(&self.url, &self.token, "v3/segments/{id}")
222    }
223
224    pub fn star() -> () {
225        todo!()
226        // segments/{id}/starred
227    }
228}
229
230pub struct SegmentEffort {
231    url: String,
232    token: String,
233}
234impl SegmentEffort {
235    pub fn new(url: impl Into<String>, token: impl Into<String>) -> Self {
236        Self {
237            url: url.into(),
238            token: token.into(),
239        }
240    }
241
242    pub fn get(&self) -> GetSegmentEffort {
243        GetSegmentEffort::new(&self.url, &self.token, "v3/segment_efforts")
244    }
245
246    pub fn list(&self) -> ListSegmentEfforts {
247        ListSegmentEfforts::new(&self.url, &self.token, "v3/segment_efforts/{id}")
248    }
249}