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
use crate::model::Body;
use serde::{Deserialize, Serialize};

#[derive(Default, Clone, Debug, Serialize)]
pub struct PostQuery;

#[derive(Default, Clone, Debug, Serialize)]
pub struct Game {
    pgn: String,
}

pub type PostRequest = crate::model::Request<PostQuery, Game>;

impl PostRequest {
    pub fn new(pgn: String) -> Self {
        Self {
            method: http::Method::POST,
            path: "/api/import".to_string(),
            body: Body::Form(Game { pgn }),
            ..Default::default()
        }
    }
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ImportData {
    pub id: String,
    pub url: String,
}