fizzy_sdk/generated/services/
users.rs1use crate::client::Scope;
4use crate::error::Error;
5use crate::generated::routes;
6use crate::generated::types::*;
7use crate::pagination::Page;
8
9pub 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 pub fn scope(&self) -> &Scope<'a> {
21 &self.scope
22 }
23
24 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 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 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 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 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 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 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 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 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 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 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 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}