1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use crate::client::LichessApi;
use crate::error::Result;
use crate::model::challenges::*;
use crate::model::games::stream::moves::Move;

impl LichessApi<reqwest::Client> {
    pub async fn list_challenges(&self, request: list::GetRequest) -> Result<list::Challenges> {
        self.get_single_model(request).await
    }

    pub async fn create_challenge(&self, request: create::PostRequest) -> Result<ChallengeCreated> {
        self.get_single_model(request).await
    }

    pub async fn accept_challenge(&self, request: accept::PostRequest) -> Result<bool> {
        self.get_ok(request).await
    }

    pub async fn decline_challenge(&self, request: decline::PostRequest) -> Result<bool> {
        self.get_ok(request).await
    }

    pub async fn cancel_challenge(&self, request: cancel::PostRequest) -> Result<bool> {
        self.get_ok(request).await
    }

    pub async fn challenge_ai(&self, request: ai::PostRequest) -> Result<Move> {
        self.get_single_model(request).await
    }

    pub async fn create_open_challenge(
        &self,
        request: open::PostRequest,
    ) -> Result<ChallengeOpenJson> {
        self.get_single_model(request).await
    }

    pub async fn start_clocks(&self, request: start_clocks::PostRequest) -> Result<bool> {
        self.get_ok(request).await
    }

    pub async fn add_time_to_opponent_clock(&self, request: add_time::PostRequest) -> Result<bool> {
        self.get_ok(request).await
    }
}