strava_wrapper/
endpoints.rs

1use crate::filters::activities::ActivityFilter;
2use crate::filters::comments::CommentFilter;
3use crate::filters::kudos::KudosFilter;
4
5// TODO: implement all these...
6
7// API
8//   Activities
9//     - get
10//     - list
11//     Kudos
12//       - list
13//     Comments
14//       - list
15//     Laps
16//       - list
17//     Zones
18//       - list
19//   Athletes
20//     - get
21//     - zones
22//     - stats
23//     - update
24//   Clubs
25//     - get
26//     - activities
27//     - admins
28//     - members
29//     - list (for current user)
30//   Gear
31//     - get
32//   Routes
33//     - export (GPX|TCX)
34//     - get
35//     - list
36//   Segments
37//     Efforts
38//       - get
39//       - list
40//     - explore
41//     - starred
42//     - get
43//     - star
44//  maybes:
45//  Uploads
46//  Streams
47
48pub struct CommentsEndpoint {
49    url: String,
50    token: String,
51}
52
53impl CommentsEndpoint {
54    pub fn new(url: impl Into<String>, token: impl Into<String>) -> Self {
55        Self {
56            url: url.into(),
57            token: token.into(),
58        }
59    }
60    pub fn get(&self) -> CommentFilter {
61        CommentFilter::new(&self.url, &self.token, "v3/activities/{id}/comments")
62    }
63}
64
65pub struct ActivitiesEndpoint {
66    url: String,
67    token: String,
68}
69
70impl ActivitiesEndpoint {
71    pub fn new(url: impl Into<String>, token: impl Into<String>) -> Self {
72        Self {
73            url: url.into(),
74            token: token.into(),
75        }
76    }
77
78    pub fn comments(&self) -> CommentsEndpoint {
79        CommentsEndpoint::new(&self.url, &self.token)
80    }
81
82    pub fn kudos(&self) -> KudosEndpoint {
83        KudosEndpoint::new(&self.url, &self.token)
84    }
85
86    pub fn list(&self) -> ActivityFilter {
87        ActivityFilter::new(&self.url, &self.token, "v3/athlete/activities")
88    }
89
90    pub fn get(&self) -> ActivityFilter {
91        ActivityFilter::new(&self.url, &self.token, "v3/activities/{id}")
92    }
93
94    // TODO create() endpoint
95}
96
97pub struct KudosEndpoint {
98    url: String,
99    token: String,
100}
101
102impl KudosEndpoint {
103    pub fn new(url: impl Into<String>, token: impl Into<String>) -> Self {
104        Self {
105            url: url.into(),
106            token: token.into(),
107        }
108    }
109
110    pub fn get(&self) -> KudosFilter {
111        KudosFilter::new(&self.url, &self.token, "v3/activities/{id}/kudos")
112    }
113}