fizzy-sdk 0.2.4

Official Fizzy API client, generated from the Smithy model in spec/
Documentation
// 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::*;

/// The `Account` operations.
pub struct AccountService<'a> {
    scope: Scope<'a>,
}

impl<'a> AccountService<'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
    }

    /// `CreateAccountExport` — `POST /{accountId}/account/exports.json`.
    ///
    /// Sent once and never resent.
    pub async fn create_export(&self) -> Result<AccountExport, Error> {
        let operation = self.scope.operation(&routes::CREATE_ACCOUNT_EXPORT, &[])?;
        self.scope.client().send(operation).await
    }

    /// `GetAccountExport` — `GET /{accountId}/account/exports/{exportId}`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn get_export(&self, export_id: &str) -> Result<AccountExport, Error> {
        let mut operation = self
            .scope
            .operation(&routes::GET_ACCOUNT_EXPORT, &[&export_id])?;
        operation.resource_id(export_id);
        self.scope.client().send(operation).await
    }

    /// `GetJoinCode` — `GET /{accountId}/account/join_code.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn get_join_code(&self) -> Result<JoinCode, Error> {
        let operation = self.scope.operation(&routes::GET_JOIN_CODE, &[])?;
        self.scope.client().send(operation).await
    }

    /// `GetAccountSettings` — `GET /{accountId}/account/settings.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn get_settings(&self) -> Result<AccountSettings, Error> {
        let operation = self.scope.operation(&routes::GET_ACCOUNT_SETTINGS, &[])?;
        self.scope.client().send(operation).await
    }

    /// `ResetJoinCode` — `DELETE /{accountId}/account/join_code.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn reset_join_code(&self) -> Result<(), Error> {
        let operation = self.scope.operation(&routes::RESET_JOIN_CODE, &[])?;
        self.scope.client().send_unit(operation).await
    }

    /// `UpdateAccountEntropy` — `PUT /{accountId}/account/entropy.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn update_entropy(
        &self,
        body: &UpdateAccountEntropyRequestContent,
    ) -> Result<AccountSettings, Error> {
        let mut operation = self.scope.operation(&routes::UPDATE_ACCOUNT_ENTROPY, &[])?;
        operation.json(body)?;
        self.scope.client().send(operation).await
    }

    /// `UpdateJoinCode` — `PATCH /{accountId}/account/join_code.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn update_join_code(&self, body: &UpdateJoinCodeRequestContent) -> Result<(), Error> {
        let mut operation = self.scope.operation(&routes::UPDATE_JOIN_CODE, &[])?;
        operation.json(body)?;
        self.scope.client().send_unit(operation).await
    }

    /// `UpdateAccountSettings` — `PATCH /{accountId}/account/settings.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn update_settings(
        &self,
        body: &UpdateAccountSettingsRequestContent,
    ) -> Result<(), Error> {
        let mut operation = self
            .scope
            .operation(&routes::UPDATE_ACCOUNT_SETTINGS, &[])?;
        operation.json(body)?;
        self.scope.client().send_unit(operation).await
    }
}