hanzo_client/apis/
notify_api.rs1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetNotifyHealthError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum PostNotifySendError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum PostNotifySendEmailError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum PostNotifySendSmsError {
43 UnknownValue(serde_json::Value),
44}
45
46
47pub async fn get_notify_health(configuration: &configuration::Configuration, ) -> Result<models::NotifyHealth, Error<GetNotifyHealthError>> {
49
50 let uri_str = format!("{}/v1/notify/health", configuration.base_path);
51 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
52
53 if let Some(ref user_agent) = configuration.user_agent {
54 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
55 }
56 if let Some(ref token) = configuration.bearer_access_token {
57 req_builder = req_builder.bearer_auth(token.to_owned());
58 };
59
60 let req = req_builder.build()?;
61 let resp = configuration.client.execute(req).await?;
62
63 let status = resp.status();
64 let content_type = resp
65 .headers()
66 .get("content-type")
67 .and_then(|v| v.to_str().ok())
68 .unwrap_or("application/octet-stream");
69 let content_type = super::ContentType::from(content_type);
70
71 if !status.is_client_error() && !status.is_server_error() {
72 let content = resp.text().await?;
73 match content_type {
74 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
75 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NotifyHealth`"))),
76 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NotifyHealth`")))),
77 }
78 } else {
79 let content = resp.text().await?;
80 let entity: Option<GetNotifyHealthError> = serde_json::from_str(&content).ok();
81 Err(Error::ResponseError(ResponseContent { status, content, entity }))
82 }
83}
84
85pub async fn post_notify_send(configuration: &configuration::Configuration, notify_send: models::NotifySend) -> Result<serde_json::Value, Error<PostNotifySendError>> {
87 let p_notify_send = notify_send;
89
90 let uri_str = format!("{}/v1/notify/send", configuration.base_path);
91 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
92
93 if let Some(ref user_agent) = configuration.user_agent {
94 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
95 }
96 if let Some(ref token) = configuration.bearer_access_token {
97 req_builder = req_builder.bearer_auth(token.to_owned());
98 };
99 req_builder = req_builder.json(&p_notify_send);
100
101 let req = req_builder.build()?;
102 let resp = configuration.client.execute(req).await?;
103
104 let status = resp.status();
105 let content_type = resp
106 .headers()
107 .get("content-type")
108 .and_then(|v| v.to_str().ok())
109 .unwrap_or("application/octet-stream");
110 let content_type = super::ContentType::from(content_type);
111
112 if !status.is_client_error() && !status.is_server_error() {
113 let content = resp.text().await?;
114 match content_type {
115 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
116 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
117 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
118 }
119 } else {
120 let content = resp.text().await?;
121 let entity: Option<PostNotifySendError> = serde_json::from_str(&content).ok();
122 Err(Error::ResponseError(ResponseContent { status, content, entity }))
123 }
124}
125
126pub async fn post_notify_send_email(configuration: &configuration::Configuration, notify_send: models::NotifySend) -> Result<serde_json::Value, Error<PostNotifySendEmailError>> {
128 let p_notify_send = notify_send;
130
131 let uri_str = format!("{}/v1/notify/send/email", configuration.base_path);
132 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
133
134 if let Some(ref user_agent) = configuration.user_agent {
135 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
136 }
137 if let Some(ref token) = configuration.bearer_access_token {
138 req_builder = req_builder.bearer_auth(token.to_owned());
139 };
140 req_builder = req_builder.json(&p_notify_send);
141
142 let req = req_builder.build()?;
143 let resp = configuration.client.execute(req).await?;
144
145 let status = resp.status();
146 let content_type = resp
147 .headers()
148 .get("content-type")
149 .and_then(|v| v.to_str().ok())
150 .unwrap_or("application/octet-stream");
151 let content_type = super::ContentType::from(content_type);
152
153 if !status.is_client_error() && !status.is_server_error() {
154 let content = resp.text().await?;
155 match content_type {
156 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
157 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
158 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
159 }
160 } else {
161 let content = resp.text().await?;
162 let entity: Option<PostNotifySendEmailError> = serde_json::from_str(&content).ok();
163 Err(Error::ResponseError(ResponseContent { status, content, entity }))
164 }
165}
166
167pub async fn post_notify_send_sms(configuration: &configuration::Configuration, notify_send: models::NotifySend) -> Result<serde_json::Value, Error<PostNotifySendSmsError>> {
169 let p_notify_send = notify_send;
171
172 let uri_str = format!("{}/v1/notify/send/sms", configuration.base_path);
173 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
174
175 if let Some(ref user_agent) = configuration.user_agent {
176 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
177 }
178 if let Some(ref token) = configuration.bearer_access_token {
179 req_builder = req_builder.bearer_auth(token.to_owned());
180 };
181 req_builder = req_builder.json(&p_notify_send);
182
183 let req = req_builder.build()?;
184 let resp = configuration.client.execute(req).await?;
185
186 let status = resp.status();
187 let content_type = resp
188 .headers()
189 .get("content-type")
190 .and_then(|v| v.to_str().ok())
191 .unwrap_or("application/octet-stream");
192 let content_type = super::ContentType::from(content_type);
193
194 if !status.is_client_error() && !status.is_server_error() {
195 let content = resp.text().await?;
196 match content_type {
197 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
198 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
199 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
200 }
201 } else {
202 let content = resp.text().await?;
203 let entity: Option<PostNotifySendSmsError> = serde_json::from_str(&content).ok();
204 Err(Error::ResponseError(ResponseContent { status, content, entity }))
205 }
206}
207