satstream_rust_sdk/apis/
fees_api.rs1use std::rc::Rc;
12use std::borrow::Borrow;
13use std::borrow::Cow;
14use std::collections::HashMap;
15
16use hyper;
17use serde_json;
18use futures;
19use futures::{Future, Stream};
20
21use hyper::header::UserAgent;
22
23use super::{Error, configuration};
24
25pub struct FeesApiClient<C: hyper::client::Connect> {
26 configuration: Rc<configuration::Configuration<C>>,
27}
28
29impl<C: hyper::client::Connect> FeesApiClient<C> {
30 pub fn new(configuration: Rc<configuration::Configuration<C>>) -> FeesApiClient<C> {
31 FeesApiClient {
32 configuration: configuration,
33 }
34 }
35}
36
37pub trait FeesApi {
38 fn get_recommended_fees(&self, ) -> Box<Future<Item = ::models::ResponsesGetFees, Error = Error<serde_json::Value>>>;
39}
40
41
42impl<C: hyper::client::Connect>FeesApi for FeesApiClient<C> {
43 fn get_recommended_fees(&self, ) -> Box<Future<Item = ::models::ResponsesGetFees, Error = Error<serde_json::Value>>> {
44 let configuration: &configuration::Configuration<C> = self.configuration.borrow();
45
46 let method = hyper::Method::Get;
47
48 let query_string = {
49 let mut query = ::url::form_urlencoded::Serializer::new(String::new());
50 query.finish()
51 };
52 let uri_str = format!("{}/fees?{}", configuration.base_path, query_string);
53
54 let mut uri: hyper::Uri = uri_str.parse().unwrap();
59
60 let mut req = hyper::Request::new(method, uri);
61
62 if let Some(ref user_agent) = configuration.user_agent {
63 req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
64 }
65
66
67
68
69 Box::new(
71 configuration.client.request(req)
72 .map_err(|e| Error::from(e))
73 .and_then(|resp| {
74 let status = resp.status();
75 resp.body().concat2()
76 .and_then(move |body| Ok((status, body)))
77 .map_err(|e| Error::from(e))
78 })
79 .and_then(|(status, body)| {
80 if status.is_success() {
81 Ok(body)
82 } else {
83 Err(Error::from((status, &*body)))
84 }
85 })
86 .and_then(|body| {
87 let parsed: Result<::models::ResponsesGetFees, _> = serde_json::from_slice(&body);
88 parsed.map_err(|e| Error::from(e))
89 })
90 )
91 }
92
93}