sendgrid_api/sender_verification.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct SenderVerification {
5 pub client: Client,
6}
7
8impl SenderVerification {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 SenderVerification { client }
12 }
13
14 /**
15 * Domain Warn List.
16 *
17 * This function performs a `GET` to the `/verified_senders/domains` endpoint.
18 *
19 * **This endpoint returns a list of domains known to implement DMARC and categorizes them by failure type — hard failure or soft failure**.
20 *
21 * Domains listed as hard failures will not deliver mail when used as a [Sender Identity](https://sendgrid.com/docs/for-developers/sending-email/sender-identity/) due to the domain's DMARC policy settings.
22 *
23 * For example, using a `yahoo.com` email address as a Sender Identity will likely result in the rejection of your mail. For more information about DMARC, see [Everything about DMARC](https://sendgrid.com/docs/ui/sending-email/dmarc/).
24 */
25 pub async fn get_verified_senders_domains(
26 &self,
27 ) -> ClientResult<crate::Response<crate::types::GetVerifiedSendersDomainsResponse>> {
28 let url = self.client.url("/verified_senders/domains", None);
29 self.client
30 .get(
31 &url,
32 crate::Message {
33 body: None,
34 content_type: None,
35 },
36 )
37 .await
38 }
39 /**
40 * Completed Steps.
41 *
42 * This function performs a `GET` to the `/verified_senders/steps_completed` endpoint.
43 *
44 * **This endpoint allows you to determine which of SendGrid’s verification processes have been completed for an account**.
45 *
46 * This endpoint returns boolean values, `true` and `false`, for [Domain Authentication](https://sendgrid.com/docs/for-developers/sending-email/sender-identity/#domain-authentication), `domain_verified`, and [Single Sender Verification](https://sendgrid.com/docs/for-developers/sending-email/sender-identity/#single-sender-verification), `sender_verified`, for the account.
47 *
48 * An account may have one, both, or neither verification steps completed. If you need to authenticate a domain rather than a Single Sender, see the "Authenticate a domain" endpoint.
49 */
50 pub async fn get_verified_senders_steps_completed(
51 &self,
52 ) -> ClientResult<crate::Response<crate::types::GetVerifiedSendersStepsCompletedResponse>> {
53 let url = self.client.url("/verified_senders/steps_completed", None);
54 self.client
55 .get(
56 &url,
57 crate::Message {
58 body: None,
59 content_type: None,
60 },
61 )
62 .await
63 }
64 /**
65 * Get All Verified Senders.
66 *
67 * This function performs a `GET` to the `/verified_senders` endpoint.
68 *
69 * **This endpoint allows you to retrieve all the Sender Identities associated with an account.**
70 *
71 * This endpoint will return both verified and unverified senders.
72 *
73 * You can limit the number of results returned using the `limit`, `lastSeenID`, and `id` query string parameters.
74 *
75 * * `limit` allows you to specify an exact number of Sender Identities to return.
76 * * `lastSeenID` will return senders with an ID number occuring after the passed in ID. In other words, the `lastSeenID` provides a starting point from which SendGrid will iterate to find Sender Identities associated with your account.
77 * * `id` will return information about only the Sender Identity passed in the request.
78 *
79 * **Parameters:**
80 *
81 * * `limit: f64` -- The number of errors found while adding recipients.
82 * * `last_seen_id: f64` -- The number of errors found while adding recipients.
83 * * `id: i64`
84 */
85 pub async fn get_verified_senders(
86 &self,
87 limit: f64,
88 last_seen_id: f64,
89 id: i64,
90 ) -> ClientResult<crate::Response<crate::types::GetVerifiedSendersResponse>> {
91 let mut query_args: Vec<(String, String)> = Default::default();
92 if id > 0 {
93 query_args.push(("id".to_string(), id.to_string()));
94 }
95 if !last_seen_id.to_string().is_empty() {
96 query_args.push(("lastSeenID".to_string(), last_seen_id.to_string()));
97 }
98 if !limit.to_string().is_empty() {
99 query_args.push(("limit".to_string(), limit.to_string()));
100 }
101 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
102 let url = self
103 .client
104 .url(&format!("/verified_senders?{}", query_), None);
105 self.client
106 .get(
107 &url,
108 crate::Message {
109 body: None,
110 content_type: None,
111 },
112 )
113 .await
114 }
115 /**
116 * Create Verified Sender Request.
117 *
118 * This function performs a `POST` to the `/verified_senders` endpoint.
119 *
120 * **This endpoint allows you to create a new Sender Identify**.
121 *
122 * Upon successful submission of a `POST` request to this endpoint, an identity will be created, and a verification email will be sent to the address assigned to the `from_email` field. You must complete the verification process using the sent email to fully verify the sender.
123 *
124 * If you need to resend the verification email, you can do so with the Resend Verified Sender Request, `/resend/{id}`, endpoint.
125 *
126 * If you need to authenticate a domain rather than a Single Sender, see the [Domain Authentication API](https://sendgrid.api-docs.io/v3.0/domain-authentication/authenticate-a-domain).
127 */
128 pub async fn post_verified_sender(
129 &self,
130 body: &crate::types::VerifiedSenderRequestSchema,
131 ) -> ClientResult<crate::Response<crate::types::VerifiedSenderResponseSchema>> {
132 let url = self.client.url("/verified_senders", None);
133 self.client
134 .post(
135 &url,
136 crate::Message {
137 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
138 content_type: None,
139 },
140 )
141 .await
142 }
143 /**
144 * Verify Sender Request.
145 *
146 * This function performs a `GET` to the `/verified_senders/verify/{token}` endpoint.
147 *
148 * **This endpoint allows you to verify a sender requests.**
149 *
150 * The token is generated by SendGrid and included in a verification email delivered to the address that's pending verification.
151 */
152 pub async fn get_verified_senders_verify_token(
153 &self,
154 token: &str,
155 ) -> ClientResult<crate::Response<()>> {
156 let url = self.client.url(
157 &format!(
158 "/verified_senders/verify/{}",
159 crate::progenitor_support::encode_path(token),
160 ),
161 None,
162 );
163 self.client
164 .get(
165 &url,
166 crate::Message {
167 body: None,
168 content_type: None,
169 },
170 )
171 .await
172 }
173 /**
174 * Delete Verified Sender.
175 *
176 * This function performs a `DELETE` to the `/verified_senders/{id}` endpoint.
177 *
178 * **This endpoint allows you to delete a Sender Identity**.
179 *
180 * Pass the `id` assigned to a Sender Identity to this endpoint to delete the Sender Identity from your account.
181 *
182 * You can retrieve the IDs associated with Sender Identities using the "Get All Verified Senders" endpoint.
183 */
184 pub async fn delete_verified_senders(
185 &self,
186 id: &str,
187 ) -> ClientResult<crate::Response<crate::types::Help>> {
188 let url = self.client.url(
189 &format!(
190 "/verified_senders/{}",
191 crate::progenitor_support::encode_path(id),
192 ),
193 None,
194 );
195 self.client
196 .delete(
197 &url,
198 crate::Message {
199 body: None,
200 content_type: None,
201 },
202 )
203 .await
204 }
205 /**
206 * Edit Verified Sender.
207 *
208 * This function performs a `PATCH` to the `/verified_senders/{id}` endpoint.
209 *
210 * **This endpoint allows you to update an existing Sender Identity**.
211 *
212 * Pass the `id` assigned to a Sender Identity to this endpoint as a path parameter. Include any fields you wish to update in the request body in JSON format.
213 *
214 * You can retrieve the IDs associated with Sender Identities by passing a `GET` request to the Get All Verified Senders endpoint, `/verified_senders`.
215 *
216 * **Note:** Unlike a `PUT` request, `PATCH` allows you to update only the fields you wish to edit. Fields that are not passed as part of a request will remain unaltered.
217 */
218 pub async fn patch_verified_senders(
219 &self,
220 id: &str,
221 body: &crate::types::VerifiedSenderRequestSchema,
222 ) -> ClientResult<crate::Response<crate::types::VerifiedSenderResponseSchema>> {
223 let url = self.client.url(
224 &format!(
225 "/verified_senders/{}",
226 crate::progenitor_support::encode_path(id),
227 ),
228 None,
229 );
230 self.client
231 .patch(
232 &url,
233 crate::Message {
234 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
235 content_type: None,
236 },
237 )
238 .await
239 }
240 /**
241 * Resend Verified Sender Request.
242 *
243 * This function performs a `POST` to the `/verified_senders/resend/{id}` endpoint.
244 *
245 * **This endpoint allows you to resend a verification email to a specified Sender Identity**.
246 *
247 * Passing the `id` assigned to a Sender Identity to this endpoint will resend a verification email to the `from_address` associated with the Sender Identity. This can be useful if someone loses their verification email or needs to have it resent for any other reason.
248 *
249 * You can retrieve the IDs associated with Sender Identities by passing a "Get All Verified Senders" endpoint.
250 */
251 pub async fn post_verified_senders_resend(
252 &self,
253 id: &str,
254 ) -> ClientResult<crate::Response<crate::types::Help>> {
255 let url = self.client.url(
256 &format!(
257 "/verified_senders/resend/{}",
258 crate::progenitor_support::encode_path(id),
259 ),
260 None,
261 );
262 self.client
263 .post(
264 &url,
265 crate::Message {
266 body: None,
267 content_type: None,
268 },
269 )
270 .await
271 }
272}