Skip to main content

fizzy_sdk/generated/services/
users.rs

1// Generated by fizzy-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
2
3use crate::client::Scope;
4use crate::error::Error;
5use crate::generated::routes;
6use crate::generated::types::*;
7use crate::pagination::Page;
8
9/// The `Users` operations.
10pub struct UsersService<'a> {
11    scope: Scope<'a>,
12}
13
14impl<'a> UsersService<'a> {
15    pub(crate) fn new(scope: Scope<'a>) -> Self {
16        Self { scope }
17    }
18
19    /// The client and account these operations send through.
20    pub fn scope(&self) -> &Scope<'a> {
21        &self.scope
22    }
23
24    /// `ConfirmEmailAddressChange` — `POST /{accountId}/users/{userId}/email_addresses/{emailAddressToken}/confirmation.json`.
25    ///
26    /// Sent once and never resent.
27    pub async fn confirm_email_address_change(
28        &self,
29        user_id: &str,
30        email_address_token: &str,
31    ) -> Result<(), Error> {
32        let mut operation = self.scope.operation(
33            &routes::CONFIRM_EMAIL_ADDRESS_CHANGE,
34            &[&user_id, &email_address_token],
35        )?;
36        operation.resource_id(user_id);
37        self.scope.client().send_unit(operation).await
38    }
39
40    /// `CreatePushSubscription` — `POST /{accountId}/users/{userId}/push_subscriptions.json`.
41    ///
42    /// Sent once and never resent.
43    pub async fn create_push_subscription(
44        &self,
45        user_id: &str,
46        body: &CreatePushSubscriptionRequestContent,
47    ) -> Result<(), Error> {
48        let mut operation = self
49            .scope
50            .operation(&routes::CREATE_PUSH_SUBSCRIPTION, &[&user_id])?;
51        operation.resource_id(user_id);
52        operation.json(body)?;
53        self.scope.client().send_unit(operation).await
54    }
55
56    /// `CreateUserDataExport` — `POST /{accountId}/users/{userId}/data_exports.json`.
57    ///
58    /// Sent once and never resent.
59    pub async fn create_user_data_export(&self, user_id: &str) -> Result<DataExport, Error> {
60        let mut operation = self
61            .scope
62            .operation(&routes::CREATE_USER_DATA_EXPORT, &[&user_id])?;
63        operation.resource_id(user_id);
64        self.scope.client().send(operation).await
65    }
66
67    /// `DeactivateUser` — `DELETE /{accountId}/users/{userId}`.
68    ///
69    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
70    pub async fn deactivate(&self, user_id: &str) -> Result<(), Error> {
71        let mut operation = self
72            .scope
73            .operation(&routes::DEACTIVATE_USER, &[&user_id])?;
74        operation.resource_id(user_id);
75        self.scope.client().send_unit(operation).await
76    }
77
78    /// `DeleteUserAvatar` — `DELETE /{accountId}/users/{userId}/avatar`.
79    ///
80    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
81    pub async fn delete_avatar(&self, user_id: &str) -> Result<(), Error> {
82        let mut operation = self
83            .scope
84            .operation(&routes::DELETE_USER_AVATAR, &[&user_id])?;
85        operation.resource_id(user_id);
86        self.scope.client().send_unit(operation).await
87    }
88
89    /// `DeletePushSubscription` — `DELETE /{accountId}/users/{userId}/push_subscriptions/{pushSubscriptionId}`.
90    ///
91    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
92    pub async fn delete_push_subscription(
93        &self,
94        user_id: &str,
95        push_subscription_id: &str,
96    ) -> Result<(), Error> {
97        let mut operation = self.scope.operation(
98            &routes::DELETE_PUSH_SUBSCRIPTION,
99            &[&user_id, &push_subscription_id],
100        )?;
101        operation.resource_id(push_subscription_id);
102        self.scope.client().send_unit(operation).await
103    }
104
105    /// `GetUser` — `GET /{accountId}/users/{userId}`.
106    ///
107    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
108    pub async fn get(&self, user_id: &str) -> Result<User, Error> {
109        let mut operation = self.scope.operation(&routes::GET_USER, &[&user_id])?;
110        operation.resource_id(user_id);
111        self.scope.client().send(operation).await
112    }
113
114    /// `GetUserDataExport` — `GET /{accountId}/users/{userId}/data_exports/{exportId}`.
115    ///
116    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
117    pub async fn get_user_data_export(
118        &self,
119        user_id: &str,
120        export_id: &str,
121    ) -> Result<DataExport, Error> {
122        let mut operation = self
123            .scope
124            .operation(&routes::GET_USER_DATA_EXPORT, &[&user_id, &export_id])?;
125        operation.resource_id(export_id);
126        self.scope.client().send(operation).await
127    }
128
129    /// `ListUsers` — `GET /{accountId}/users.json`.
130    ///
131    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
132    ///
133    /// Paginated: the answer is a page with `page` as its cursor, and the next one is read with `next_page`.
134    pub async fn list(&self) -> Result<Page<Vec<User>>, Error> {
135        let operation = self.scope.operation(&routes::LIST_USERS, &[])?;
136        self.scope.client().send_page(operation).await
137    }
138
139    /// `RequestEmailAddressChange` — `POST /{accountId}/users/{userId}/email_addresses.json`.
140    ///
141    /// Sent once and never resent.
142    pub async fn request_email_address_change(
143        &self,
144        user_id: &str,
145        body: &RequestEmailAddressChangeRequestContent,
146    ) -> Result<(), Error> {
147        let mut operation = self
148            .scope
149            .operation(&routes::REQUEST_EMAIL_ADDRESS_CHANGE, &[&user_id])?;
150        operation.resource_id(user_id);
151        operation.json(body)?;
152        self.scope.client().send_unit(operation).await
153    }
154
155    /// `UpdateUser` — `PATCH /{accountId}/users/{userId}`.
156    ///
157    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
158    pub async fn update(
159        &self,
160        user_id: &str,
161        body: &UpdateUserRequestContent,
162    ) -> Result<User, Error> {
163        let mut operation = self.scope.operation(&routes::UPDATE_USER, &[&user_id])?;
164        operation.resource_id(user_id);
165        operation.json(body)?;
166        self.scope.client().send(operation).await
167    }
168
169    /// `UpdateUserRole` — `PATCH /{accountId}/users/{userId}/role.json`.
170    ///
171    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
172    pub async fn update_role(
173        &self,
174        user_id: &str,
175        body: &UpdateUserRoleRequestContent,
176    ) -> Result<(), Error> {
177        let mut operation = self
178            .scope
179            .operation(&routes::UPDATE_USER_ROLE, &[&user_id])?;
180        operation.resource_id(user_id);
181        operation.json(body)?;
182        self.scope.client().send_unit(operation).await
183    }
184}