1use std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21 apis::{AuthRequired, ContentType, ResponseContent},
22 models,
23};
24
25#[cfg_attr(feature = "mockall", automock)]
26#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
27#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
28pub trait DevicesApi: Send + Sync {
29 async fn deactivate<'a>(&self, id: &'a str) -> Result<(), Error<DeactivateError>>;
31
32 async fn get<'a>(&self, id: &'a str) -> Result<models::DeviceResponseModel, Error<GetError>>;
34
35 async fn get_all(
37 &self,
38 ) -> Result<models::DeviceAuthRequestResponseModelListResponseModel, Error<GetAllError>>;
39
40 async fn get_by_identifier<'a>(
42 &self,
43 identifier: &'a str,
44 ) -> Result<models::DeviceResponseModel, Error<GetByIdentifierError>>;
45
46 async fn get_by_identifier_query<'a>(
48 &self,
49 x_request_email: &'a str,
50 x_device_identifier: &'a str,
51 ) -> Result<bool, Error<GetByIdentifierQueryError>>;
52
53 async fn post<'a>(
55 &self,
56 device_request_model: Option<models::DeviceRequestModel>,
57 ) -> Result<models::DeviceResponseModel, Error<PostError>>;
58
59 async fn post_lost_trust(&self) -> Result<(), Error<PostLostTrustError>>;
61
62 async fn post_untrust<'a>(
64 &self,
65 untrust_devices_request_model: Option<models::UntrustDevicesRequestModel>,
66 ) -> Result<(), Error<PostUntrustError>>;
67
68 async fn post_update_trust<'a>(
70 &self,
71 update_devices_trust_request_model: Option<models::UpdateDevicesTrustRequestModel>,
72 ) -> Result<(), Error<PostUpdateTrustError>>;
73
74 async fn put<'a>(
76 &self,
77 id: &'a str,
78 device_request_model: Option<models::DeviceRequestModel>,
79 ) -> Result<models::DeviceResponseModel, Error<PutError>>;
80
81 async fn put_clear_token<'a>(
83 &self,
84 identifier: &'a str,
85 ) -> Result<(), Error<PutClearTokenError>>;
86
87 async fn put_keys<'a>(
89 &self,
90 identifier: &'a str,
91 device_keys_request_model: Option<models::DeviceKeysRequestModel>,
92 ) -> Result<models::DeviceResponseModel, Error<PutKeysError>>;
93
94 async fn put_token<'a>(
96 &self,
97 identifier: &'a str,
98 device_token_request_model: Option<models::DeviceTokenRequestModel>,
99 ) -> Result<(), Error<PutTokenError>>;
100
101 async fn put_web_push_auth<'a>(
103 &self,
104 identifier: &'a str,
105 web_push_auth_request_model: Option<models::WebPushAuthRequestModel>,
106 ) -> Result<(), Error<PutWebPushAuthError>>;
107}
108
109pub struct DevicesApiClient {
110 configuration: Arc<configuration::Configuration>,
111}
112
113impl DevicesApiClient {
114 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
115 Self { configuration }
116 }
117}
118
119#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
120#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
121impl DevicesApi for DevicesApiClient {
122 async fn deactivate<'a>(&self, id: &'a str) -> Result<(), Error<DeactivateError>> {
123 let local_var_configuration = &self.configuration;
124
125 let local_var_client = &local_var_configuration.client;
126
127 let local_var_uri_str = format!(
128 "{}/devices/{id}",
129 local_var_configuration.base_path,
130 id = crate::apis::urlencode(id)
131 );
132 let mut local_var_req_builder =
133 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
134
135 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
136
137 let local_var_resp = local_var_req_builder.send().await?;
138
139 let local_var_status = local_var_resp.status();
140 let local_var_content = local_var_resp.text().await?;
141
142 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
143 Ok(())
144 } else {
145 let local_var_entity: Option<DeactivateError> =
146 serde_json::from_str(&local_var_content).ok();
147 let local_var_error = ResponseContent {
148 status: local_var_status,
149 content: local_var_content,
150 entity: local_var_entity,
151 };
152 Err(Error::ResponseError(local_var_error))
153 }
154 }
155
156 async fn get<'a>(&self, id: &'a str) -> Result<models::DeviceResponseModel, Error<GetError>> {
157 let local_var_configuration = &self.configuration;
158
159 let local_var_client = &local_var_configuration.client;
160
161 let local_var_uri_str = format!(
162 "{}/devices/{id}",
163 local_var_configuration.base_path,
164 id = crate::apis::urlencode(id)
165 );
166 let mut local_var_req_builder =
167 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
168
169 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
170
171 let local_var_resp = local_var_req_builder.send().await?;
172
173 let local_var_status = local_var_resp.status();
174 let local_var_content_type = local_var_resp
175 .headers()
176 .get("content-type")
177 .and_then(|v| v.to_str().ok())
178 .unwrap_or("application/octet-stream");
179 let local_var_content_type = super::ContentType::from(local_var_content_type);
180 let local_var_content = local_var_resp.text().await?;
181
182 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
183 match local_var_content_type {
184 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
185 ContentType::Text => {
186 return Err(Error::from(serde_json::Error::custom(
187 "Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`",
188 )));
189 }
190 ContentType::Unsupported(local_var_unknown_type) => {
191 return Err(Error::from(serde_json::Error::custom(format!(
192 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`"
193 ))));
194 }
195 }
196 } else {
197 let local_var_entity: Option<GetError> = serde_json::from_str(&local_var_content).ok();
198 let local_var_error = ResponseContent {
199 status: local_var_status,
200 content: local_var_content,
201 entity: local_var_entity,
202 };
203 Err(Error::ResponseError(local_var_error))
204 }
205 }
206
207 async fn get_all(
208 &self,
209 ) -> Result<models::DeviceAuthRequestResponseModelListResponseModel, Error<GetAllError>> {
210 let local_var_configuration = &self.configuration;
211
212 let local_var_client = &local_var_configuration.client;
213
214 let local_var_uri_str = format!("{}/devices", local_var_configuration.base_path);
215 let mut local_var_req_builder =
216 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
217
218 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
219
220 let local_var_resp = local_var_req_builder.send().await?;
221
222 let local_var_status = local_var_resp.status();
223 let local_var_content_type = local_var_resp
224 .headers()
225 .get("content-type")
226 .and_then(|v| v.to_str().ok())
227 .unwrap_or("application/octet-stream");
228 let local_var_content_type = super::ContentType::from(local_var_content_type);
229 let local_var_content = local_var_resp.text().await?;
230
231 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
232 match local_var_content_type {
233 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
234 ContentType::Text => {
235 return Err(Error::from(serde_json::Error::custom(
236 "Received `text/plain` content type response that cannot be converted to `models::DeviceAuthRequestResponseModelListResponseModel`",
237 )));
238 }
239 ContentType::Unsupported(local_var_unknown_type) => {
240 return Err(Error::from(serde_json::Error::custom(format!(
241 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceAuthRequestResponseModelListResponseModel`"
242 ))));
243 }
244 }
245 } else {
246 let local_var_entity: Option<GetAllError> =
247 serde_json::from_str(&local_var_content).ok();
248 let local_var_error = ResponseContent {
249 status: local_var_status,
250 content: local_var_content,
251 entity: local_var_entity,
252 };
253 Err(Error::ResponseError(local_var_error))
254 }
255 }
256
257 async fn get_by_identifier<'a>(
258 &self,
259 identifier: &'a str,
260 ) -> Result<models::DeviceResponseModel, Error<GetByIdentifierError>> {
261 let local_var_configuration = &self.configuration;
262
263 let local_var_client = &local_var_configuration.client;
264
265 let local_var_uri_str = format!(
266 "{}/devices/identifier/{identifier}",
267 local_var_configuration.base_path,
268 identifier = crate::apis::urlencode(identifier)
269 );
270 let mut local_var_req_builder =
271 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
272
273 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
274
275 let local_var_resp = local_var_req_builder.send().await?;
276
277 let local_var_status = local_var_resp.status();
278 let local_var_content_type = local_var_resp
279 .headers()
280 .get("content-type")
281 .and_then(|v| v.to_str().ok())
282 .unwrap_or("application/octet-stream");
283 let local_var_content_type = super::ContentType::from(local_var_content_type);
284 let local_var_content = local_var_resp.text().await?;
285
286 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
287 match local_var_content_type {
288 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
289 ContentType::Text => {
290 return Err(Error::from(serde_json::Error::custom(
291 "Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`",
292 )));
293 }
294 ContentType::Unsupported(local_var_unknown_type) => {
295 return Err(Error::from(serde_json::Error::custom(format!(
296 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`"
297 ))));
298 }
299 }
300 } else {
301 let local_var_entity: Option<GetByIdentifierError> =
302 serde_json::from_str(&local_var_content).ok();
303 let local_var_error = ResponseContent {
304 status: local_var_status,
305 content: local_var_content,
306 entity: local_var_entity,
307 };
308 Err(Error::ResponseError(local_var_error))
309 }
310 }
311
312 async fn get_by_identifier_query<'a>(
313 &self,
314 x_request_email: &'a str,
315 x_device_identifier: &'a str,
316 ) -> Result<bool, Error<GetByIdentifierQueryError>> {
317 let local_var_configuration = &self.configuration;
318
319 let local_var_client = &local_var_configuration.client;
320
321 let local_var_uri_str =
322 format!("{}/devices/knowndevice", local_var_configuration.base_path);
323 let mut local_var_req_builder =
324 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
325
326 local_var_req_builder =
327 local_var_req_builder.header("x-Request-Email", x_request_email.to_string());
328 local_var_req_builder =
329 local_var_req_builder.header("x-Device-Identifier", x_device_identifier.to_string());
330 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
331
332 let local_var_resp = local_var_req_builder.send().await?;
333
334 let local_var_status = local_var_resp.status();
335 let local_var_content_type = local_var_resp
336 .headers()
337 .get("content-type")
338 .and_then(|v| v.to_str().ok())
339 .unwrap_or("application/octet-stream");
340 let local_var_content_type = super::ContentType::from(local_var_content_type);
341 let local_var_content = local_var_resp.text().await?;
342
343 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
344 match local_var_content_type {
345 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
346 ContentType::Text => {
347 return Err(Error::from(serde_json::Error::custom(
348 "Received `text/plain` content type response that cannot be converted to `bool`",
349 )));
350 }
351 ContentType::Unsupported(local_var_unknown_type) => {
352 return Err(Error::from(serde_json::Error::custom(format!(
353 "Received `{local_var_unknown_type}` content type response that cannot be converted to `bool`"
354 ))));
355 }
356 }
357 } else {
358 let local_var_entity: Option<GetByIdentifierQueryError> =
359 serde_json::from_str(&local_var_content).ok();
360 let local_var_error = ResponseContent {
361 status: local_var_status,
362 content: local_var_content,
363 entity: local_var_entity,
364 };
365 Err(Error::ResponseError(local_var_error))
366 }
367 }
368
369 async fn post<'a>(
370 &self,
371 device_request_model: Option<models::DeviceRequestModel>,
372 ) -> Result<models::DeviceResponseModel, Error<PostError>> {
373 let local_var_configuration = &self.configuration;
374
375 let local_var_client = &local_var_configuration.client;
376
377 let local_var_uri_str = format!("{}/devices", local_var_configuration.base_path);
378 let mut local_var_req_builder =
379 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
380
381 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
382 local_var_req_builder = local_var_req_builder.json(&device_request_model);
383
384 let local_var_resp = local_var_req_builder.send().await?;
385
386 let local_var_status = local_var_resp.status();
387 let local_var_content_type = local_var_resp
388 .headers()
389 .get("content-type")
390 .and_then(|v| v.to_str().ok())
391 .unwrap_or("application/octet-stream");
392 let local_var_content_type = super::ContentType::from(local_var_content_type);
393 let local_var_content = local_var_resp.text().await?;
394
395 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
396 match local_var_content_type {
397 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
398 ContentType::Text => {
399 return Err(Error::from(serde_json::Error::custom(
400 "Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`",
401 )));
402 }
403 ContentType::Unsupported(local_var_unknown_type) => {
404 return Err(Error::from(serde_json::Error::custom(format!(
405 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`"
406 ))));
407 }
408 }
409 } else {
410 let local_var_entity: Option<PostError> = serde_json::from_str(&local_var_content).ok();
411 let local_var_error = ResponseContent {
412 status: local_var_status,
413 content: local_var_content,
414 entity: local_var_entity,
415 };
416 Err(Error::ResponseError(local_var_error))
417 }
418 }
419
420 async fn post_lost_trust(&self) -> Result<(), Error<PostLostTrustError>> {
421 let local_var_configuration = &self.configuration;
422
423 let local_var_client = &local_var_configuration.client;
424
425 let local_var_uri_str = format!("{}/devices/lost-trust", local_var_configuration.base_path);
426 let mut local_var_req_builder =
427 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
428
429 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
430
431 let local_var_resp = local_var_req_builder.send().await?;
432
433 let local_var_status = local_var_resp.status();
434 let local_var_content = local_var_resp.text().await?;
435
436 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
437 Ok(())
438 } else {
439 let local_var_entity: Option<PostLostTrustError> =
440 serde_json::from_str(&local_var_content).ok();
441 let local_var_error = ResponseContent {
442 status: local_var_status,
443 content: local_var_content,
444 entity: local_var_entity,
445 };
446 Err(Error::ResponseError(local_var_error))
447 }
448 }
449
450 async fn post_untrust<'a>(
451 &self,
452 untrust_devices_request_model: Option<models::UntrustDevicesRequestModel>,
453 ) -> Result<(), Error<PostUntrustError>> {
454 let local_var_configuration = &self.configuration;
455
456 let local_var_client = &local_var_configuration.client;
457
458 let local_var_uri_str = format!("{}/devices/untrust", local_var_configuration.base_path);
459 let mut local_var_req_builder =
460 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
461
462 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
463 local_var_req_builder = local_var_req_builder.json(&untrust_devices_request_model);
464
465 let local_var_resp = local_var_req_builder.send().await?;
466
467 let local_var_status = local_var_resp.status();
468 let local_var_content = local_var_resp.text().await?;
469
470 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
471 Ok(())
472 } else {
473 let local_var_entity: Option<PostUntrustError> =
474 serde_json::from_str(&local_var_content).ok();
475 let local_var_error = ResponseContent {
476 status: local_var_status,
477 content: local_var_content,
478 entity: local_var_entity,
479 };
480 Err(Error::ResponseError(local_var_error))
481 }
482 }
483
484 async fn post_update_trust<'a>(
485 &self,
486 update_devices_trust_request_model: Option<models::UpdateDevicesTrustRequestModel>,
487 ) -> Result<(), Error<PostUpdateTrustError>> {
488 let local_var_configuration = &self.configuration;
489
490 let local_var_client = &local_var_configuration.client;
491
492 let local_var_uri_str =
493 format!("{}/devices/update-trust", local_var_configuration.base_path);
494 let mut local_var_req_builder =
495 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
496
497 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
498 local_var_req_builder = local_var_req_builder.json(&update_devices_trust_request_model);
499
500 let local_var_resp = local_var_req_builder.send().await?;
501
502 let local_var_status = local_var_resp.status();
503 let local_var_content = local_var_resp.text().await?;
504
505 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
506 Ok(())
507 } else {
508 let local_var_entity: Option<PostUpdateTrustError> =
509 serde_json::from_str(&local_var_content).ok();
510 let local_var_error = ResponseContent {
511 status: local_var_status,
512 content: local_var_content,
513 entity: local_var_entity,
514 };
515 Err(Error::ResponseError(local_var_error))
516 }
517 }
518
519 async fn put<'a>(
520 &self,
521 id: &'a str,
522 device_request_model: Option<models::DeviceRequestModel>,
523 ) -> Result<models::DeviceResponseModel, Error<PutError>> {
524 let local_var_configuration = &self.configuration;
525
526 let local_var_client = &local_var_configuration.client;
527
528 let local_var_uri_str = format!(
529 "{}/devices/{id}",
530 local_var_configuration.base_path,
531 id = crate::apis::urlencode(id)
532 );
533 let mut local_var_req_builder =
534 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
535
536 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
537 local_var_req_builder = local_var_req_builder.json(&device_request_model);
538
539 let local_var_resp = local_var_req_builder.send().await?;
540
541 let local_var_status = local_var_resp.status();
542 let local_var_content_type = local_var_resp
543 .headers()
544 .get("content-type")
545 .and_then(|v| v.to_str().ok())
546 .unwrap_or("application/octet-stream");
547 let local_var_content_type = super::ContentType::from(local_var_content_type);
548 let local_var_content = local_var_resp.text().await?;
549
550 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
551 match local_var_content_type {
552 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
553 ContentType::Text => {
554 return Err(Error::from(serde_json::Error::custom(
555 "Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`",
556 )));
557 }
558 ContentType::Unsupported(local_var_unknown_type) => {
559 return Err(Error::from(serde_json::Error::custom(format!(
560 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`"
561 ))));
562 }
563 }
564 } else {
565 let local_var_entity: Option<PutError> = serde_json::from_str(&local_var_content).ok();
566 let local_var_error = ResponseContent {
567 status: local_var_status,
568 content: local_var_content,
569 entity: local_var_entity,
570 };
571 Err(Error::ResponseError(local_var_error))
572 }
573 }
574
575 async fn put_clear_token<'a>(
576 &self,
577 identifier: &'a str,
578 ) -> Result<(), Error<PutClearTokenError>> {
579 let local_var_configuration = &self.configuration;
580
581 let local_var_client = &local_var_configuration.client;
582
583 let local_var_uri_str = format!(
584 "{}/devices/identifier/{identifier}/clear-token",
585 local_var_configuration.base_path,
586 identifier = crate::apis::urlencode(identifier)
587 );
588 let mut local_var_req_builder =
589 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
590
591 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
592
593 let local_var_resp = local_var_req_builder.send().await?;
594
595 let local_var_status = local_var_resp.status();
596 let local_var_content = local_var_resp.text().await?;
597
598 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
599 Ok(())
600 } else {
601 let local_var_entity: Option<PutClearTokenError> =
602 serde_json::from_str(&local_var_content).ok();
603 let local_var_error = ResponseContent {
604 status: local_var_status,
605 content: local_var_content,
606 entity: local_var_entity,
607 };
608 Err(Error::ResponseError(local_var_error))
609 }
610 }
611
612 async fn put_keys<'a>(
613 &self,
614 identifier: &'a str,
615 device_keys_request_model: Option<models::DeviceKeysRequestModel>,
616 ) -> Result<models::DeviceResponseModel, Error<PutKeysError>> {
617 let local_var_configuration = &self.configuration;
618
619 let local_var_client = &local_var_configuration.client;
620
621 let local_var_uri_str = format!(
622 "{}/devices/{identifier}/keys",
623 local_var_configuration.base_path,
624 identifier = crate::apis::urlencode(identifier)
625 );
626 let mut local_var_req_builder =
627 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
628
629 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
630 local_var_req_builder = local_var_req_builder.json(&device_keys_request_model);
631
632 let local_var_resp = local_var_req_builder.send().await?;
633
634 let local_var_status = local_var_resp.status();
635 let local_var_content_type = local_var_resp
636 .headers()
637 .get("content-type")
638 .and_then(|v| v.to_str().ok())
639 .unwrap_or("application/octet-stream");
640 let local_var_content_type = super::ContentType::from(local_var_content_type);
641 let local_var_content = local_var_resp.text().await?;
642
643 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
644 match local_var_content_type {
645 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
646 ContentType::Text => {
647 return Err(Error::from(serde_json::Error::custom(
648 "Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`",
649 )));
650 }
651 ContentType::Unsupported(local_var_unknown_type) => {
652 return Err(Error::from(serde_json::Error::custom(format!(
653 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`"
654 ))));
655 }
656 }
657 } else {
658 let local_var_entity: Option<PutKeysError> =
659 serde_json::from_str(&local_var_content).ok();
660 let local_var_error = ResponseContent {
661 status: local_var_status,
662 content: local_var_content,
663 entity: local_var_entity,
664 };
665 Err(Error::ResponseError(local_var_error))
666 }
667 }
668
669 async fn put_token<'a>(
670 &self,
671 identifier: &'a str,
672 device_token_request_model: Option<models::DeviceTokenRequestModel>,
673 ) -> Result<(), Error<PutTokenError>> {
674 let local_var_configuration = &self.configuration;
675
676 let local_var_client = &local_var_configuration.client;
677
678 let local_var_uri_str = format!(
679 "{}/devices/identifier/{identifier}/token",
680 local_var_configuration.base_path,
681 identifier = crate::apis::urlencode(identifier)
682 );
683 let mut local_var_req_builder =
684 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
685
686 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
687 local_var_req_builder = local_var_req_builder.json(&device_token_request_model);
688
689 let local_var_resp = local_var_req_builder.send().await?;
690
691 let local_var_status = local_var_resp.status();
692 let local_var_content = local_var_resp.text().await?;
693
694 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
695 Ok(())
696 } else {
697 let local_var_entity: Option<PutTokenError> =
698 serde_json::from_str(&local_var_content).ok();
699 let local_var_error = ResponseContent {
700 status: local_var_status,
701 content: local_var_content,
702 entity: local_var_entity,
703 };
704 Err(Error::ResponseError(local_var_error))
705 }
706 }
707
708 async fn put_web_push_auth<'a>(
709 &self,
710 identifier: &'a str,
711 web_push_auth_request_model: Option<models::WebPushAuthRequestModel>,
712 ) -> Result<(), Error<PutWebPushAuthError>> {
713 let local_var_configuration = &self.configuration;
714
715 let local_var_client = &local_var_configuration.client;
716
717 let local_var_uri_str = format!(
718 "{}/devices/identifier/{identifier}/web-push-auth",
719 local_var_configuration.base_path,
720 identifier = crate::apis::urlencode(identifier)
721 );
722 let mut local_var_req_builder =
723 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
724
725 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
726 local_var_req_builder = local_var_req_builder.json(&web_push_auth_request_model);
727
728 let local_var_resp = local_var_req_builder.send().await?;
729
730 let local_var_status = local_var_resp.status();
731 let local_var_content = local_var_resp.text().await?;
732
733 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
734 Ok(())
735 } else {
736 let local_var_entity: Option<PutWebPushAuthError> =
737 serde_json::from_str(&local_var_content).ok();
738 let local_var_error = ResponseContent {
739 status: local_var_status,
740 content: local_var_content,
741 entity: local_var_entity,
742 };
743 Err(Error::ResponseError(local_var_error))
744 }
745 }
746}
747
748#[derive(Debug, Clone, Serialize, Deserialize)]
750#[serde(untagged)]
751pub enum DeactivateError {
752 UnknownValue(serde_json::Value),
753}
754#[derive(Debug, Clone, Serialize, Deserialize)]
756#[serde(untagged)]
757pub enum GetError {
758 UnknownValue(serde_json::Value),
759}
760#[derive(Debug, Clone, Serialize, Deserialize)]
762#[serde(untagged)]
763pub enum GetAllError {
764 UnknownValue(serde_json::Value),
765}
766#[derive(Debug, Clone, Serialize, Deserialize)]
768#[serde(untagged)]
769pub enum GetByIdentifierError {
770 UnknownValue(serde_json::Value),
771}
772#[derive(Debug, Clone, Serialize, Deserialize)]
774#[serde(untagged)]
775pub enum GetByIdentifierQueryError {
776 UnknownValue(serde_json::Value),
777}
778#[derive(Debug, Clone, Serialize, Deserialize)]
780#[serde(untagged)]
781pub enum PostError {
782 UnknownValue(serde_json::Value),
783}
784#[derive(Debug, Clone, Serialize, Deserialize)]
786#[serde(untagged)]
787pub enum PostLostTrustError {
788 UnknownValue(serde_json::Value),
789}
790#[derive(Debug, Clone, Serialize, Deserialize)]
792#[serde(untagged)]
793pub enum PostUntrustError {
794 UnknownValue(serde_json::Value),
795}
796#[derive(Debug, Clone, Serialize, Deserialize)]
798#[serde(untagged)]
799pub enum PostUpdateTrustError {
800 UnknownValue(serde_json::Value),
801}
802#[derive(Debug, Clone, Serialize, Deserialize)]
804#[serde(untagged)]
805pub enum PutError {
806 UnknownValue(serde_json::Value),
807}
808#[derive(Debug, Clone, Serialize, Deserialize)]
810#[serde(untagged)]
811pub enum PutClearTokenError {
812 UnknownValue(serde_json::Value),
813}
814#[derive(Debug, Clone, Serialize, Deserialize)]
816#[serde(untagged)]
817pub enum PutKeysError {
818 UnknownValue(serde_json::Value),
819}
820#[derive(Debug, Clone, Serialize, Deserialize)]
822#[serde(untagged)]
823pub enum PutTokenError {
824 UnknownValue(serde_json::Value),
825}
826#[derive(Debug, Clone, Serialize, Deserialize)]
828#[serde(untagged)]
829pub enum PutWebPushAuthError {
830 UnknownValue(serde_json::Value),
831}