Skip to main content

fizzy_sdk/generated/services/
account.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::*;
7
8/// The `Account` operations.
9pub 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    /// The client and account these operations send through.
19    pub fn scope(&self) -> &Scope<'a> {
20        &self.scope
21    }
22
23    /// `CreateAccountExport` — `POST /{accountId}/account/exports.json`.
24    ///
25    /// Sent once and never resent.
26    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    /// `GetAccountExport` — `GET /{accountId}/account/exports/{exportId}`.
32    ///
33    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
34    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    /// `GetJoinCode` — `GET /{accountId}/account/join_code.json`.
43    ///
44    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
45    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    /// `GetAccountSettings` — `GET /{accountId}/account/settings.json`.
51    ///
52    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
53    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    /// `ResetJoinCode` — `DELETE /{accountId}/account/join_code.json`.
59    ///
60    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
61    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    /// `UpdateAccountEntropy` — `PUT /{accountId}/account/entropy.json`.
67    ///
68    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
69    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    /// `UpdateJoinCode` — `PATCH /{accountId}/account/join_code.json`.
79    ///
80    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
81    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    /// `UpdateAccountSettings` — `PATCH /{accountId}/account/settings.json`.
88    ///
89    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
90    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}