feat: abstract method to perform action

This commit is contained in:
mokurin000
2025-07-30 03:20:21 +08:00
parent 6ee009715d
commit 1a281e0cc7
7 changed files with 59 additions and 15 deletions

View File

@@ -2,7 +2,7 @@ use nyquest_preset::nyquest::ClientBuilder;
use palc::Parser;
use sdgb_api::{
all_net::QRCode,
title::{MaiVersionExt, Sdgb1_50, methods::APIMethod, model::Ping},
title::{MaiVersionExt, Sdgb1_40, Sdgb1_50, methods::APIMethod, model::Ping},
};
use spdlog::{error, info};
@@ -19,10 +19,10 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
match cmd.command {
commands::Commands::Ping => {
let req = Sdgb1_50::api_request(APIMethod::Ping, "", Ping)?;
let data = client.request(req).await?.bytes().await?;
let decoded = Sdgb1_50::decode(data)?;
info!("resp: {:?}", String::from_utf8_lossy(&decoded));
let decoded = Sdgb1_40::request(&client, APIMethod::Ping, "1", Ping {}).await?;
info!("sdgb 1.40 resp: {:?}", String::from_utf8_lossy(&decoded));
let decoded = Sdgb1_50::request(&client, APIMethod::Ping, "", Ping {}).await?;
info!("sdgb 1.50 resp: {:?}", String::from_utf8_lossy(&decoded));
}
commands::Commands::QRLogin { ref qrcode_content } => {
let qrcode = QRCode { qrcode_content };