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