Skip to main content

strava_wrapper/filters/
clubs.rs

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