fizzy_sdk/generated/services/
account.rs1use crate::client::Scope;
4use crate::error::Error;
5use crate::generated::routes;
6use crate::generated::types::*;
7
8pub struct AccountService<'a> {
10 scope: Scope<'a>,
11}
12
13impl<'a> AccountService<'a> {
14 pub(crate) fn new(scope: Scope<'a>) -> Self {
15 Self { scope }
16 }
17
18 pub fn scope(&self) -> &Scope<'a> {
20 &self.scope
21 }
22
23 pub async fn create_export(&self) -> Result<AccountExport, Error> {
27 let operation = self.scope.operation(&routes::CREATE_ACCOUNT_EXPORT, &[])?;
28 self.scope.client().send(operation).await
29 }
30
31 pub async fn get_export(&self, export_id: &str) -> Result<AccountExport, Error> {
35 let mut operation = self
36 .scope
37 .operation(&routes::GET_ACCOUNT_EXPORT, &[&export_id])?;
38 operation.resource_id(export_id);
39 self.scope.client().send(operation).await
40 }
41
42 pub async fn get_join_code(&self) -> Result<JoinCode, Error> {
46 let operation = self.scope.operation(&routes::GET_JOIN_CODE, &[])?;
47 self.scope.client().send(operation).await
48 }
49
50 pub async fn get_settings(&self) -> Result<AccountSettings, Error> {
54 let operation = self.scope.operation(&routes::GET_ACCOUNT_SETTINGS, &[])?;
55 self.scope.client().send(operation).await
56 }
57
58 pub async fn reset_join_code(&self) -> Result<(), Error> {
62 let operation = self.scope.operation(&routes::RESET_JOIN_CODE, &[])?;
63 self.scope.client().send_unit(operation).await
64 }
65
66 pub async fn update_entropy(
70 &self,
71 body: &UpdateAccountEntropyRequestContent,
72 ) -> Result<AccountSettings, Error> {
73 let mut operation = self.scope.operation(&routes::UPDATE_ACCOUNT_ENTROPY, &[])?;
74 operation.json(body)?;
75 self.scope.client().send(operation).await
76 }
77
78 pub async fn update_join_code(&self, body: &UpdateJoinCodeRequestContent) -> Result<(), Error> {
82 let mut operation = self.scope.operation(&routes::UPDATE_JOIN_CODE, &[])?;
83 operation.json(body)?;
84 self.scope.client().send_unit(operation).await
85 }
86
87 pub async fn update_settings(
91 &self,
92 body: &UpdateAccountSettingsRequestContent,
93 ) -> Result<(), Error> {
94 let mut operation = self
95 .scope
96 .operation(&routes::UPDATE_ACCOUNT_SETTINGS, &[])?;
97 operation.json(body)?;
98 self.scope.client().send_unit(operation).await
99 }
100}