use std::sync::Arc;
use crate::error::Result;
use crate::http::Config;
use crate::types::{
list_query, CreateDomainOptions, DeleteDomainResponse, Domain, List, ListOptions,
UpdateDomainOptions,
};
#[derive(Clone)]
pub struct Domains(pub(crate) Arc<Config>);
impl Domains {
pub async fn create(&self, domain: &CreateDomainOptions) -> Result<Domain> {
self.0.post(&["domains"], domain).await
}
pub async fn get(&self, id: &str) -> Result<Domain> {
self.0.get(&["domains", id], &[]).await
}
pub async fn list(&self, options: Option<&ListOptions>) -> Result<List<Domain>> {
self.0.get(&["domains"], &list_query(options)).await
}
pub async fn verify(&self, id: &str) -> Result<Domain> {
self.0.post_empty(&["domains", id, "verify"]).await
}
pub async fn update(&self, id: &str, changes: &UpdateDomainOptions) -> Result<Domain> {
self.0.patch(&["domains", id], changes).await
}
pub async fn delete(&self, id: &str) -> Result<DeleteDomainResponse> {
self.0.delete(&["domains", id]).await
}
}