feat: initial support for GetUserRating
This commit is contained in:
@@ -11,14 +11,18 @@ use sdgb_api::{
|
||||
MaiVersionExt, Sdgb1_40, Sdgb1_50,
|
||||
methods::APIMethod,
|
||||
model::{
|
||||
GetUserDataApi, GetUserDataApiResp, GetUserPreviewApi, GetUserPreviewApiResp, Ping,
|
||||
PingResp, UserLogoutApi, UserLogoutApiResp,
|
||||
GetUserDataApi, GetUserDataApiResp, GetUserPreviewApi, GetUserPreviewApiResp,
|
||||
GetUserRatingApi, GetUserRatingApiResp, Ping, PingResp, UserLogoutApi,
|
||||
UserLogoutApiResp,
|
||||
},
|
||||
},
|
||||
};
|
||||
use spdlog::{error, info, warn};
|
||||
|
||||
use crate::{commands::Cli, utils::login_action};
|
||||
use crate::{
|
||||
commands::Cli,
|
||||
utils::{human_readable_display, login_action},
|
||||
};
|
||||
|
||||
#[cfg(feature = "fetchall")]
|
||||
mod cache;
|
||||
@@ -48,12 +52,27 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
|
||||
}
|
||||
})?;
|
||||
|
||||
let Cli { command } = <Cli as Parser>::parse();
|
||||
let Cli {
|
||||
command,
|
||||
machine_readable,
|
||||
} = <Cli as Parser>::parse();
|
||||
let human_readable = !machine_readable;
|
||||
|
||||
let client = ClientBuilder::default().build_async().await?;
|
||||
|
||||
// TODO: refactor via enum_dispatch
|
||||
match command {
|
||||
commands::Commands::Rating { user_id } => {
|
||||
let rating: GetUserRatingApiResp = Sdgb1_50::request(
|
||||
&client,
|
||||
APIMethod::GetUserRatingApi,
|
||||
user_id,
|
||||
GetUserRatingApi { user_id },
|
||||
)
|
||||
.await?;
|
||||
|
||||
human_readable_display(rating, human_readable)?;
|
||||
}
|
||||
commands::Commands::Logout { user_id, timestamp } => {
|
||||
let logout: UserLogoutApiResp = Sdgb1_50::request(
|
||||
&client,
|
||||
@@ -77,7 +96,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
|
||||
)
|
||||
.await?;
|
||||
|
||||
println!("{preview}");
|
||||
human_readable_display(preview, human_readable)?;
|
||||
}
|
||||
commands::Commands::Ping => {
|
||||
let decoded: PingResp = Sdgb1_40::request(
|
||||
|
||||
Reference in New Issue
Block a user