use serde_json::json;
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize)]
struct Post {
    name: String,
    description: String,
    channel: String,
    channel_id: i64,
}

fn get_posts(user: i64, password: String, url: String) -> Vec<Post> {
    let args = json!({
        "user": user,
        "password": password,
    })
    .to_string();

    let client = reqwest::blocking::Client::new();

    let response = match client.get(url).body(args).send() {
        Ok(v) => v,
        Err(_e) => return vec![],
    };

    let response_text = match response.text() {
        Ok(v) => v,
        Err(_e) => return vec![],
    };

    let parsed: Vec<Post> = match serde_json::from_str(&response_text) {
        Ok(v) => v,
        Err(_e) => return vec![],
    };

    vec![]
}
