ib/apis/
portfolio_analyst_api.rs

1/* 
2 * Client Portal Web API
3 *
4 * Client Poral Web API
5 *
6 * OpenAPI spec version: 1.0.0
7 * 
8 * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 */
10
11use std::rc::Rc;
12use std::borrow::Borrow;
13use std::borrow::Cow;
14use std::collections::HashMap;
15
16use hyper;
17use serde_json::{self, Value};
18use futures;
19use futures::{Future, Stream};
20
21use hyper::header::UserAgent;
22
23use super::{Error, configuration};
24
25pub struct PortfolioAnalystApiClient<C: hyper::client::Connect> {
26    configuration: Rc<configuration::Configuration<C>>,
27}
28
29impl<C: hyper::client::Connect> PortfolioAnalystApiClient<C> {
30    pub fn new(configuration: Rc<configuration::Configuration<C>>) -> PortfolioAnalystApiClient<C> {
31        PortfolioAnalystApiClient {
32            configuration: configuration,
33        }
34    }
35}
36
37pub trait PortfolioAnalystApi {
38    fn pa_performance_post(&self, body: ::models::Body7) -> Box<Future<Item = ::models::Performance, Error = Error<serde_json::Value>>>;
39    fn pa_summary_post(&self, body: ::models::Body8) -> Box<Future<Item = ::models::Summary, Error = Error<serde_json::Value>>>;
40    fn pa_transactions_post(&self, body: ::models::Body9) -> Box<Future<Item = ::models::Transactions, Error = Error<serde_json::Value>>>;
41}
42
43
44impl<C: hyper::client::Connect>PortfolioAnalystApi for PortfolioAnalystApiClient<C> {
45    fn pa_performance_post(&self, body: ::models::Body7) -> Box<Future<Item = ::models::Performance, Error = Error<serde_json::Value>>> {
46        let configuration: &configuration::Configuration<C> = self.configuration.borrow();
47
48        let method = hyper::Method::Post;
49
50        let query_string = {
51            let mut query = ::url::form_urlencoded::Serializer::new(String::new());
52            query.finish()
53        };
54        let uri_str = format!("{}/pa/performance?{}", configuration.base_path, query_string);
55
56        // TODO(farcaller): handle error
57        // if let Err(e) = uri {
58        //     return Box::new(futures::future::err(e));
59        // }
60        let mut uri: hyper::Uri = uri_str.parse().unwrap();
61
62        let mut req = hyper::Request::new(method, uri);
63
64        if let Some(ref user_agent) = configuration.user_agent {
65            req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
66        }
67
68
69
70        let serialized = serde_json::to_string(&body).unwrap();
71        req.headers_mut().set(hyper::header::ContentType::json());
72        req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
73        req.set_body(serialized);
74
75        // send request
76        Box::new(
77        configuration.client.request(req)
78            .map_err(|e| Error::from(e))
79            .and_then(|resp| {
80                let status = resp.status();
81                resp.body().concat2()
82                    .and_then(move |body| Ok((status, body)))
83                    .map_err(|e| Error::from(e))
84            })
85            .and_then(|(status, body)| {
86                if status.is_success() {
87                    Ok(body)
88                } else {
89                    Err(Error::from((status, &*body)))
90                }
91            })
92            .and_then(|body| {
93                let parsed: Result<::models::Performance, _> = serde_json::from_slice(&body);
94                parsed.map_err(|e| Error::from(e))
95            })
96        )
97    }
98
99    fn pa_summary_post(&self, body: ::models::Body8) -> Box<Future<Item = ::models::Summary, Error = Error<serde_json::Value>>> {
100        let configuration: &configuration::Configuration<C> = self.configuration.borrow();
101
102        let method = hyper::Method::Post;
103
104        let query_string = {
105            let mut query = ::url::form_urlencoded::Serializer::new(String::new());
106            query.finish()
107        };
108        let uri_str = format!("{}/pa/summary?{}", configuration.base_path, query_string);
109
110        // TODO(farcaller): handle error
111        // if let Err(e) = uri {
112        //     return Box::new(futures::future::err(e));
113        // }
114        let mut uri: hyper::Uri = uri_str.parse().unwrap();
115
116        let mut req = hyper::Request::new(method, uri);
117
118        if let Some(ref user_agent) = configuration.user_agent {
119            req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
120        }
121
122
123
124        let serialized = serde_json::to_string(&body).unwrap();
125        req.headers_mut().set(hyper::header::ContentType::json());
126        req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
127        req.set_body(serialized);
128
129        // send request
130        Box::new(
131        configuration.client.request(req)
132            .map_err(|e| Error::from(e))
133            .and_then(|resp| {
134                let status = resp.status();
135                resp.body().concat2()
136                    .and_then(move |body| Ok((status, body)))
137                    .map_err(|e| Error::from(e))
138            })
139            .and_then(|(status, body)| {
140                if status.is_success() {
141                    Ok(body)
142                } else {
143                    Err(Error::from((status, &*body)))
144                }
145            })
146            .and_then(|body| {
147                let parsed: Result<::models::Summary, _> = serde_json::from_slice(&body);
148                parsed.map_err(|e| Error::from(e))
149            })
150        )
151    }
152
153    fn pa_transactions_post(&self, body: ::models::Body9) -> Box<Future<Item = ::models::Transactions, Error = Error<serde_json::Value>>> {
154        let configuration: &configuration::Configuration<C> = self.configuration.borrow();
155
156        let method = hyper::Method::Post;
157
158        let query_string = {
159            let mut query = ::url::form_urlencoded::Serializer::new(String::new());
160            query.finish()
161        };
162        let uri_str = format!("{}/pa/transactions?{}", configuration.base_path, query_string);
163
164        // TODO(farcaller): handle error
165        // if let Err(e) = uri {
166        //     return Box::new(futures::future::err(e));
167        // }
168        let mut uri: hyper::Uri = uri_str.parse().unwrap();
169
170        let mut req = hyper::Request::new(method, uri);
171
172        if let Some(ref user_agent) = configuration.user_agent {
173            req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
174        }
175
176
177
178        let serialized = serde_json::to_string(&body).unwrap();
179        req.headers_mut().set(hyper::header::ContentType::json());
180        req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
181        req.set_body(serialized);
182
183        // send request
184        Box::new(
185        configuration.client.request(req)
186            .map_err(|e| Error::from(e))
187            .and_then(|resp| {
188                let status = resp.status();
189                resp.body().concat2()
190                    .and_then(move |body| Ok((status, body)))
191                    .map_err(|e| Error::from(e))
192            })
193            .and_then(|(status, body)| {
194                if status.is_success() {
195                    Ok(body)
196                } else {
197                    Err(Error::from((status, &*body)))
198                }
199            })
200            .and_then(|body| {
201                let parsed: Result<::models::Transactions, _> = serde_json::from_slice(&body);
202                parsed.map_err(|e| Error::from(e))
203            })
204        )
205    }
206
207}