lichess_api/model/studies/
import_pgn_into_study.rs

1use crate::model::{Body, Request, VariantKey};
2use serde::{Deserialize, Serialize};
3use serde_with::skip_serializing_none;
4
5#[derive(Default, Clone, Debug, Serialize)]
6#[skip_serializing_none]
7pub struct ImportPgnBody {
8    pub name: String,
9    pub pgn: String,
10    pub variant: Option<VariantKey>,
11    pub orientation: Option<String>,
12}
13
14#[derive(Default, Clone, Debug, Deserialize)]
15pub struct StudyImportPgnChapters {
16    pub chapters: Vec<StudyChapterListItem>,
17}
18
19#[derive(Default, Clone, Debug, Deserialize)]
20pub struct StudyChapterListItem {
21    pub id: String,
22    pub name: String,
23}
24
25#[derive(Default, Clone, Debug, Serialize)]
26pub struct PostQuery;
27
28pub type PostRequest = Request<PostQuery, ImportPgnBody>;
29
30impl PostRequest {
31    pub fn new(study_id: String, import_pgn_body: ImportPgnBody) -> Self {
32        let path = format!("/api/study/{study_id}/import-pgn");
33        Self::post(path, None, Body::Form(import_pgn_body), None)
34    }
35}