use crate::cores::endpoint::Endpoint;
use derive_builder::Builder;
use http::Method;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, skip_serializing_none};
#[serde_as]
#[skip_serializing_none]
#[derive(Builder, Default, Debug, Clone, Serialize, Deserialize)]
#[builder(setter(into))]
pub struct UpdateWebhook {
webhook_id: String,
is_active: bool,
}
impl UpdateWebhook {
pub fn builder() -> UpdateWebhookBuilder {
UpdateWebhookBuilder::default()
}
}
impl Endpoint for UpdateWebhook {
fn method(&self) -> http::Method {
Method::PUT
}
fn endpoint(&self) -> std::borrow::Cow<'static, str> {
"api/update-webhook".into()
}
fn body(&self) -> anyhow::Result<Option<(&'static str, Vec<u8>)>> {
let body = serde_json::to_vec(self)?;
Ok(Some(("application/json", body)))
}
}