use serde::Serialize;
use crate::client::Sentd;
use crate::error::Error;
use crate::types::*;
pub struct Domains {
client: Sentd,
}
impl Domains {
pub(crate) fn new(client: Sentd) -> Self {
Self { client }
}
pub async fn list(&self) -> Result<ListDomainsResponse, Error> {
self.client.get("/api/domains").await
}
pub async fn get(&self, id: &str) -> Result<DomainResponse, Error> {
self.client.get(&format!("/api/domains/{}", id)).await
}
pub async fn add(&self, domain: &str) -> Result<DomainResponse, Error> {
#[derive(Serialize)]
struct AddDomainRequest<'a> {
domain: &'a str,
}
self.client.post("/api/domains", &AddDomainRequest { domain }).await
}
pub async fn verify(&self, id: &str) -> Result<VerifyDomainResponse, Error> {
self.client.post(&format!("/api/domains/{}/verify", id), &()).await
}
pub async fn delete(&self, id: &str) -> Result<SuccessResponse, Error> {
self.client.delete(&format!("/api/domains/{}", id)).await
}
}