fizzy_sdk/generated/services/
devices.rs1use crate::client::Scope;
4use crate::error::Error;
5use crate::generated::routes;
6use crate::generated::types::*;
7
8pub 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 pub fn scope(&self) -> &Scope<'a> {
20 &self.scope
21 }
22
23 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 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}