Skip to main content

strava_wrapper/filters/
routes.rs

1use crate::models::Route;
2use crate::query::{
3    get_raw_with_query_and_path, get_with_query_and_path, Endpoint, ErrorWrapper, Page, PathQuery,
4    PerPage, Query, Sendable, ID,
5};
6use async_trait::async_trait;
7use std::collections::HashMap;
8use strava_wrapper_macros::{Endpoint, Page, PathQuery, PerPage, Query, ID};
9
10#[derive(Debug, Clone, Endpoint, Query, PathQuery, ID)]
11#[must_use = "this request is not executed until you call .send().await"]
12pub struct GetRoute {
13    url: String,
14    token: String,
15    path: String,
16    query: Vec<(String, String)>,
17    path_params: Vec<(String, String)>,
18}
19
20#[async_trait]
21impl Sendable<Route> for GetRoute {
22    async fn send(self) -> Result<Route, ErrorWrapper> {
23        let token = self.token.clone();
24        get_with_query_and_path(self, &token).await
25    }
26}
27
28#[derive(Debug, Clone, Endpoint, Query, PathQuery, ID, Page, PerPage)]
29#[must_use = "this request is not executed until you call .send().await"]
30pub struct ListAthleteRoutes {
31    url: String,
32    token: String,
33    path: String,
34    query: Vec<(String, String)>,
35    path_params: Vec<(String, String)>,
36}
37
38#[async_trait]
39impl Sendable<Vec<Route>> for ListAthleteRoutes {
40    async fn send(self) -> Result<Vec<Route>, ErrorWrapper> {
41        let token = self.token.clone();
42        get_with_query_and_path(self, &token).await
43    }
44}
45
46#[derive(Debug, Clone, Endpoint, Query, PathQuery, ID)]
47#[must_use = "this request is not executed until you call .send().await"]
48pub struct ExportTCXRoute {
49    url: String,
50    token: String,
51    path: String,
52    query: Vec<(String, String)>,
53    path_params: Vec<(String, String)>,
54}
55
56#[async_trait]
57impl Sendable<String> for ExportTCXRoute {
58    async fn send(self) -> Result<String, ErrorWrapper> {
59        let token = self.token.clone();
60        get_raw_with_query_and_path(self, &token).await
61    }
62}
63
64#[derive(Debug, Clone, Endpoint, Query, PathQuery, ID)]
65#[must_use = "this request is not executed until you call .send().await"]
66pub struct ExportGPXRoute {
67    url: String,
68    token: String,
69    path: String,
70    query: Vec<(String, String)>,
71    path_params: Vec<(String, String)>,
72}
73
74#[async_trait]
75impl Sendable<String> for ExportGPXRoute {
76    async fn send(self) -> Result<String, ErrorWrapper> {
77        let token = self.token.clone();
78        get_raw_with_query_and_path(self, &token).await
79    }
80}