chore: add PingResp
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
use serde::Serialize;
|
mod ping;
|
||||||
|
pub use ping::{Ping, PingResp};
|
||||||
#[derive(Serialize)]
|
|
||||||
pub struct Ping {}
|
|
||||||
|
|
||||||
mod get_user_preview_api;
|
mod get_user_preview_api;
|
||||||
pub use get_user_preview_api::{GetUserPreviewApi, GetUserPreviewApiResp};
|
pub use get_user_preview_api::{GetUserPreviewApi, GetUserPreviewApiResp};
|
||||||
|
|||||||
18
sdgb-api/src/title/model/ping/mod.rs
Normal file
18
sdgb-api/src/title/model/ping/mod.rs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
pub struct Ping {}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct PingResp {
|
||||||
|
result: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for PingResp {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.write_str(&self.result)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,10 @@ use sdgb_api::{
|
|||||||
title::{
|
title::{
|
||||||
MaiVersionExt, Sdgb1_40, Sdgb1_50,
|
MaiVersionExt, Sdgb1_40, Sdgb1_50,
|
||||||
methods::APIMethod,
|
methods::APIMethod,
|
||||||
model::{GetUserPreviewApi, GetUserPreviewApiResp, Ping, UserLogoutApi, UserLogoutApiResp},
|
model::{
|
||||||
|
GetUserPreviewApi, GetUserPreviewApiResp, Ping, PingResp, UserLogoutApi,
|
||||||
|
UserLogoutApiResp,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use spdlog::{error, info};
|
use spdlog::{error, info};
|
||||||
@@ -47,16 +50,17 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
|
|||||||
println!("{preview}");
|
println!("{preview}");
|
||||||
}
|
}
|
||||||
commands::Commands::Ping => {
|
commands::Commands::Ping => {
|
||||||
let decoded = Sdgb1_40::request_raw(
|
let decoded: PingResp = Sdgb1_40::request(
|
||||||
&client,
|
&client,
|
||||||
APIMethod::Ping,
|
APIMethod::Ping,
|
||||||
"",
|
"",
|
||||||
Ping {}, // note: must not be `Ping`, or serde_json serializes to nothing
|
Ping {}, // note: must not be `Ping`, or serde_json serializes to nothing
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
info!("sdgb 1.40 resp: {:?}", String::from_utf8_lossy(&decoded));
|
info!("sdgb 1.40 resp: {decoded}");
|
||||||
let decoded = Sdgb1_50::request_raw(&client, APIMethod::Ping, "", Ping {}).await?;
|
let decoded: PingResp =
|
||||||
info!("sdgb 1.50 resp: {:?}", String::from_utf8_lossy(&decoded));
|
Sdgb1_50::request(&client, APIMethod::Ping, "", Ping {}).await?;
|
||||||
|
info!("sdgb 1.50 resp: {decoded}");
|
||||||
}
|
}
|
||||||
commands::Commands::QRLogin { ref qrcode_content } => {
|
commands::Commands::QRLogin { ref qrcode_content } => {
|
||||||
let qrcode = QRCode { qrcode_content };
|
let qrcode = QRCode { qrcode_content };
|
||||||
|
|||||||
Reference in New Issue
Block a user