geeny-api 0.3.0

Crate for consuming the Geeny APIs as a client
Documentation
// Copyright 2017 Telefónica Germany Next GmbH. See the COPYRIGHT file at
// the top-level directory of this distribution
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

pub(crate) mod connect;
pub(crate) mod things;

use reqwest::Client;

#[derive(Debug, Clone)]
pub struct DefaultClient(Client);

impl Default for DefaultClient {
    fn default() -> Self {
        DefaultClient(Client::new())
    }
}

// TODO DI-235 - could this just be a SocketAddr (or contain one)
#[derive(Debug, Serialize, Deserialize, Clone)]
struct GeenyApi {
    host: String,
    port: u16,

    #[serde(skip)] client: DefaultClient,
}

impl GeenyApi {
    pub fn endpoint(&self, path: &str) -> String {
        // TODO validate?
        format!("{}:{}{}", self.host, self.port, path)
    }
}