src: add conversion result

This commit is contained in:
notohh 2024-05-27 10:29:24 -04:00
parent b67110564e
commit 0c41050779
Signed by: notohh
GPG key ID: BD47506D475EE86D

View file

@ -12,6 +12,8 @@ pub struct Args {
from: String,
#[arg(short, long)]
to: String,
#[arg(short, long)]
value: String,
}
#[derive(Debug, Deserialize, Serialize)]
@ -19,14 +21,15 @@ pub struct Payload {
base_code: String,
target_code: String,
conversion_rate: f64,
conversion_result: f64,
}
#[tokio::main]
async fn main() -> Result<(), Error> {
let args = Args::parse();
let url = format!(
"https://v6.exchangerate-api.com/v6/{}/pair/{}/{}",
args.app_id, args.from, args.to
"https://v6.exchangerate-api.com/v6/{}/pair/{}/{}/{}",
args.app_id, args.from, args.to, args.value
);
let client = reqwest::Client::new();
@ -39,6 +42,7 @@ async fn main() -> Result<(), Error> {
println!("From: {:?}", payload.base_code);
println!("To: {:?}", payload.target_code);
println!("Rate: {:?}", payload.conversion_rate);
println!("Total: {:?}", payload.conversion_result);
}
Err(e) => panic!("Failed: {}", e),
}