use std::borrow::Borrow;
use std::rc::Rc;
use reqwest;
use super::{configuration, Error};
pub struct NetworksApiClient {
configuration: Rc<configuration::Configuration>,
}
impl NetworksApiClient {
pub fn new(configuration: Rc<configuration::Configuration>) -> NetworksApiClient {
NetworksApiClient {
configuration: configuration,
}
}
}
pub trait NetworksApi {
fn get_network_details(&self, network_id: i32) -> Result<crate::models::Network, Error>;
}
impl NetworksApi for NetworksApiClient {
fn get_network_details(&self, network_id: i32) -> Result<crate::models::Network, Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;
let uri_str = format!(
"{}/network/{network_id}",
configuration.base_path,
network_id = network_id
);
let mut req_builder = client.get(uri_str.as_str());
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let val = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("api_key", val)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
Ok(client.execute(req)?.error_for_status()?.json()?)
}
}