use crate::error::MisarDevError;
use crate::transport::Transport;
use crate::transport::body_or_empty;
use crate::transport::build_query;
use crate::transport::encode_path;
use reqwest::Method;
use serde_json::Value;
#[derive(Debug, Clone, Copy)]
pub struct DomainsResource<'a> {
pub(crate) t: &'a Transport,
}
impl DomainsResource<'_> {
pub async fn checkout(self, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, "/domains/checkout", "", Some(body_or_empty(body))).await
}
pub async fn create_dns_record(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, &format!("/domains/{}/dns", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn delete_dns_record(self, id: &str, record_id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::DELETE, &format!("/domains/{}/dns", encode_path(id)), &build_query(None, &[("recordId", record_id)]), None).await
}
pub async fn list(self) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, "/domains", "", None).await
}
pub async fn list_dns_records(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/domains/{}/dns", encode_path(id)), "", None).await
}
pub async fn lookup(self, domain: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, "/domains/lookup", &build_query(None, &[("domain", domain)]), None).await
}
pub async fn search(self, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, "/domains/search", "", Some(body_or_empty(body))).await
}
pub async fn update(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::PATCH, &format!("/domains/{}", encode_path(id)), "", Some(body_or_empty(body))).await
}
}