Skip to main content

highlevel_api/apis/webhooks/
types.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4#[serde(rename_all = "camelCase")]
5pub struct Webhook {
6    pub id: String,
7    pub location_id: String,
8    pub name: String,
9    pub url: String,
10    pub status: String,
11    #[serde(default)]
12    pub events: Vec<String>,
13}
14
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct GetWebhooksResponse {
17    pub webhooks: Vec<Webhook>,
18}
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct GetWebhookResponse {
22    pub webhook: Webhook,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct CreateWebhookParams {
27    pub name: String,
28    pub url: String,
29    pub events: Vec<String>,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize, Default)]
33pub struct UpdateWebhookParams {
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub name: Option<String>,
36    #[serde(skip_serializing_if = "Option::is_none")]
37    pub url: Option<String>,
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub events: Option<Vec<String>>,
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub status: Option<String>,
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
45pub struct DeleteWebhookResponse {
46    pub succeded: bool,
47}
48
49/// Well-known GHL webhook event types.
50pub mod events {
51    pub const CONTACT_CREATE: &str = "ContactCreate";
52    pub const CONTACT_UPDATE: &str = "ContactUpdate";
53    pub const CONTACT_DELETE: &str = "ContactDelete";
54    pub const OPPORTUNITY_CREATE: &str = "OpportunityCreate";
55    pub const OPPORTUNITY_UPDATE: &str = "OpportunityUpdate";
56    pub const OPPORTUNITY_DELETE: &str = "OpportunityDelete";
57    pub const OPPORTUNITY_STAGE_UPDATE: &str = "OpportunityStageUpdate";
58    pub const OPPORTUNITY_STATUS_UPDATE: &str = "OpportunityStatusUpdate";
59    pub const OPPORTUNITY_MONETARY_VALUE_UPDATE: &str = "OpportunityMonetaryValueUpdate";
60    pub const CONVERSATION_CREATE: &str = "ConversationCreate";
61    pub const CONVERSATION_UPDATE: &str = "ConversationUpdate";
62    pub const SMS_SENT: &str = "OutboundMessage";
63    pub const SMS_RECEIVED: &str = "InboundMessage";
64    pub const APPOINTMENT_CREATE: &str = "AppointmentCreate";
65    pub const APPOINTMENT_UPDATE: &str = "AppointmentUpdate";
66    pub const APPOINTMENT_DELETE: &str = "AppointmentDelete";
67    pub const FORM_SUBMISSION: &str = "FormSubmissionCreate";
68    pub const SURVEY_SUBMISSION: &str = "SurveySubmissionCreate";
69    pub const NOTE_CREATE: &str = "NoteCreate";
70    pub const NOTE_UPDATE: &str = "NoteUpdate";
71    pub const NOTE_DELETE: &str = "NoteDelete";
72    pub const TASK_CREATE: &str = "TaskCreate";
73    pub const TASK_UPDATE: &str = "TaskUpdate";
74    pub const TASK_DELETE: &str = "TaskDelete";
75    pub const INSTALL: &str = "Install";
76    pub const UNINSTALL: &str = "Uninstall";
77}