use std::rc::Rc;
use std::borrow::Borrow;
use hyper;
use serde_json;
use futures;
use futures::{Future, Stream};
use super::{Error, configuration};
pub struct ContractApiClient<C: hyper::client::Connect> {
configuration: Rc<configuration::Configuration<C>>,
}
impl<C: hyper::client::Connect> ContractApiClient<C> {
pub fn new(configuration: Rc<configuration::Configuration<C>>) -> ContractApiClient<C> {
ContractApiClient {
configuration: configuration,
}
}
}
pub trait ContractApi {
fn iserver_contract_conid_info_get(&self, conid: &str) -> Box<Future<Item = ::models::Contract, Error = Error>>;
fn iserver_secdef_search_post(&self, symbol: ::models::Symbol) -> Box<Future<Item = Vec<::models::InlineResponse2008>, Error = Error>>;
fn trsrv_futures_get(&self, symbols: &str) -> Box<Future<Item = ::models::InlineResponse20015, Error = Error>>;
fn trsrv_secdef_post(&self, body: ::models::Body4) -> Box<Future<Item = ::models::Secdef, Error = Error>>;
}
impl<C: hyper::client::Connect>ContractApi for ContractApiClient<C> {
fn iserver_contract_conid_info_get(&self, conid: &str) -> Box<Future<Item = ::models::Contract, Error = Error>> {
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
let method = hyper::Method::Get;
let uri_str = format!("{}/iserver/contract/{conid}/info", configuration.base_path, conid=conid);
let uri = uri_str.parse();
let mut req = hyper::Request::new(method, uri.unwrap());
Box::new(
configuration.client.request(req).and_then(|res| { res.body().concat2() })
.map_err(|e| Error::from(e))
.and_then(|body| {
let parsed: Result<::models::Contract, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
}).map_err(|e| Error::from(e))
)
}
fn iserver_secdef_search_post(&self, symbol: ::models::Symbol) -> Box<Future<Item = Vec<::models::InlineResponse2008>, Error = Error>> {
unimplemented!("swagger-codegen bug workaround");
}
fn trsrv_futures_get(&self, symbols: &str) -> Box<Future<Item = ::models::InlineResponse20015, Error = Error>> {
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
let method = hyper::Method::Get;
let query = ::url::form_urlencoded::Serializer::new(String::new())
.append_pair("symbols", &symbols.to_string())
.finish();
let uri_str = format!("{}/trsrv/futures{}", configuration.base_path, query);
let uri = uri_str.parse();
let mut req = hyper::Request::new(method, uri.unwrap());
Box::new(
configuration.client.request(req).and_then(|res| { res.body().concat2() })
.map_err(|e| Error::from(e))
.and_then(|body| {
let parsed: Result<::models::InlineResponse20015, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
}).map_err(|e| Error::from(e))
)
}
fn trsrv_secdef_post(&self, body: ::models::Body4) -> Box<Future<Item = ::models::Secdef, Error = Error>> {
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
let method = hyper::Method::Post;
let uri_str = format!("{}/trsrv/secdef", configuration.base_path);
let uri = uri_str.parse();
let mut req = hyper::Request::new(method, uri.unwrap());
let serialized = serde_json::to_string(&body).unwrap();
req.headers_mut().set(hyper::header::ContentType::json());
req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
req.set_body(serialized);
Box::new(
configuration.client.request(req).and_then(|res| { res.body().concat2() })
.map_err(|e| Error::from(e))
.and_then(|body| {
let parsed: Result<::models::Secdef, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
}).map_err(|e| Error::from(e))
)
}
}