1use 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 MembersServiceAllowAccessError {
22 DefaultResponse(models::ErrorResponse),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum MembersServiceDeleteError {
30 DefaultResponse(models::ErrorResponse),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum MembersServiceForceSignoutError {
38 DefaultResponse(models::ErrorResponse),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum MembersServiceGetError {
46 DefaultResponse(models::ErrorResponse),
47 UnknownValue(serde_json::Value),
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum MembersServiceGetMyselfError {
54 DefaultResponse(models::ErrorResponse),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum MembersServiceInviteError {
62 DefaultResponse(models::ErrorResponse),
63 UnknownValue(serde_json::Value),
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum MembersServiceListError {
70 DefaultResponse(models::ErrorResponse),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum MembersServiceRevokeAccessError {
78 DefaultResponse(models::ErrorResponse),
79 UnknownValue(serde_json::Value),
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum MembersServiceUpdateError {
86 DefaultResponse(models::ErrorResponse),
87 UnknownValue(serde_json::Value),
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum MembersServiceUpdateMyselfError {
94 DefaultResponse(models::ErrorResponse),
95 UnknownValue(serde_json::Value),
96}
97
98
99pub async fn members_service_allow_access(configuration: &configuration::Configuration, id: &str, body: serde_json::Value) -> Result<models::Member, Error<MembersServiceAllowAccessError>> {
101 let p_path_id = id;
103 let p_body_body = body;
104
105 let uri_str = format!("{}/v1/members/{id}/allow", configuration.base_path, id=crate::apis::urlencode(p_path_id));
106 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
107
108 if let Some(ref user_agent) = configuration.user_agent {
109 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
110 }
111 if let Some(ref token) = configuration.bearer_access_token {
112 req_builder = req_builder.bearer_auth(token.to_owned());
113 };
114 req_builder = req_builder.json(&p_body_body);
115
116 let req = req_builder.build()?;
117 let resp = configuration.client.execute(req).await?;
118
119 let status = resp.status();
120 let content_type = resp
121 .headers()
122 .get("content-type")
123 .and_then(|v| v.to_str().ok())
124 .unwrap_or("application/octet-stream");
125 let content_type = super::ContentType::from(content_type);
126
127 if !status.is_client_error() && !status.is_server_error() {
128 let content = resp.text().await?;
129 match content_type {
130 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
131 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Member`"))),
132 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::Member`")))),
133 }
134 } else {
135 let content = resp.text().await?;
136 let entity: Option<MembersServiceAllowAccessError> = serde_json::from_str(&content).ok();
137 Err(Error::ResponseError(ResponseContent { status, content, entity }))
138 }
139}
140
141pub async fn members_service_delete(configuration: &configuration::Configuration, id: &str) -> Result<serde_json::Value, Error<MembersServiceDeleteError>> {
143 let p_path_id = id;
145
146 let uri_str = format!("{}/v1/members/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
147 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
148
149 if let Some(ref user_agent) = configuration.user_agent {
150 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
151 }
152 if let Some(ref token) = configuration.bearer_access_token {
153 req_builder = req_builder.bearer_auth(token.to_owned());
154 };
155
156 let req = req_builder.build()?;
157 let resp = configuration.client.execute(req).await?;
158
159 let status = resp.status();
160 let content_type = resp
161 .headers()
162 .get("content-type")
163 .and_then(|v| v.to_str().ok())
164 .unwrap_or("application/octet-stream");
165 let content_type = super::ContentType::from(content_type);
166
167 if !status.is_client_error() && !status.is_server_error() {
168 let content = resp.text().await?;
169 match content_type {
170 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
171 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
172 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`")))),
173 }
174 } else {
175 let content = resp.text().await?;
176 let entity: Option<MembersServiceDeleteError> = serde_json::from_str(&content).ok();
177 Err(Error::ResponseError(ResponseContent { status, content, entity }))
178 }
179}
180
181pub async fn members_service_force_signout(configuration: &configuration::Configuration, id: &str, body: serde_json::Value) -> Result<models::Member, Error<MembersServiceForceSignoutError>> {
183 let p_path_id = id;
185 let p_body_body = body;
186
187 let uri_str = format!("{}/v1/members/{id}/signout", configuration.base_path, id=crate::apis::urlencode(p_path_id));
188 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
189
190 if let Some(ref user_agent) = configuration.user_agent {
191 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
192 }
193 if let Some(ref token) = configuration.bearer_access_token {
194 req_builder = req_builder.bearer_auth(token.to_owned());
195 };
196 req_builder = req_builder.json(&p_body_body);
197
198 let req = req_builder.build()?;
199 let resp = configuration.client.execute(req).await?;
200
201 let status = resp.status();
202 let content_type = resp
203 .headers()
204 .get("content-type")
205 .and_then(|v| v.to_str().ok())
206 .unwrap_or("application/octet-stream");
207 let content_type = super::ContentType::from(content_type);
208
209 if !status.is_client_error() && !status.is_server_error() {
210 let content = resp.text().await?;
211 match content_type {
212 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
213 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Member`"))),
214 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::Member`")))),
215 }
216 } else {
217 let content = resp.text().await?;
218 let entity: Option<MembersServiceForceSignoutError> = serde_json::from_str(&content).ok();
219 Err(Error::ResponseError(ResponseContent { status, content, entity }))
220 }
221}
222
223pub async fn members_service_get(configuration: &configuration::Configuration, id: &str) -> Result<models::Member, Error<MembersServiceGetError>> {
225 let p_path_id = id;
227
228 let uri_str = format!("{}/v1/members/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
229 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
230
231 if let Some(ref user_agent) = configuration.user_agent {
232 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
233 }
234 if let Some(ref token) = configuration.bearer_access_token {
235 req_builder = req_builder.bearer_auth(token.to_owned());
236 };
237
238 let req = req_builder.build()?;
239 let resp = configuration.client.execute(req).await?;
240
241 let status = resp.status();
242 let content_type = resp
243 .headers()
244 .get("content-type")
245 .and_then(|v| v.to_str().ok())
246 .unwrap_or("application/octet-stream");
247 let content_type = super::ContentType::from(content_type);
248
249 if !status.is_client_error() && !status.is_server_error() {
250 let content = resp.text().await?;
251 match content_type {
252 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
253 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Member`"))),
254 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::Member`")))),
255 }
256 } else {
257 let content = resp.text().await?;
258 let entity: Option<MembersServiceGetError> = serde_json::from_str(&content).ok();
259 Err(Error::ResponseError(ResponseContent { status, content, entity }))
260 }
261}
262
263pub async fn members_service_get_myself(configuration: &configuration::Configuration, ) -> Result<models::Member, Error<MembersServiceGetMyselfError>> {
265
266 let uri_str = format!("{}/v1/member", configuration.base_path);
267 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
268
269 if let Some(ref user_agent) = configuration.user_agent {
270 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
271 }
272 if let Some(ref token) = configuration.bearer_access_token {
273 req_builder = req_builder.bearer_auth(token.to_owned());
274 };
275
276 let req = req_builder.build()?;
277 let resp = configuration.client.execute(req).await?;
278
279 let status = resp.status();
280 let content_type = resp
281 .headers()
282 .get("content-type")
283 .and_then(|v| v.to_str().ok())
284 .unwrap_or("application/octet-stream");
285 let content_type = super::ContentType::from(content_type);
286
287 if !status.is_client_error() && !status.is_server_error() {
288 let content = resp.text().await?;
289 match content_type {
290 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
291 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Member`"))),
292 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::Member`")))),
293 }
294 } else {
295 let content = resp.text().await?;
296 let entity: Option<MembersServiceGetMyselfError> = serde_json::from_str(&content).ok();
297 Err(Error::ResponseError(ResponseContent { status, content, entity }))
298 }
299}
300
301pub async fn members_service_invite(configuration: &configuration::Configuration, invite_member_request: models::InviteMemberRequest) -> Result<models::Member, Error<MembersServiceInviteError>> {
303 let p_body_invite_member_request = invite_member_request;
305
306 let uri_str = format!("{}/v1/members/invite", configuration.base_path);
307 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
308
309 if let Some(ref user_agent) = configuration.user_agent {
310 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
311 }
312 if let Some(ref token) = configuration.bearer_access_token {
313 req_builder = req_builder.bearer_auth(token.to_owned());
314 };
315 req_builder = req_builder.json(&p_body_invite_member_request);
316
317 let req = req_builder.build()?;
318 let resp = configuration.client.execute(req).await?;
319
320 let status = resp.status();
321 let content_type = resp
322 .headers()
323 .get("content-type")
324 .and_then(|v| v.to_str().ok())
325 .unwrap_or("application/octet-stream");
326 let content_type = super::ContentType::from(content_type);
327
328 if !status.is_client_error() && !status.is_server_error() {
329 let content = resp.text().await?;
330 match content_type {
331 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
332 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Member`"))),
333 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::Member`")))),
334 }
335 } else {
336 let content = resp.text().await?;
337 let entity: Option<MembersServiceInviteError> = serde_json::from_str(&content).ok();
338 Err(Error::ResponseError(ResponseContent { status, content, entity }))
339 }
340}
341
342pub async fn members_service_list(configuration: &configuration::Configuration, page_size: Option<i64>, page_token: Option<&str>) -> Result<models::ListResponse, Error<MembersServiceListError>> {
344 let p_query_page_size = page_size;
346 let p_query_page_token = page_token;
347
348 let uri_str = format!("{}/v1/members", configuration.base_path);
349 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
350
351 if let Some(ref param_value) = p_query_page_size {
352 req_builder = req_builder.query(&[("pageSize", ¶m_value.to_string())]);
353 }
354 if let Some(ref param_value) = p_query_page_token {
355 req_builder = req_builder.query(&[("pageToken", ¶m_value.to_string())]);
356 }
357 if let Some(ref user_agent) = configuration.user_agent {
358 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
359 }
360 if let Some(ref token) = configuration.bearer_access_token {
361 req_builder = req_builder.bearer_auth(token.to_owned());
362 };
363
364 let req = req_builder.build()?;
365 let resp = configuration.client.execute(req).await?;
366
367 let status = resp.status();
368 let content_type = resp
369 .headers()
370 .get("content-type")
371 .and_then(|v| v.to_str().ok())
372 .unwrap_or("application/octet-stream");
373 let content_type = super::ContentType::from(content_type);
374
375 if !status.is_client_error() && !status.is_server_error() {
376 let content = resp.text().await?;
377 match content_type {
378 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
379 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListResponse`"))),
380 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::ListResponse`")))),
381 }
382 } else {
383 let content = resp.text().await?;
384 let entity: Option<MembersServiceListError> = serde_json::from_str(&content).ok();
385 Err(Error::ResponseError(ResponseContent { status, content, entity }))
386 }
387}
388
389pub async fn members_service_revoke_access(configuration: &configuration::Configuration, id: &str, body: serde_json::Value) -> Result<models::Member, Error<MembersServiceRevokeAccessError>> {
391 let p_path_id = id;
393 let p_body_body = body;
394
395 let uri_str = format!("{}/v1/members/{id}/revoke", configuration.base_path, id=crate::apis::urlencode(p_path_id));
396 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
397
398 if let Some(ref user_agent) = configuration.user_agent {
399 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
400 }
401 if let Some(ref token) = configuration.bearer_access_token {
402 req_builder = req_builder.bearer_auth(token.to_owned());
403 };
404 req_builder = req_builder.json(&p_body_body);
405
406 let req = req_builder.build()?;
407 let resp = configuration.client.execute(req).await?;
408
409 let status = resp.status();
410 let content_type = resp
411 .headers()
412 .get("content-type")
413 .and_then(|v| v.to_str().ok())
414 .unwrap_or("application/octet-stream");
415 let content_type = super::ContentType::from(content_type);
416
417 if !status.is_client_error() && !status.is_server_error() {
418 let content = resp.text().await?;
419 match content_type {
420 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
421 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Member`"))),
422 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::Member`")))),
423 }
424 } else {
425 let content = resp.text().await?;
426 let entity: Option<MembersServiceRevokeAccessError> = serde_json::from_str(&content).ok();
427 Err(Error::ResponseError(ResponseContent { status, content, entity }))
428 }
429}
430
431pub async fn members_service_update(configuration: &configuration::Configuration, id: &str, members_service_update_body: models::MembersServiceUpdateBody) -> Result<models::Member, Error<MembersServiceUpdateError>> {
433 let p_path_id = id;
435 let p_body_members_service_update_body = members_service_update_body;
436
437 let uri_str = format!("{}/v1/members/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
438 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
439
440 if let Some(ref user_agent) = configuration.user_agent {
441 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
442 }
443 if let Some(ref token) = configuration.bearer_access_token {
444 req_builder = req_builder.bearer_auth(token.to_owned());
445 };
446 req_builder = req_builder.json(&p_body_members_service_update_body);
447
448 let req = req_builder.build()?;
449 let resp = configuration.client.execute(req).await?;
450
451 let status = resp.status();
452 let content_type = resp
453 .headers()
454 .get("content-type")
455 .and_then(|v| v.to_str().ok())
456 .unwrap_or("application/octet-stream");
457 let content_type = super::ContentType::from(content_type);
458
459 if !status.is_client_error() && !status.is_server_error() {
460 let content = resp.text().await?;
461 match content_type {
462 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
463 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Member`"))),
464 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::Member`")))),
465 }
466 } else {
467 let content = resp.text().await?;
468 let entity: Option<MembersServiceUpdateError> = serde_json::from_str(&content).ok();
469 Err(Error::ResponseError(ResponseContent { status, content, entity }))
470 }
471}
472
473pub async fn members_service_update_myself(configuration: &configuration::Configuration, update_me_request: models::UpdateMeRequest) -> Result<models::Member, Error<MembersServiceUpdateMyselfError>> {
475 let p_body_update_me_request = update_me_request;
477
478 let uri_str = format!("{}/v1/member", configuration.base_path);
479 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
480
481 if let Some(ref user_agent) = configuration.user_agent {
482 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
483 }
484 if let Some(ref token) = configuration.bearer_access_token {
485 req_builder = req_builder.bearer_auth(token.to_owned());
486 };
487 req_builder = req_builder.json(&p_body_update_me_request);
488
489 let req = req_builder.build()?;
490 let resp = configuration.client.execute(req).await?;
491
492 let status = resp.status();
493 let content_type = resp
494 .headers()
495 .get("content-type")
496 .and_then(|v| v.to_str().ok())
497 .unwrap_or("application/octet-stream");
498 let content_type = super::ContentType::from(content_type);
499
500 if !status.is_client_error() && !status.is_server_error() {
501 let content = resp.text().await?;
502 match content_type {
503 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
504 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Member`"))),
505 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::Member`")))),
506 }
507 } else {
508 let content = resp.text().await?;
509 let entity: Option<MembersServiceUpdateMyselfError> = serde_json::from_str(&content).ok();
510 Err(Error::ResponseError(ResponseContent { status, content, entity }))
511 }
512}
513