sendgrid_api/
users_api.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct UsersApi {
5    pub client: Client,
6}
7
8impl UsersApi {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        UsersApi { client }
12    }
13
14    /**
15     * Get a user's profile.
16     *
17     * This function performs a `GET` to the `/user/profile` endpoint.
18     *
19     * **Parameters:**
20     *
21     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
22     */
23    pub async fn get_user_profile(
24        &self,
25    ) -> ClientResult<crate::Response<crate::types::GetUserProfileResponse>> {
26        let url = self.client.url("/user/profile", None);
27        self.client
28            .get(
29                &url,
30                crate::Message {
31                    body: None,
32                    content_type: None,
33                },
34            )
35            .await
36    }
37    /**
38     * Update a user's profile.
39     *
40     * This function performs a `PATCH` to the `/user/profile` endpoint.
41     *
42     * **This endpoint allows you to update your current profile details.**
43     *
44     * Any one or more of the parameters can be updated via the PATCH `/user/profile` endpoint. You must include at least one when you PATCH.
45     *
46     * **Parameters:**
47     *
48     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
49     */
50    pub async fn patch_user_profile(
51        &self,
52        body: &crate::types::UserProfile,
53    ) -> ClientResult<crate::Response<crate::types::UserProfile>> {
54        let url = self.client.url("/user/profile", None);
55        self.client
56            .patch(
57                &url,
58                crate::Message {
59                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
60                    content_type: Some("application/json".to_string()),
61                },
62            )
63            .await
64    }
65    /**
66     * Get a user's account information.
67     *
68     * This function performs a `GET` to the `/user/account` endpoint.
69     *
70     * **This endpoint allows you to retrieve your user account details.**
71     *
72     * Your user's account information includes the user's account type and reputation.
73     *
74     * **Parameters:**
75     *
76     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
77     */
78    pub async fn get_user_account(
79        &self,
80    ) -> ClientResult<crate::Response<crate::types::GetUserAccountResponse>> {
81        let url = self.client.url("/user/account", None);
82        self.client
83            .get(
84                &url,
85                crate::Message {
86                    body: None,
87                    content_type: None,
88                },
89            )
90            .await
91    }
92    /**
93     * Retrieve your account email address.
94     *
95     * This function performs a `GET` to the `/user/email` endpoint.
96     *
97     * **This endpoint allows you to retrieve the email address currently on file for your account.**
98     *
99     * **Parameters:**
100     *
101     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
102     */
103    pub async fn get_user_email(
104        &self,
105    ) -> ClientResult<crate::Response<crate::types::GetUserEmailResponse>> {
106        let url = self.client.url("/user/email", None);
107        self.client
108            .get(
109                &url,
110                crate::Message {
111                    body: None,
112                    content_type: None,
113                },
114            )
115            .await
116    }
117    /**
118     * Update your account email address.
119     *
120     * This function performs a `PUT` to the `/user/email` endpoint.
121     *
122     * **This endpoint allows you to update the email address currently on file for your account.**
123     *
124     * **Parameters:**
125     *
126     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
127     */
128    pub async fn put_user_email(
129        &self,
130        body: &crate::types::PutUserEmailRequest,
131    ) -> ClientResult<crate::Response<crate::types::GetUserEmailResponse>> {
132        let url = self.client.url("/user/email", None);
133        self.client
134            .put(
135                &url,
136                crate::Message {
137                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
138                    content_type: Some("application/json".to_string()),
139                },
140            )
141            .await
142    }
143    /**
144     * Retrieve your username.
145     *
146     * This function performs a `GET` to the `/user/username` endpoint.
147     *
148     * **This endpoint allows you to retrieve your current account username.**
149     *
150     * **Parameters:**
151     *
152     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
153     */
154    pub async fn get_user_username(&self) -> ClientResult<crate::Response<crate::types::Users>> {
155        let url = self.client.url("/user/username", None);
156        self.client
157            .get(
158                &url,
159                crate::Message {
160                    body: None,
161                    content_type: None,
162                },
163            )
164            .await
165    }
166    /**
167     * Update your username.
168     *
169     * This function performs a `PUT` to the `/user/username` endpoint.
170     *
171     * **This endpoint allows you to update the username for your account.**
172     *
173     * **Parameters:**
174     *
175     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
176     */
177    pub async fn put_user_username(
178        &self,
179        body: &crate::types::PutUserUsernameRequest,
180    ) -> ClientResult<crate::Response<crate::types::PutUserUsernameResponse>> {
181        let url = self.client.url("/user/username", None);
182        self.client
183            .put(
184                &url,
185                crate::Message {
186                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
187                    content_type: Some("application/json".to_string()),
188                },
189            )
190            .await
191    }
192    /**
193     * Retrieve your credit balance.
194     *
195     * This function performs a `GET` to the `/user/credits` endpoint.
196     *
197     * **This endpoint allows you to retrieve the current credit balance for your account.**
198     *
199     * Each account has a credit balance, which is a base number of emails it can send before receiving per-email charges. For more information about credits and billing, see [Billing and Plan details information](https://sendgrid.com/docs/ui/account-and-settings/billing/).
200     *
201     * **Parameters:**
202     *
203     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
204     */
205    pub async fn get_user_credits(
206        &self,
207    ) -> ClientResult<crate::Response<crate::types::GetUserCreditsResponse>> {
208        let url = self.client.url("/user/credits", None);
209        self.client
210            .get(
211                &url,
212                crate::Message {
213                    body: None,
214                    content_type: None,
215                },
216            )
217            .await
218    }
219    /**
220     * Update your password.
221     *
222     * This function performs a `PUT` to the `/user/password` endpoint.
223     *
224     * **This endpoint allows you to update your password.**
225     *
226     * **Parameters:**
227     *
228     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
229     */
230    pub async fn put_user_password(
231        &self,
232        body: &crate::types::PutUserPasswordRequest,
233    ) -> ClientResult<crate::Response<crate::types::Help>> {
234        let url = self.client.url("/user/password", None);
235        self.client
236            .put(
237                &url,
238                crate::Message {
239                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
240                    content_type: Some("application/json".to_string()),
241                },
242            )
243            .await
244    }
245}