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 PortfolioApiClient<C: hyper::client::Connect> {
configuration: Rc<configuration::Configuration<C>>,
}
impl<C: hyper::client::Connect> PortfolioApiClient<C> {
pub fn new(configuration: Rc<configuration::Configuration<C>>) -> PortfolioApiClient<C> {
PortfolioApiClient {
configuration: configuration,
}
}
}
pub trait PortfolioApi {
fn portfolio_account_id_allocation_get(&self, account_id: &str) -> Box<Future<Item = ::models::Allocation, Error = Error>>;
fn portfolio_account_id_ledger_get(&self, account_id: &str) -> Box<Future<Item = ::models::InlineResponse20013, Error = Error>>;
fn portfolio_account_id_meta_get(&self, account_id: &str) -> Box<Future<Item = ::models::Accounts, Error = Error>>;
fn portfolio_account_id_position_conid_get(&self, account_id: &str, conid: i32) -> Box<Future<Item = ::models::Position, Error = Error>>;
fn portfolio_account_id_positions_page_id_get(&self, account_id: &str, page_id: &str, model: &str, sort: &str, direction: &str, period: &str) -> Box<Future<Item = ::models::Position, Error = Error>>;
fn portfolio_account_id_summary_get(&self, account_id: &str) -> Box<Future<Item = ::models::InlineResponse20012, Error = Error>>;
fn portfolio_accounts_get(&self, ) -> Box<Future<Item = ::models::Accounts, Error = Error>>;
fn portfolio_allocation_post(&self, body: ::models::Body1) -> Box<Future<Item = ::models::Allocation, Error = Error>>;
fn portfolio_positions_conid_get(&self, conid: i32) -> Box<Future<Item = ::models::InlineResponse20014, Error = Error>>;
fn portfolio_subaccounts_get(&self, ) -> Box<Future<Item = ::models::Account, Error = Error>>;
}
impl<C: hyper::client::Connect>PortfolioApi for PortfolioApiClient<C> {
fn portfolio_account_id_allocation_get(&self, account_id: &str) -> Box<Future<Item = ::models::Allocation, Error = Error>> {
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
let method = hyper::Method::Get;
let uri_str = format!("{}/portfolio/{accountId}/allocation", configuration.base_path, accountId=account_id);
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::Allocation, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
}).map_err(|e| Error::from(e))
)
}
fn portfolio_account_id_ledger_get(&self, account_id: &str) -> Box<Future<Item = ::models::InlineResponse20013, Error = Error>> {
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
let method = hyper::Method::Get;
let uri_str = format!("{}/portfolio/{accountId}/ledger", configuration.base_path, accountId=account_id);
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::InlineResponse20013, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
}).map_err(|e| Error::from(e))
)
}
fn portfolio_account_id_meta_get(&self, account_id: &str) -> Box<Future<Item = ::models::Accounts, Error = Error>> {
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
let method = hyper::Method::Get;
let uri_str = format!("{}/portfolio/{accountId}/meta", configuration.base_path, accountId=account_id);
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::Accounts, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
}).map_err(|e| Error::from(e))
)
}
fn portfolio_account_id_position_conid_get(&self, account_id: &str, conid: i32) -> Box<Future<Item = ::models::Position, Error = Error>> {
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
let method = hyper::Method::Get;
let uri_str = format!("{}/portfolio/{accountId}/position/{conid}", configuration.base_path, accountId=account_id, 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::Position, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
}).map_err(|e| Error::from(e))
)
}
fn portfolio_account_id_positions_page_id_get(&self, account_id: &str, page_id: &str, model: &str, sort: &str, direction: &str, period: &str) -> Box<Future<Item = ::models::Position, 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("model", &model.to_string())
.append_pair("sort", &sort.to_string())
.append_pair("direction", &direction.to_string())
.append_pair("period", &period.to_string())
.finish();
let uri_str = format!("{}/portfolio/{accountId}/positions/{pageId}{}", configuration.base_path, query, accountId=account_id, pageId=page_id);
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::Position, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
}).map_err(|e| Error::from(e))
)
}
fn portfolio_account_id_summary_get(&self, account_id: &str) -> Box<Future<Item = ::models::InlineResponse20012, Error = Error>> {
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
let method = hyper::Method::Get;
let uri_str = format!("{}/portfolio/{accountId}/summary", configuration.base_path, accountId=account_id);
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::InlineResponse20012, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
}).map_err(|e| Error::from(e))
)
}
fn portfolio_accounts_get(&self, ) -> Box<Future<Item = ::models::Accounts, Error = Error>> {
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
let method = hyper::Method::Get;
let uri_str = format!("{}/portfolio/accounts", configuration.base_path);
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::Accounts, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
}).map_err(|e| Error::from(e))
)
}
fn portfolio_allocation_post(&self, body: ::models::Body1) -> Box<Future<Item = ::models::Allocation, Error = Error>> {
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
let method = hyper::Method::Post;
let uri_str = format!("{}/portfolio/allocation", 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::Allocation, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
}).map_err(|e| Error::from(e))
)
}
fn portfolio_positions_conid_get(&self, conid: i32) -> Box<Future<Item = ::models::InlineResponse20014, Error = Error>> {
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
let method = hyper::Method::Get;
let uri_str = format!("{}/portfolio/positions/{conid}", 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::InlineResponse20014, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
}).map_err(|e| Error::from(e))
)
}
fn portfolio_subaccounts_get(&self, ) -> Box<Future<Item = ::models::Account, Error = Error>> {
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
let method = hyper::Method::Get;
let uri_str = format!("{}/portfolio/subaccounts", configuration.base_path);
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::Account, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
}).map_err(|e| Error::from(e))
)
}
}