Make player name optional

This commit is contained in:
Kiana Sheibani 2023-09-02 21:27:21 -04:00
parent 98f140afff
commit 326da19523
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -27,7 +27,7 @@ struct Player {
// Unwrapping // Unwrapping
pub struct PlayerInfoResponse { pub struct PlayerInfoResponse {
pub name: String, pub name: Option<String>,
pub prefix: Option<String>, pub prefix: Option<String>,
} }
@ -37,7 +37,7 @@ impl QueryUnwrap<PlayerInfoVars> for PlayerInfo {
fn unwrap_response(response: GraphQlResponse<PlayerInfo>) -> Option<PlayerInfoResponse> { fn unwrap_response(response: GraphQlResponse<PlayerInfo>) -> Option<PlayerInfoResponse> {
let player = response.data?.player?; let player = response.data?.player?;
Some(PlayerInfoResponse { Some(PlayerInfoResponse {
name: player.gamer_tag?, name: player.gamer_tag,
prefix: player.prefix.filter(|pr| !pr.is_empty()), prefix: player.prefix.filter(|pr| !pr.is_empty()),
}) })
} }