use crate::client::Scope;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;
pub struct AccessTokensService<'a> {
scope: Scope<'a>,
}
impl<'a> AccessTokensService<'a> {
pub(crate) fn new(scope: Scope<'a>) -> Self {
Self { scope }
}
pub fn scope(&self) -> &Scope<'a> {
&self.scope
}
pub async fn create(
&self,
body: &CreateAccessTokenRequestContent,
) -> Result<AccessToken, Error> {
let mut operation = self.scope.operation(&routes::CREATE_ACCESS_TOKEN, &[])?;
operation.json(body)?;
self.scope.client().send(operation).await
}
pub async fn delete(&self, access_token_id: &str) -> Result<(), Error> {
let mut operation = self
.scope
.operation(&routes::DELETE_ACCESS_TOKEN, &[&access_token_id])?;
operation.resource_id(access_token_id);
self.scope.client().send_unit(operation).await
}
pub async fn list(&self) -> Result<Vec<AccessToken>, Error> {
let operation = self.scope.operation(&routes::LIST_ACCESS_TOKENS, &[])?;
self.scope.client().send(operation).await
}
}