vika 0.1.2

A Rust API for Vika.
Documentation
// use std::fmt::Debug;

pub mod common;

pub mod any;
pub mod attachment;
pub mod contact;
pub mod datasheet;
pub mod field;
pub mod node;
pub mod record;
pub mod space;
pub mod view;

use common::config::Config;

use self::space::SpacesManager;

pub struct Vika {
    pub spaces: SpacesManager,
    config: Config,
}

impl Vika {
    pub fn new(host: &str, token: &str) -> Vika {
        let mut config = Config::new(token);
        config.set_host(host);
        Vika {
            spaces: SpacesManager::new(config.clone()),
            config,
        }
    }

    pub fn headers(&self) -> http::HeaderMap {
        self.config.clone().into()
    }
}

impl Into<http::HeaderMap> for Config {
    fn into(self) -> http::HeaderMap {
        let mut map = http::HeaderMap::new();
        map.insert(
            http::header::CONTENT_TYPE,
            self.content_type.parse().unwrap(),
        );
        map.insert(
            http::header::AUTHORIZATION,
            Into::<String>::into(self.authorization).parse().unwrap(),
        );
        map
    }
}

#[cfg(test)]
mod tests {

    use super::*;
    #[test]
    fn test_vika_get_webhook() {
        let vika = Vika::new("api.vika.cn", "Bearer 1234567890");
        assert_eq!(vika.config.get_url(), "https://api.vika.cn:443/fusion/v1");
    }
}