use std::sync::Arc;
use serde::Serialize;
use serde_json::Value;
use crate::client::Inner;
use crate::error::Result;
use crate::params;
#[derive(Clone, Debug)]
pub struct Senders {
inner: Arc<Inner>,
}
impl Senders {
pub(crate) fn new(inner: Arc<Inner>) -> Self {
Self { inner }
}
pub async fn create(&self, params: impl Serialize) -> Result<Value> {
self.inner
.call("POST", "/v1/senders", crate::params::to_body(params)?)
.await
}
pub async fn list(&self, params: impl Serialize) -> Result<Value> {
self.inner
.call(
"GET",
&format!("/v1/senders{}", params::query(params)?),
None,
)
.await
}
pub async fn get(&self, id: &str, params: impl Serialize) -> Result<Value> {
self.inner
.call(
"GET",
&format!(
"/v1/senders/{}{}",
crate::params::encode(id),
crate::params::query(params)?
),
None,
)
.await
}
pub async fn update(&self, id: &str, params: impl Serialize) -> Result<Value> {
self.inner
.call(
"PATCH",
&format!("/v1/senders/{}", crate::params::encode(id)),
crate::params::to_body(params)?,
)
.await
}
pub async fn delete(&self, id: &str, params: impl Serialize) -> Result<Value> {
self.inner
.call(
"DELETE",
&format!(
"/v1/senders/{}{}",
crate::params::encode(id),
crate::params::query(params)?
),
None,
)
.await
}
}