Skip to main content

fizzy_sdk/generated/services/
devices.rs

1// Generated by fizzy-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
2
3use crate::client::Scope;
4use crate::error::Error;
5use crate::generated::routes;
6use crate::generated::types::*;
7
8/// The `Devices` operations.
9pub struct DevicesService<'a> {
10    scope: Scope<'a>,
11}
12
13impl<'a> DevicesService<'a> {
14    pub(crate) fn new(scope: Scope<'a>) -> Self {
15        Self { scope }
16    }
17
18    /// The client and account these operations send through.
19    pub fn scope(&self) -> &Scope<'a> {
20        &self.scope
21    }
22
23    /// `RegisterDevice` — `POST /{accountId}/devices`.
24    ///
25    /// Sent once and never resent.
26    pub async fn register(&self, body: &RegisterDeviceRequestContent) -> Result<(), Error> {
27        let mut operation = self.scope.operation(&routes::REGISTER_DEVICE, &[])?;
28        operation.json(body)?;
29        self.scope.client().send_unit(operation).await
30    }
31
32    /// `UnregisterDevice` — `DELETE /{accountId}/devices/{deviceToken}`.
33    ///
34    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
35    pub async fn unregister(&self, device_token: &str) -> Result<(), Error> {
36        let mut operation = self
37            .scope
38            .operation(&routes::UNREGISTER_DEVICE, &[&device_token])?;
39        operation.resource_id(device_token);
40        self.scope.client().send_unit(operation).await
41    }
42}