use super::super::Trigger;
use super::super::kind::TriggerKind;
use super::HttpMethod;
pub const DEFAULT_WEBHOOK_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30);
impl Trigger {
#[must_use]
pub fn webhook(url: impl Into<String>) -> Self {
Self {
kind: TriggerKind::Webhook(Box::new(super::build_webhook_config(url))),
retries: 0,
required: true,
timeout: Some(DEFAULT_WEBHOOK_TIMEOUT),
fail_fast: true,
}
}
#[must_use]
pub fn method(mut self, method: HttpMethod) -> Self {
if let TriggerKind::Webhook(cfg) = &mut self.kind {
super::webhook_set_method(cfg, method);
}
self
}
#[must_use]
pub fn header(mut self, name: impl Into<String>, value: impl Into<String>) -> Self {
if let TriggerKind::Webhook(cfg) = &mut self.kind {
super::webhook_add_header(cfg, name, value);
}
self
}
#[must_use]
pub fn body_template(mut self, body: impl Into<String>) -> Self {
if let TriggerKind::Webhook(cfg) = &mut self.kind {
super::webhook_set_body_template(cfg, body);
}
self
}
}