bw_web_api_rs/endpoints/
map_stats_by_toon.rs

1use crate::endpoints::Endpoint;
2use crate::error::ApiError;
3use crate::models::MapStatsByToon;
4use crate::types::Gateway;
5
6pub struct MapStatsByToonEndpoint {
7    toon: String,
8    gateway: Gateway,
9}
10
11impl MapStatsByToonEndpoint {
12    pub fn new(toon: String, gateway: Gateway) -> Self {
13        Self { toon, gateway }
14    }
15}
16
17impl Endpoint for MapStatsByToonEndpoint {
18    type Request = ();
19    type Response = MapStatsByToon;
20
21    fn endpoint(&self) -> String {
22        format!(
23            "/web-api/v1/map-stats-by-toon/{}/{}",
24            urlencoding::encode(&self.toon),
25            self.gateway as i32
26        )
27    }
28}
29
30impl crate::client::ApiClient {
31    /// Get map statistics for a specific player
32    ///
33    /// Endpoint: /web-api/v1/map-stats-by-toon/{toon}/{gateway}
34    pub async fn get_map_stats(
35        &self,
36        toon: String,
37        gateway: Gateway,
38    ) -> Result<MapStatsByToon, ApiError> {
39        let endpoint = MapStatsByToonEndpoint::new(toon, gateway);
40        self.request(&endpoint, &()).await
41    }
42}