Skip to content

Commit

Permalink
Merge pull request #73 from rubdos/event-compat
Browse files Browse the repository at this point in the history
  • Loading branch information
ion232 authored Oct 14, 2024
2 parents d213d8d + 470153f commit 46dc5ba
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 18 deletions.
10 changes: 9 additions & 1 deletion src/model/board/stream/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@ impl Default for GetRequest {

// Response structs.

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Event {
#[serde(flatten)]
pub event: EventData,
#[serde(skip_serializing_if = "Option::is_none")]
pub compat: Option<Compat>,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "type")]
#[serde(rename_all = "camelCase")]
pub enum Event {
pub enum EventData {
Challenge { challenge: ChallengeJson },
ChallengeCanceled { challenge: ChallengeJson },
ChallengeDeclined { challenge: ChallengeJson },
Expand Down
1 change: 0 additions & 1 deletion src/model/challenges/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ pub struct ChallengeJsonBase {
/// The api docs suggest this is non-nullable,
/// this is true only if the user does not accept anonymous challengers.
pub challenger: Option<ChallengeUser>,
pub compat: Option<Compat>,
pub dest_user: Option<ChallengeUser>,
pub perf: Perf,
pub rated: bool,
Expand Down
8 changes: 4 additions & 4 deletions tests/data/response/challenge.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"id": "7pGLxJ4F",
"url": "https://lichess.org/VU0nyvsW",
"status": "created",
"compat": {
"bot": false,
"board": true
},
"challenger": {
"id": "lovlas",
"name": "Lovlas",
Expand Down Expand Up @@ -43,5 +39,9 @@
"icon": "#",
"name": "Rapid"
}
},
"compat": {
"bot": false,
"board": true
}
}
4 changes: 0 additions & 4 deletions tests/data/response/challenge_anonymous.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"id": "7pGLxJ4F",
"url": "https://lichess.org/VU0nyvsW",
"status": "created",
"compat": {
"bot": false,
"board": true
},
"destUser": {
"id": "thibot",
"name": "thibot",
Expand Down
4 changes: 0 additions & 4 deletions tests/data/response/challenge_canceled.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"id": "7pGLxJ4F",
"url": "https://lichess.org/VU0nyvsW",
"status": "created",
"compat": {
"bot": false,
"board": true
},
"challenger": {
"id": "lovlas",
"name": "Lovlas",
Expand Down
4 changes: 0 additions & 4 deletions tests/data/response/challenge_declined.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"id": "7pGLxJ4F",
"url": "https://lichess.org/VU0nyvsW",
"status": "created",
"compat": {
"bot": false,
"board": true
},
"challenger": {
"id": "lovlas",
"name": "Lovlas",
Expand Down

0 comments on commit 46dc5ba

Please sign in to comment.