pipedrive_rs/models/
add_webhook_request.rs

1/*
2 * Pipedrive API v1
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.0.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12
13
14#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
15pub struct AddWebhookRequest {
16    /// A full, valid, publicly accessible URL which determines where to send the notifications. Please note that you cannot use Pipedrive API endpoints as the `subscription_url` and the chosen URL must not redirect to another link.
17    #[serde(rename = "subscription_url")]
18    pub subscription_url: String,
19    /// The type of action to receive notifications about. Wildcard will match all supported actions.
20    #[serde(rename = "event_action")]
21    pub event_action: EventAction,
22    /// The type of object to receive notifications about. Wildcard will match all supported objects.
23    #[serde(rename = "event_object")]
24    pub event_object: EventObject,
25    /// The ID of the user that this webhook will be authorized with. You have the option to use a different user's `user_id`. If it is not set, the current user's `user_id` will be used. As each webhook event is checked against a user’s permissions, the webhook will only be sent if the user has access to the specified object(s). If you want to receive notifications for all events, please use a top-level admin user’s `user_id`.
26    #[serde(rename = "user_id", skip_serializing_if = "Option::is_none")]
27    pub user_id: Option<i32>,
28    /// The HTTP basic auth username of the subscription URL endpoint (if required)
29    #[serde(rename = "http_auth_user", skip_serializing_if = "Option::is_none")]
30    pub http_auth_user: Option<String>,
31    /// The HTTP basic auth password of the subscription URL endpoint (if required)
32    #[serde(rename = "http_auth_password", skip_serializing_if = "Option::is_none")]
33    pub http_auth_password: Option<String>,
34    /// The webhook's version
35    #[serde(rename = "version", skip_serializing_if = "Option::is_none")]
36    pub version: Option<Version>,
37}
38
39impl AddWebhookRequest {
40    pub fn new(subscription_url: String, event_action: EventAction, event_object: EventObject) -> AddWebhookRequest {
41        AddWebhookRequest {
42            subscription_url,
43            event_action,
44            event_object,
45            user_id: None,
46            http_auth_user: None,
47            http_auth_password: None,
48            version: None,
49        }
50    }
51}
52
53/// The type of action to receive notifications about. Wildcard will match all supported actions.
54#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
55pub enum EventAction {
56    #[serde(rename = "added")]
57    Added,
58    #[serde(rename = "updated")]
59    Updated,
60    #[serde(rename = "merged")]
61    Merged,
62    #[serde(rename = "deleted")]
63    Deleted,
64    #[serde(rename = "*")]
65    Star,
66}
67
68impl Default for EventAction {
69    fn default() -> EventAction {
70        Self::Added
71    }
72}
73/// The type of object to receive notifications about. Wildcard will match all supported objects.
74#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
75pub enum EventObject {
76    #[serde(rename = "activity")]
77    Activity,
78    #[serde(rename = "activityType")]
79    ActivityType,
80    #[serde(rename = "deal")]
81    Deal,
82    #[serde(rename = "note")]
83    Note,
84    #[serde(rename = "organization")]
85    Organization,
86    #[serde(rename = "person")]
87    Person,
88    #[serde(rename = "pipeline")]
89    Pipeline,
90    #[serde(rename = "product")]
91    Product,
92    #[serde(rename = "stage")]
93    Stage,
94    #[serde(rename = "user")]
95    User,
96    #[serde(rename = "*")]
97    Star,
98}
99
100impl Default for EventObject {
101    fn default() -> EventObject {
102        Self::Activity
103    }
104}
105/// The webhook's version
106#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
107pub enum Version {
108    #[serde(rename = "1.0")]
109    Variant1Period0,
110    #[serde(rename = "2.0")]
111    Variant2Period0,
112}
113
114impl Default for Version {
115    fn default() -> Version {
116        Self::Variant1Period0
117    }
118}
119