ib/apis/
ccp_beta_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 CCPBetaApiClient<C: hyper::client::Connect> {
26    configuration: Rc<configuration::Configuration<C>>,
27}
28
29impl<C: hyper::client::Connect> CCPBetaApiClient<C> {
30    pub fn new(configuration: Rc<configuration::Configuration<C>>) -> CCPBetaApiClient<C> {
31        CCPBetaApiClient {
32            configuration: configuration,
33        }
34    }
35}
36
37pub trait CCPBetaApi {
38    fn ccp_account_get(&self, ) -> Box<Future<Item = ::models::InlineResponse200, Error = Error<serde_json::Value>>>;
39    fn ccp_auth_init_post(&self, compete: bool, locale: &str, mac: &str, machine_id: &str, username: &str) -> Box<Future<Item = ::models::InlineResponse2001, Error = Error<serde_json::Value>>>;
40    fn ccp_auth_response_post(&self, auth: ::models::Auth) -> Box<Future<Item = ::models::InlineResponse2002, Error = Error<serde_json::Value>>>;
41    fn ccp_order_delete(&self, acct: &str, id: f32) -> Box<Future<Item = ::models::OrderData, Error = Error<serde_json::Value>>>;
42    fn ccp_order_post(&self, acct: &str, conid: f32, ccy: &str, exchange: &str, qty: f32, _type: &str, side: &str, price: f32, tif: &str) -> Box<Future<Item = ::models::OrderData, Error = Error<serde_json::Value>>>;
43    fn ccp_order_put(&self, acct: &str, id: f32) -> Box<Future<Item = ::models::OrderData, Error = Error<serde_json::Value>>>;
44    fn ccp_orders_get(&self, acct: &str, cancelled: bool) -> Box<Future<Item = ::models::InlineResponse2003, Error = Error<serde_json::Value>>>;
45    fn ccp_positions_get(&self, ) -> Box<Future<Item = ::models::PositionData, Error = Error<serde_json::Value>>>;
46    fn ccp_status_get(&self, ) -> Box<Future<Item = ::models::InlineResponse2004, Error = Error<serde_json::Value>>>;
47    fn ccp_trades_get(&self, from: &str, to: &str) -> Box<Future<Item = ::models::InlineResponse2003, Error = Error<serde_json::Value>>>;
48}
49
50
51impl<C: hyper::client::Connect>CCPBetaApi for CCPBetaApiClient<C> {
52    fn ccp_account_get(&self, ) -> Box<Future<Item = ::models::InlineResponse200, Error = Error<serde_json::Value>>> {
53        let configuration: &configuration::Configuration<C> = self.configuration.borrow();
54
55        let method = hyper::Method::Get;
56
57        let query_string = {
58            let mut query = ::url::form_urlencoded::Serializer::new(String::new());
59            query.finish()
60        };
61        let uri_str = format!("{}/ccp/account?{}", configuration.base_path, query_string);
62
63        // TODO(farcaller): handle error
64        // if let Err(e) = uri {
65        //     return Box::new(futures::future::err(e));
66        // }
67        let mut uri: hyper::Uri = uri_str.parse().unwrap();
68
69        let mut req = hyper::Request::new(method, uri);
70
71        if let Some(ref user_agent) = configuration.user_agent {
72            req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
73        }
74
75
76
77
78        // send request
79        Box::new(
80        configuration.client.request(req)
81            .map_err(|e| Error::from(e))
82            .and_then(|resp| {
83                let status = resp.status();
84                resp.body().concat2()
85                    .and_then(move |body| Ok((status, body)))
86                    .map_err(|e| Error::from(e))
87            })
88            .and_then(|(status, body)| {
89                if status.is_success() {
90                    Ok(body)
91                } else {
92                    Err(Error::from((status, &*body)))
93                }
94            })
95            .and_then(|body| {
96                let parsed: Result<::models::InlineResponse200, _> = serde_json::from_slice(&body);
97                parsed.map_err(|e| Error::from(e))
98            })
99        )
100    }
101
102    fn ccp_auth_init_post(&self, compete: bool, locale: &str, mac: &str, machine_id: &str, username: &str) -> Box<Future<Item = ::models::InlineResponse2001, Error = Error<serde_json::Value>>> {
103        let configuration: &configuration::Configuration<C> = self.configuration.borrow();
104
105        let method = hyper::Method::Post;
106
107        let query_string = {
108            let mut query = ::url::form_urlencoded::Serializer::new(String::new());
109            query.finish()
110        };
111        let uri_str = format!("{}/ccp/auth/init?{}", configuration.base_path, query_string);
112
113        // TODO(farcaller): handle error
114        // if let Err(e) = uri {
115        //     return Box::new(futures::future::err(e));
116        // }
117        let mut uri: hyper::Uri = uri_str.parse().unwrap();
118
119        let mut req = hyper::Request::new(method, uri);
120
121        if let Some(ref user_agent) = configuration.user_agent {
122            req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
123        }
124
125
126
127
128        // send request
129        Box::new(
130        configuration.client.request(req)
131            .map_err(|e| Error::from(e))
132            .and_then(|resp| {
133                let status = resp.status();
134                resp.body().concat2()
135                    .and_then(move |body| Ok((status, body)))
136                    .map_err(|e| Error::from(e))
137            })
138            .and_then(|(status, body)| {
139                if status.is_success() {
140                    Ok(body)
141                } else {
142                    Err(Error::from((status, &*body)))
143                }
144            })
145            .and_then(|body| {
146                let parsed: Result<::models::InlineResponse2001, _> = serde_json::from_slice(&body);
147                parsed.map_err(|e| Error::from(e))
148            })
149        )
150    }
151
152    fn ccp_auth_response_post(&self, auth: ::models::Auth) -> Box<Future<Item = ::models::InlineResponse2002, Error = Error<serde_json::Value>>> {
153        let configuration: &configuration::Configuration<C> = self.configuration.borrow();
154
155        let method = hyper::Method::Post;
156
157        let query_string = {
158            let mut query = ::url::form_urlencoded::Serializer::new(String::new());
159            query.finish()
160        };
161        let uri_str = format!("{}/ccp/auth/response?{}", configuration.base_path, query_string);
162
163        // TODO(farcaller): handle error
164        // if let Err(e) = uri {
165        //     return Box::new(futures::future::err(e));
166        // }
167        let mut uri: hyper::Uri = uri_str.parse().unwrap();
168
169        let mut req = hyper::Request::new(method, uri);
170
171        if let Some(ref user_agent) = configuration.user_agent {
172            req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
173        }
174
175
176
177        let serialized = serde_json::to_string(&auth).unwrap();
178        req.headers_mut().set(hyper::header::ContentType::json());
179        req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
180        req.set_body(serialized);
181
182        // send request
183        Box::new(
184        configuration.client.request(req)
185            .map_err(|e| Error::from(e))
186            .and_then(|resp| {
187                let status = resp.status();
188                resp.body().concat2()
189                    .and_then(move |body| Ok((status, body)))
190                    .map_err(|e| Error::from(e))
191            })
192            .and_then(|(status, body)| {
193                if status.is_success() {
194                    Ok(body)
195                } else {
196                    Err(Error::from((status, &*body)))
197                }
198            })
199            .and_then(|body| {
200                let parsed: Result<::models::InlineResponse2002, _> = serde_json::from_slice(&body);
201                parsed.map_err(|e| Error::from(e))
202            })
203        )
204    }
205
206    fn ccp_order_delete(&self, acct: &str, id: f32) -> Box<Future<Item = ::models::OrderData, Error = Error<serde_json::Value>>> {
207        let configuration: &configuration::Configuration<C> = self.configuration.borrow();
208
209        let method = hyper::Method::Delete;
210
211        let query_string = {
212            let mut query = ::url::form_urlencoded::Serializer::new(String::new());
213            query.append_pair("acct", &acct.to_string());
214            query.append_pair("id", &id.to_string());
215            query.finish()
216        };
217        let uri_str = format!("{}/ccp/order?{}", configuration.base_path, query_string);
218
219        // TODO(farcaller): handle error
220        // if let Err(e) = uri {
221        //     return Box::new(futures::future::err(e));
222        // }
223        let mut uri: hyper::Uri = uri_str.parse().unwrap();
224
225        let mut req = hyper::Request::new(method, uri);
226
227        if let Some(ref user_agent) = configuration.user_agent {
228            req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
229        }
230
231
232
233
234        // send request
235        Box::new(
236        configuration.client.request(req)
237            .map_err(|e| Error::from(e))
238            .and_then(|resp| {
239                let status = resp.status();
240                resp.body().concat2()
241                    .and_then(move |body| Ok((status, body)))
242                    .map_err(|e| Error::from(e))
243            })
244            .and_then(|(status, body)| {
245                if status.is_success() {
246                    Ok(body)
247                } else {
248                    Err(Error::from((status, &*body)))
249                }
250            })
251            .and_then(|body| {
252                let parsed: Result<::models::OrderData, _> = serde_json::from_slice(&body);
253                parsed.map_err(|e| Error::from(e))
254            })
255        )
256    }
257
258    fn ccp_order_post(&self, acct: &str, conid: f32, ccy: &str, exchange: &str, qty: f32, _type: &str, side: &str, price: f32, tif: &str) -> Box<Future<Item = ::models::OrderData, Error = Error<serde_json::Value>>> {
259        let configuration: &configuration::Configuration<C> = self.configuration.borrow();
260
261        let method = hyper::Method::Post;
262
263        let query_string = {
264            let mut query = ::url::form_urlencoded::Serializer::new(String::new());
265            query.append_pair("acct", &acct.to_string());
266            query.append_pair("conid", &conid.to_string());
267            query.append_pair("ccy", &ccy.to_string());
268            query.append_pair("exchange", &exchange.to_string());
269            query.append_pair("qty", &qty.to_string());
270            query.append_pair("type", &_type.to_string());
271            query.append_pair("side", &side.to_string());
272            query.append_pair("price", &price.to_string());
273            query.append_pair("tif", &tif.to_string());
274            query.finish()
275        };
276        let uri_str = format!("{}/ccp/order?{}", configuration.base_path, query_string);
277
278        // TODO(farcaller): handle error
279        // if let Err(e) = uri {
280        //     return Box::new(futures::future::err(e));
281        // }
282        let mut uri: hyper::Uri = uri_str.parse().unwrap();
283
284        let mut req = hyper::Request::new(method, uri);
285
286        if let Some(ref user_agent) = configuration.user_agent {
287            req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
288        }
289
290
291
292
293        // send request
294        Box::new(
295        configuration.client.request(req)
296            .map_err(|e| Error::from(e))
297            .and_then(|resp| {
298                let status = resp.status();
299                resp.body().concat2()
300                    .and_then(move |body| Ok((status, body)))
301                    .map_err(|e| Error::from(e))
302            })
303            .and_then(|(status, body)| {
304                if status.is_success() {
305                    Ok(body)
306                } else {
307                    Err(Error::from((status, &*body)))
308                }
309            })
310            .and_then(|body| {
311                let parsed: Result<::models::OrderData, _> = serde_json::from_slice(&body);
312                parsed.map_err(|e| Error::from(e))
313            })
314        )
315    }
316
317    fn ccp_order_put(&self, acct: &str, id: f32) -> Box<Future<Item = ::models::OrderData, Error = Error<serde_json::Value>>> {
318        let configuration: &configuration::Configuration<C> = self.configuration.borrow();
319
320        let method = hyper::Method::Put;
321
322        let query_string = {
323            let mut query = ::url::form_urlencoded::Serializer::new(String::new());
324            query.append_pair("acct", &acct.to_string());
325            query.append_pair("id", &id.to_string());
326            query.finish()
327        };
328        let uri_str = format!("{}/ccp/order?{}", configuration.base_path, query_string);
329
330        // TODO(farcaller): handle error
331        // if let Err(e) = uri {
332        //     return Box::new(futures::future::err(e));
333        // }
334        let mut uri: hyper::Uri = uri_str.parse().unwrap();
335
336        let mut req = hyper::Request::new(method, uri);
337
338        if let Some(ref user_agent) = configuration.user_agent {
339            req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
340        }
341
342
343
344
345        // send request
346        Box::new(
347        configuration.client.request(req)
348            .map_err(|e| Error::from(e))
349            .and_then(|resp| {
350                let status = resp.status();
351                resp.body().concat2()
352                    .and_then(move |body| Ok((status, body)))
353                    .map_err(|e| Error::from(e))
354            })
355            .and_then(|(status, body)| {
356                if status.is_success() {
357                    Ok(body)
358                } else {
359                    Err(Error::from((status, &*body)))
360                }
361            })
362            .and_then(|body| {
363                let parsed: Result<::models::OrderData, _> = serde_json::from_slice(&body);
364                parsed.map_err(|e| Error::from(e))
365            })
366        )
367    }
368
369    fn ccp_orders_get(&self, acct: &str, cancelled: bool) -> Box<Future<Item = ::models::InlineResponse2003, Error = Error<serde_json::Value>>> {
370        let configuration: &configuration::Configuration<C> = self.configuration.borrow();
371
372        let method = hyper::Method::Get;
373
374        let query_string = {
375            let mut query = ::url::form_urlencoded::Serializer::new(String::new());
376            query.append_pair("acct", &acct.to_string());
377            query.append_pair("cancelled", &cancelled.to_string());
378            query.finish()
379        };
380        let uri_str = format!("{}/ccp/orders?{}", configuration.base_path, query_string);
381
382        // TODO(farcaller): handle error
383        // if let Err(e) = uri {
384        //     return Box::new(futures::future::err(e));
385        // }
386        let mut uri: hyper::Uri = uri_str.parse().unwrap();
387
388        let mut req = hyper::Request::new(method, uri);
389
390        if let Some(ref user_agent) = configuration.user_agent {
391            req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
392        }
393
394
395
396
397        // send request
398        Box::new(
399        configuration.client.request(req)
400            .map_err(|e| Error::from(e))
401            .and_then(|resp| {
402                let status = resp.status();
403                resp.body().concat2()
404                    .and_then(move |body| Ok((status, body)))
405                    .map_err(|e| Error::from(e))
406            })
407            .and_then(|(status, body)| {
408                if status.is_success() {
409                    Ok(body)
410                } else {
411                    Err(Error::from((status, &*body)))
412                }
413            })
414            .and_then(|body| {
415                let parsed: Result<::models::InlineResponse2003, _> = serde_json::from_slice(&body);
416                parsed.map_err(|e| Error::from(e))
417            })
418        )
419    }
420
421    fn ccp_positions_get(&self, ) -> Box<Future<Item = ::models::PositionData, Error = Error<serde_json::Value>>> {
422        let configuration: &configuration::Configuration<C> = self.configuration.borrow();
423
424        let method = hyper::Method::Get;
425
426        let query_string = {
427            let mut query = ::url::form_urlencoded::Serializer::new(String::new());
428            query.finish()
429        };
430        let uri_str = format!("{}/ccp/positions?{}", configuration.base_path, query_string);
431
432        // TODO(farcaller): handle error
433        // if let Err(e) = uri {
434        //     return Box::new(futures::future::err(e));
435        // }
436        let mut uri: hyper::Uri = uri_str.parse().unwrap();
437
438        let mut req = hyper::Request::new(method, uri);
439
440        if let Some(ref user_agent) = configuration.user_agent {
441            req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
442        }
443
444
445
446
447        // send request
448        Box::new(
449        configuration.client.request(req)
450            .map_err(|e| Error::from(e))
451            .and_then(|resp| {
452                let status = resp.status();
453                resp.body().concat2()
454                    .and_then(move |body| Ok((status, body)))
455                    .map_err(|e| Error::from(e))
456            })
457            .and_then(|(status, body)| {
458                if status.is_success() {
459                    Ok(body)
460                } else {
461                    Err(Error::from((status, &*body)))
462                }
463            })
464            .and_then(|body| {
465                let parsed: Result<::models::PositionData, _> = serde_json::from_slice(&body);
466                parsed.map_err(|e| Error::from(e))
467            })
468        )
469    }
470
471    fn ccp_status_get(&self, ) -> Box<Future<Item = ::models::InlineResponse2004, Error = Error<serde_json::Value>>> {
472        let configuration: &configuration::Configuration<C> = self.configuration.borrow();
473
474        let method = hyper::Method::Get;
475
476        let query_string = {
477            let mut query = ::url::form_urlencoded::Serializer::new(String::new());
478            query.finish()
479        };
480        let uri_str = format!("{}/ccp/status?{}", configuration.base_path, query_string);
481
482        // TODO(farcaller): handle error
483        // if let Err(e) = uri {
484        //     return Box::new(futures::future::err(e));
485        // }
486        let mut uri: hyper::Uri = uri_str.parse().unwrap();
487
488        let mut req = hyper::Request::new(method, uri);
489
490        if let Some(ref user_agent) = configuration.user_agent {
491            req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
492        }
493
494
495
496
497        // send request
498        Box::new(
499        configuration.client.request(req)
500            .map_err(|e| Error::from(e))
501            .and_then(|resp| {
502                let status = resp.status();
503                resp.body().concat2()
504                    .and_then(move |body| Ok((status, body)))
505                    .map_err(|e| Error::from(e))
506            })
507            .and_then(|(status, body)| {
508                if status.is_success() {
509                    Ok(body)
510                } else {
511                    Err(Error::from((status, &*body)))
512                }
513            })
514            .and_then(|body| {
515                let parsed: Result<::models::InlineResponse2004, _> = serde_json::from_slice(&body);
516                parsed.map_err(|e| Error::from(e))
517            })
518        )
519    }
520
521    fn ccp_trades_get(&self, from: &str, to: &str) -> Box<Future<Item = ::models::InlineResponse2003, Error = Error<serde_json::Value>>> {
522        let configuration: &configuration::Configuration<C> = self.configuration.borrow();
523
524        let method = hyper::Method::Get;
525
526        let query_string = {
527            let mut query = ::url::form_urlencoded::Serializer::new(String::new());
528            query.append_pair("from", &from.to_string());
529            query.append_pair("to", &to.to_string());
530            query.finish()
531        };
532        let uri_str = format!("{}/ccp/trades?{}", configuration.base_path, query_string);
533
534        // TODO(farcaller): handle error
535        // if let Err(e) = uri {
536        //     return Box::new(futures::future::err(e));
537        // }
538        let mut uri: hyper::Uri = uri_str.parse().unwrap();
539
540        let mut req = hyper::Request::new(method, uri);
541
542        if let Some(ref user_agent) = configuration.user_agent {
543            req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
544        }
545
546
547
548
549        // send request
550        Box::new(
551        configuration.client.request(req)
552            .map_err(|e| Error::from(e))
553            .and_then(|resp| {
554                let status = resp.status();
555                resp.body().concat2()
556                    .and_then(move |body| Ok((status, body)))
557                    .map_err(|e| Error::from(e))
558            })
559            .and_then(|(status, body)| {
560                if status.is_success() {
561                    Ok(body)
562                } else {
563                    Err(Error::from((status, &*body)))
564                }
565            })
566            .and_then(|body| {
567                let parsed: Result<::models::InlineResponse2003, _> = serde_json::from_slice(&body);
568                parsed.map_err(|e| Error::from(e))
569            })
570        )
571    }
572
573}