sendgrid_api/suppressions_unsubscribe_groups.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct SuppressionsUnsubscribeGroups {
5 pub client: Client,
6}
7
8impl SuppressionsUnsubscribeGroups {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 SuppressionsUnsubscribeGroups { client }
12 }
13
14 /**
15 * Retrieve all suppression groups associated with the user.
16 *
17 * This function performs a `GET` to the `/asm/groups` endpoint.
18 *
19 * **This endpoint allows you to retrieve a list of all suppression groups created by this user.**
20 *
21 * This endpoint can also return information for multiple group IDs that you include in your request. To add a group ID to your request, simply append `?id=123456&id=123456`, with the appropriate group IDs.
22 *
23 * **Parameters:**
24 *
25 * * `id: i64`
26 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
27 */
28 pub async fn get_asm_groups(
29 &self,
30 id: i64,
31 ) -> ClientResult<crate::Response<Vec<crate::types::SuppressionGroup>>> {
32 let mut query_args: Vec<(String, String)> = Default::default();
33 if id > 0 {
34 query_args.push(("id".to_string(), id.to_string()));
35 }
36 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
37 let url = self.client.url(&format!("/asm/groups?{}", query_), None);
38 self.client
39 .get(
40 &url,
41 crate::Message {
42 body: None,
43 content_type: None,
44 },
45 )
46 .await
47 }
48 /**
49 * Retrieve all suppression groups associated with the user.
50 *
51 * This function performs a `GET` to the `/asm/groups` endpoint.
52 *
53 * As opposed to `get_asm_groups`, this function returns all the pages of the request at once.
54 *
55 * **This endpoint allows you to retrieve a list of all suppression groups created by this user.**
56 *
57 * This endpoint can also return information for multiple group IDs that you include in your request. To add a group ID to your request, simply append `?id=123456&id=123456`, with the appropriate group IDs.
58 */
59 pub async fn get_all_asm_groups(
60 &self,
61 id: i64,
62 ) -> ClientResult<crate::Response<Vec<crate::types::SuppressionGroup>>> {
63 let mut query_args: Vec<(String, String)> = Default::default();
64 if id > 0 {
65 query_args.push(("id".to_string(), id.to_string()));
66 }
67 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
68 let url = self.client.url(&format!("/asm/groups?{}", query_), None);
69 self.client
70 .get_all_pages(
71 &url,
72 crate::Message {
73 body: None,
74 content_type: None,
75 },
76 )
77 .await
78 }
79 /**
80 * Create a new suppression group.
81 *
82 * This function performs a `POST` to the `/asm/groups` endpoint.
83 *
84 * **This endpoint allows you to create a new suppression group.**
85 *
86 * To add an email address to the suppression group, [create a Suppression](https://sendgrid.api-docs.io/v3.0/suppressions-suppressions/add-suppressions-to-a-suppression-group).
87 *
88 * **Parameters:**
89 *
90 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
91 */
92 pub async fn post_asm_group(
93 &self,
94 body: &crate::types::SuppressionGroupRequestBase,
95 ) -> ClientResult<crate::Response<crate::types::PostAsmGroupsResponse>> {
96 let url = self.client.url("/asm/groups", None);
97 self.client
98 .post(
99 &url,
100 crate::Message {
101 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
102 content_type: Some("application/json".to_string()),
103 },
104 )
105 .await
106 }
107 /**
108 * Get information on a single suppression group.
109 *
110 * This function performs a `GET` to the `/asm/groups/{group_id}` endpoint.
111 *
112 * **This endpoint allows you to retrieve a single suppression group.**
113 *
114 * **Parameters:**
115 *
116 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
117 */
118 pub async fn get_asm_groups_group(
119 &self,
120 group_id: &str,
121 ) -> ClientResult<crate::Response<crate::types::GetAsmGroupsGroupResponseAllOf>> {
122 let url = self.client.url(
123 &format!(
124 "/asm/groups/{}",
125 crate::progenitor_support::encode_path(group_id),
126 ),
127 None,
128 );
129 self.client
130 .get(
131 &url,
132 crate::Message {
133 body: None,
134 content_type: None,
135 },
136 )
137 .await
138 }
139 /**
140 * Delete a Suppression Group.
141 *
142 * This function performs a `DELETE` to the `/asm/groups/{group_id}` endpoint.
143 *
144 * **This endpoint allows you to delete a suppression group.**
145 *
146 * If a recipient uses the "one-click unsubscribe" option on an email associated with a deleted group, that recipient will be added to the global suppression list.
147 *
148 * Deleting a suppression group will remove the suppression, meaning email will once again be sent to the previously suppressed addresses. This should be avoided unless a recipient indicates they wish to receive email from you again. You can use our [bypass filters](https://sendgrid.com/docs/ui/sending-email/index-suppressions/#bypass-suppressions) to deliver messages to otherwise suppressed addresses when exceptions are required.
149 *
150 * **Parameters:**
151 *
152 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
153 */
154 pub async fn delete_asm_groups_group(
155 &self,
156 group_id: &str,
157 ) -> ClientResult<crate::Response<crate::types::Help>> {
158 let url = self.client.url(
159 &format!(
160 "/asm/groups/{}",
161 crate::progenitor_support::encode_path(group_id),
162 ),
163 None,
164 );
165 self.client
166 .delete(
167 &url,
168 crate::Message {
169 body: None,
170 content_type: None,
171 },
172 )
173 .await
174 }
175 /**
176 * Update a suppression group.
177 *
178 * This function performs a `PATCH` to the `/asm/groups/{group_id}` endpoint.
179 *
180 * **This endpoint allows you to update or change a suppression group.**
181 *
182 * **Parameters:**
183 *
184 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
185 */
186 pub async fn patch_asm_groups_group(
187 &self,
188 group_id: &str,
189 body: &crate::types::SuppressionGroupRequestBase,
190 ) -> ClientResult<crate::Response<crate::types::SuppressionGroup>> {
191 let url = self.client.url(
192 &format!(
193 "/asm/groups/{}",
194 crate::progenitor_support::encode_path(group_id),
195 ),
196 None,
197 );
198 self.client
199 .patch(
200 &url,
201 crate::Message {
202 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
203 content_type: Some("application/json".to_string()),
204 },
205 )
206 .await
207 }
208}