use crates

This commit is contained in:
notohh 2024-05-27 13:36:36 -04:00
parent e1061652d1
commit 6022cb94a8
Signed by: notohh
GPG key ID: BD47506D475EE86D

View file

@ -1,12 +1,15 @@
use clap::Parser;
use reqwest::Error;
mod args;
mod payload;
use clap::Parser;
use reqwest::Error;
use args::Args;
use payload::Payload;
#[tokio::main]
async fn main() -> Result<(), Error> {
let args = args::Args::parse();
let args = Args::parse();
let url = format!(
"https://v6.exchangerate-api.com/v6/{}/pair/{}/{}/{}",
args.app_id, args.from, args.to, args.value
@ -17,7 +20,7 @@ async fn main() -> Result<(), Error> {
match client.get(url).send().await {
Ok(response) => {
if response.status().is_success() {
match response.json::<payload::Payload>().await {
match response.json::<Payload>().await {
Ok(payload) => {
println!("From: {:?}", payload.base_code);
println!("To: {:?}", payload.target_code);