use chrono::prelude::*;
use chrono::Duration;
use newsapi::api::NewsAPIClient;
use newsapi::constants::{Category, Language, SortMethod};
use newsapi::payload::article::Articles;
use std::env;
fn main() {
let key = env::var("NEWSAPI_KEY").unwrap();
let start_timestamp = Utc::now() - Duration::days(10);
let end_timestamp = Utc::now();
let mut c = NewsAPIClient::new(key);
c
.language(Language::German)
.from(&start_timestamp)
.to(&end_timestamp)
.query("Trump America")
.category(Category::General)
.sort_by(SortMethod::Popularity)
.everything();
println!("{:?}", c);
let articles = c.send_sync::<Articles>().unwrap();
println!("{:?}", articles);
let status = articles.status;
println!("{}", status);
}