src: add conversion result
This commit is contained in:
parent
b67110564e
commit
0c41050779
1 changed files with 6 additions and 2 deletions
|
@ -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),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue