feat: initial support of method call

This commit is contained in:
mokurin000
2025-07-30 02:33:31 +08:00
parent d870dc7047
commit 6ee009715d
8 changed files with 179 additions and 8 deletions

View File

@@ -1,6 +1,9 @@
use nyquest_preset::nyquest::ClientBuilder;
use palc::Parser;
use sdgb_api::all_net::QRCode;
use sdgb_api::{
all_net::QRCode,
title::{MaiVersionExt, Sdgb1_50, methods::APIMethod, model::Ping},
};
use spdlog::{error, info};
use crate::commands::Cli;
@@ -15,6 +18,12 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
let client = ClientBuilder::default().build_async().await?;
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));
}
commands::Commands::QRLogin { ref qrcode_content } => {
let qrcode = QRCode { qrcode_content };
match qrcode.login(&client).await {