fizzy-sdk 0.2.4

Official Fizzy API client, generated from the Smithy model in spec/
Documentation
// Generated by fizzy-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.

use crate::client::Scope;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;

/// The `Devices` operations.
pub struct DevicesService<'a> {
    scope: Scope<'a>,
}

impl<'a> DevicesService<'a> {
    pub(crate) fn new(scope: Scope<'a>) -> Self {
        Self { scope }
    }

    /// The client and account these operations send through.
    pub fn scope(&self) -> &Scope<'a> {
        &self.scope
    }

    /// `RegisterDevice` — `POST /{accountId}/devices`.
    ///
    /// Sent once and never resent.
    pub async fn register(&self, body: &RegisterDeviceRequestContent) -> Result<(), Error> {
        let mut operation = self.scope.operation(&routes::REGISTER_DEVICE, &[])?;
        operation.json(body)?;
        self.scope.client().send_unit(operation).await
    }

    /// `UnregisterDevice` — `DELETE /{accountId}/devices/{deviceToken}`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn unregister(&self, device_token: &str) -> Result<(), Error> {
        let mut operation = self
            .scope
            .operation(&routes::UNREGISTER_DEVICE, &[&device_token])?;
        operation.resource_id(device_token);
        self.scope.client().send_unit(operation).await
    }
}