sendgrid_api/
settings_inbound_parse.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct SettingsInboundParse {
5    pub client: Client,
6}
7
8impl SettingsInboundParse {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        SettingsInboundParse { client }
12    }
13
14    /**
15     * Create a parse setting.
16     *
17     * This function performs a `POST` to the `/user/webhooks/parse/settings` endpoint.
18     *
19     * **This endpoint allows you to create a new inbound parse setting.**
20     *
21     * Creating an Inbound Parse setting requires two pieces of information: a `url` and a `hostname`.
22     *
23     * The `hostname` must correspond to a domain authenticated by Twilio SendGrid on your account. If you need to complete domain authentication, you can use the [Twilio SendGrid App](https://app.sendgrid.com/settings/sender_auth) or the "Authenticate a domain" endpoint. See "[How to Set Up Domain Authentication](https://sendgrid.com/docs/ui/account-and-settings/how-to-set-up-domain-authentication/)" for instructions.
24     *
25     * Any email received by the `hostname` will be parsed when you complete this setup. You must also add a Twilio SendGrid MX record to this domain's DNS records. See "[Setting up the Inbound Parse Webhook](https://sendgrid.com/docs/for-developers/parsing-email/setting-up-the-inbound-parse-webhook/)" for full instructions.
26     *
27     * The `url` represents a location where the parsed message data will be delivered. Twilio SendGrid will make an HTTP POST request to this `url` with the message data. The `url` must be publicly reachable, and your application must return a `200` status code to signal that the message data has been received.
28     *
29     * **Parameters:**
30     *
31     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
32     */
33    pub async fn post_user_webhooks_parse_setting(
34        &self,
35        body: &crate::types::ParseSetting,
36    ) -> ClientResult<crate::Response<crate::types::ParseSetting>> {
37        let url = self.client.url("/user/webhooks/parse/settings", None);
38        self.client
39            .post(
40                &url,
41                crate::Message {
42                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
43                    content_type: None,
44                },
45            )
46            .await
47    }
48    /**
49     * Retrieve a specific parse setting.
50     *
51     * This function performs a `GET` to the `/user/webhooks/parse/settings/{hostname}` endpoint.
52     *
53     * **This endpoint allows you to retrieve a specific inbound parse setting by hostname.**
54     *
55     * You can retrieve all your Inbound Parse settings and their associated host names with the "Retrieve all parse settings" endpoint.
56     *
57     * **Parameters:**
58     *
59     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
60     */
61    pub async fn get_user_webhooks_parse_settings_hostname(
62        &self,
63        hostname: &str,
64    ) -> ClientResult<crate::Response<crate::types::ParseSetting>> {
65        let url = self.client.url(
66            &format!(
67                "/user/webhooks/parse/settings/{}",
68                crate::progenitor_support::encode_path(hostname),
69            ),
70            None,
71        );
72        self.client
73            .get(
74                &url,
75                crate::Message {
76                    body: None,
77                    content_type: None,
78                },
79            )
80            .await
81    }
82    /**
83     * Delete a parse setting.
84     *
85     * This function performs a `DELETE` to the `/user/webhooks/parse/settings/{hostname}` endpoint.
86     *
87     * **This endpoint allows you to delete a specific inbound parse setting by hostname.**
88     *
89     * You can retrieve all your Inbound Parse settings and their associated host names with the "Retrieve all parse settings" endpoint.
90     *
91     * **Parameters:**
92     *
93     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
94     */
95    pub async fn delete_user_webhooks_parse_settings_hostname(
96        &self,
97        hostname: &str,
98    ) -> ClientResult<crate::Response<crate::types::Help>> {
99        let url = self.client.url(
100            &format!(
101                "/user/webhooks/parse/settings/{}",
102                crate::progenitor_support::encode_path(hostname),
103            ),
104            None,
105        );
106        self.client
107            .delete(
108                &url,
109                crate::Message {
110                    body: None,
111                    content_type: None,
112                },
113            )
114            .await
115    }
116    /**
117     * Update a parse setting.
118     *
119     * This function performs a `PATCH` to the `/user/webhooks/parse/settings/{hostname}` endpoint.
120     *
121     * **This endpoint allows you to update a specific inbound parse setting by hostname.**
122     *
123     * You can retrieve all your Inbound Parse settings and their associated host names with the "Retrieve all parse settings" endpoint.
124     *
125     * **Parameters:**
126     *
127     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
128     */
129    pub async fn patch_user_webhooks_parse_settings_hostname(
130        &self,
131        hostname: &str,
132        body: &crate::types::ParseSetting,
133    ) -> ClientResult<crate::Response<crate::types::ParseSetting>> {
134        let url = self.client.url(
135            &format!(
136                "/user/webhooks/parse/settings/{}",
137                crate::progenitor_support::encode_path(hostname),
138            ),
139            None,
140        );
141        self.client
142            .patch(
143                &url,
144                crate::Message {
145                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
146                    content_type: None,
147                },
148            )
149            .await
150    }
151}