sendgrid_api/sender_identities_api.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct SenderIdentitiesApi {
5 pub client: Client,
6}
7
8impl SenderIdentitiesApi {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 SenderIdentitiesApi { client }
12 }
13
14 /**
15 * Get all Sender Identities.
16 *
17 * This function performs a `GET` to the `/senders` endpoint.
18 *
19 * **This endpoint allows you to retrieve a list of all sender identities that have been created for your account.**
20 *
21 * **Parameters:**
22 *
23 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
24 */
25 pub async fn get_senders(
26 &self,
27 ) -> ClientResult<crate::Response<crate::types::GetSendersResponse>> {
28 let url = self.client.url("/senders", 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 * Create a Sender Identity.
41 *
42 * This function performs a `POST` to the `/senders` endpoint.
43 *
44 * **This endpoint allows you to create a new sender identity.**
45 *
46 * You may create up to 100 unique sender identities.
47 *
48 * **Parameters:**
49 *
50 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
51 */
52 pub async fn post_sender(
53 &self,
54 body: &crate::types::PostSendersRequestAllOf,
55 ) -> ClientResult<crate::Response<crate::types::SenderAllOf>> {
56 let url = self.client.url("/senders", None);
57 self.client
58 .post(
59 &url,
60 crate::Message {
61 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
62 content_type: Some("application/json".to_string()),
63 },
64 )
65 .await
66 }
67 /**
68 * View a Sender Identity.
69 *
70 * This function performs a `GET` to the `/senders/{sender_id}` endpoint.
71 *
72 * **This endpoint allows you to retrieve a specific sender identity.**
73 *
74 * **Parameters:**
75 *
76 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
77 */
78 pub async fn get_senders_sender(
79 &self,
80 sender_id: i64,
81 ) -> ClientResult<crate::Response<crate::types::SenderAllOf>> {
82 let url = self.client.url(
83 &format!(
84 "/senders/{}",
85 crate::progenitor_support::encode_path(&sender_id.to_string()),
86 ),
87 None,
88 );
89 self.client
90 .get(
91 &url,
92 crate::Message {
93 body: None,
94 content_type: None,
95 },
96 )
97 .await
98 }
99 /**
100 * Delete a Sender Identity.
101 *
102 * This function performs a `DELETE` to the `/senders/{sender_id}` endpoint.
103 *
104 * **This endoint allows you to delete one of your sender identities.**
105 *
106 * **Parameters:**
107 *
108 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
109 */
110 pub async fn delete_senders_sender(
111 &self,
112 sender_id: i64,
113 ) -> ClientResult<crate::Response<crate::types::Help>> {
114 let url = self.client.url(
115 &format!(
116 "/senders/{}",
117 crate::progenitor_support::encode_path(&sender_id.to_string()),
118 ),
119 None,
120 );
121 self.client
122 .delete(
123 &url,
124 crate::Message {
125 body: None,
126 content_type: None,
127 },
128 )
129 .await
130 }
131 /**
132 * Update a Sender Identity.
133 *
134 * This function performs a `PATCH` to the `/senders/{sender_id}` endpoint.
135 *
136 * **This endpoint allows you to update a sender identity.**
137 *
138 * Updates to `from.email` require re-verification.
139 *
140 * Partial updates are allowed, but fields that are marked as "required" in the POST (create) endpoint must not be nil if that field is included in the PATCH request.
141 *
142 * **Parameters:**
143 *
144 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
145 */
146 pub async fn patch_senders_sender(
147 &self,
148 sender_id: i64,
149 body: &crate::types::SenderRequest,
150 ) -> ClientResult<crate::Response<crate::types::SenderAllOf>> {
151 let url = self.client.url(
152 &format!(
153 "/senders/{}",
154 crate::progenitor_support::encode_path(&sender_id.to_string()),
155 ),
156 None,
157 );
158 self.client
159 .patch(
160 &url,
161 crate::Message {
162 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
163 content_type: Some("application/json".to_string()),
164 },
165 )
166 .await
167 }
168 /**
169 * Resend Sender Identity Verification.
170 *
171 * This function performs a `POST` to the `/senders/{sender_id}/resend_verification` endpoint.
172 *
173 * **This enpdoint allows you to resend a sender identity verification email.**
174 *
175 * **Parameters:**
176 *
177 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
178 */
179 pub async fn post_senders_sender_resend_verification(
180 &self,
181 sender_id: i64,
182 ) -> ClientResult<crate::Response<crate::types::Help>> {
183 let url = self.client.url(
184 &format!(
185 "/senders/{}/resend_verification",
186 crate::progenitor_support::encode_path(&sender_id.to_string()),
187 ),
188 None,
189 );
190 self.client
191 .post(
192 &url,
193 crate::Message {
194 body: None,
195 content_type: None,
196 },
197 )
198 .await
199 }
200}