use crate::client::Scope;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;
pub struct DevicesService<'a> {
scope: Scope<'a>,
}
impl<'a> DevicesService<'a> {
pub(crate) fn new(scope: Scope<'a>) -> Self {
Self { scope }
}
pub fn scope(&self) -> &Scope<'a> {
&self.scope
}
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
}
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
}
}