use crates
This commit is contained in:
parent
e1061652d1
commit
6022cb94a8
1 changed files with 8 additions and 5 deletions
13
src/main.rs
13
src/main.rs
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue