feat: support dxratingnet format
This commit is contained in:
@@ -15,16 +15,16 @@ use sdgb_api::{
|
||||
MaiVersionExt, Sdgb1_40, Sdgb1_50,
|
||||
methods::APIMethod,
|
||||
model::{
|
||||
GetUserDataApi, GetUserDataApiResp, GetUserPreviewApi, GetUserPreviewApiResp,
|
||||
GetUserRatingApi, GetUserRatingApiResp, Ping, PingResp, UserLogoutApi,
|
||||
UserLogoutApiResp,
|
||||
DxCalculatedEntries, GetUserDataApi, GetUserDataApiResp, GetUserPreviewApi,
|
||||
GetUserPreviewApiResp, GetUserRatingApi, GetUserRatingApiResp, Ping, PingResp,
|
||||
UserLogoutApi, UserLogoutApiResp,
|
||||
},
|
||||
},
|
||||
};
|
||||
use spdlog::{error, info, warn};
|
||||
|
||||
use crate::{
|
||||
commands::Cli,
|
||||
commands::{Cli, RatingFormat},
|
||||
utils::{human_readable_display, json_display, login_action},
|
||||
};
|
||||
|
||||
@@ -77,7 +77,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
|
||||
|
||||
// TODO: refactor via enum_dispatch
|
||||
match command {
|
||||
commands::Commands::Rating { user_id } => {
|
||||
commands::Commands::Rating { user_id, format } => {
|
||||
let rating: GetUserRatingApiResp = Sdgb1_50::request(
|
||||
&client,
|
||||
APIMethod::GetUserRatingApi,
|
||||
@@ -86,7 +86,13 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
|
||||
)
|
||||
.await?;
|
||||
|
||||
human_readable_display(rating, human_readable)?;
|
||||
match (human_readable, format) {
|
||||
(true, _) => println!("{rating}"),
|
||||
(false, RatingFormat::Origin) => json_display(rating)?,
|
||||
(false, RatingFormat::DxRatingNet) => json_display(
|
||||
DxCalculatedEntries::from_user_rating_lossy(&rating.user_rating),
|
||||
)?,
|
||||
}
|
||||
}
|
||||
commands::Commands::Logout { user_id, timestamp } => {
|
||||
let logout: UserLogoutApiResp = Sdgb1_50::request(
|
||||
|
||||
Reference in New Issue
Block a user