1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
use std::rc::Rc;
use std::borrow::Borrow;
use std::borrow::Cow;
use std::collections::HashMap;
use hyper;
use serde_json;
use futures;
use futures::{Future, Stream};
use hyper::header::UserAgent;
use super::{Error, configuration};
pub struct AlertNotificationsApiClient<C: hyper::client::Connect> {
configuration: Rc<configuration::Configuration<C>>,
}
impl<C: hyper::client::Connect> AlertNotificationsApiClient<C> {
pub fn new(configuration: Rc<configuration::Configuration<C>>) -> AlertNotificationsApiClient<C> {
AlertNotificationsApiClient {
configuration: configuration,
}
}
}
pub trait AlertNotificationsApi {
fn get_alert_notifications_for_app_using_post(&self, app_id: i64, time_interval: ::models::AlertNotificationRequest) -> Box<Future<Item = ::models::NotificationsResponse, Error = Error<serde_json::Value>>>;
fn get_alert_notifications_for_user_using_post(&self, time_interval: ::models::AlertNotificationRequest) -> Box<Future<Item = ::models::NotificationsResponse, Error = Error<serde_json::Value>>>;
}
impl<C: hyper::client::Connect>AlertNotificationsApi for AlertNotificationsApiClient<C> {
fn get_alert_notifications_for_app_using_post(&self, app_id: i64, time_interval: ::models::AlertNotificationRequest) -> Box<Future<Item = ::models::NotificationsResponse, Error = Error<serde_json::Value>>> {
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
let mut auth_headers = HashMap::<String, String>::new();
let mut auth_query = HashMap::<String, String>::new();
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let val = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
auth_headers.insert("Authorization".to_owned(), val);
};
let method = hyper::Method::Post;
let query_string = {
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
for (key, val) in &auth_query {
query.append_pair(key, val);
}
query.finish()
};
let uri_str = format!("{}/users-web/api/v3/apps/{appId}/notifications/alerts?{}", configuration.base_path, query_string, appId=app_id);
let mut uri: hyper::Uri = uri_str.parse().unwrap();
let mut req = hyper::Request::new(method, uri);
if let Some(ref user_agent) = configuration.user_agent {
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
}
for (key, val) in auth_headers {
req.headers_mut().set_raw(key, val);
}
let serialized = serde_json::to_string(&time_interval).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)
.map_err(|e| Error::from(e))
.and_then(|resp| {
let status = resp.status();
resp.body().concat2()
.and_then(move |body| Ok((status, body)))
.map_err(|e| Error::from(e))
})
.and_then(|(status, body)| {
if status.is_success() {
Ok(body)
} else {
Err(Error::from((status, &*body)))
}
})
.and_then(|body| {
let parsed: Result<::models::NotificationsResponse, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
})
)
}
fn get_alert_notifications_for_user_using_post(&self, time_interval: ::models::AlertNotificationRequest) -> Box<Future<Item = ::models::NotificationsResponse, Error = Error<serde_json::Value>>> {
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
let mut auth_headers = HashMap::<String, String>::new();
let mut auth_query = HashMap::<String, String>::new();
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let val = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
auth_headers.insert("Authorization".to_owned(), val);
};
let method = hyper::Method::Post;
let query_string = {
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
for (key, val) in &auth_query {
query.append_pair(key, val);
}
query.finish()
};
let uri_str = format!("{}/users-web/api/v3/notifications/alerts?{}", configuration.base_path, query_string);
let mut uri: hyper::Uri = uri_str.parse().unwrap();
let mut req = hyper::Request::new(method, uri);
if let Some(ref user_agent) = configuration.user_agent {
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
}
for (key, val) in auth_headers {
req.headers_mut().set_raw(key, val);
}
let serialized = serde_json::to_string(&time_interval).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)
.map_err(|e| Error::from(e))
.and_then(|resp| {
let status = resp.status();
resp.body().concat2()
.and_then(move |body| Ok((status, body)))
.map_err(|e| Error::from(e))
})
.and_then(|(status, body)| {
if status.is_success() {
Ok(body)
} else {
Err(Error::from((status, &*body)))
}
})
.and_then(|body| {
let parsed: Result<::models::NotificationsResponse, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
})
)
}
}