basecamp-sdk 0.38.0

Official client for Basecamp - https://basecamp.com
Documentation
// Generated by basecamp-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.

//! Account operations.

#![allow(
    clippy::too_many_arguments,
    clippy::wildcard_imports,
    clippy::doc_markdown
)]

use bytes::Bytes;

use crate::client::AccountClient;
use crate::error::Error;
use crate::generated::routes;
#[allow(unused_imports)]
use crate::generated::types::*;

/// `Account` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct AccountService<'a> {
    client: &'a AccountClient,
}

impl<'a> AccountService<'a> {
    pub(crate) fn new(client: &'a AccountClient) -> Self {
        Self { client }
    }

    /// The client this service sends through.
    pub fn client(&self) -> &'a AccountClient {
        self.client
    }

    /// Get the account for the current access token
    ///
    /// `GET /account.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn account(&self) -> Result<GetAccountResponseContent, Error> {
        let operation = self.client.operation(&routes::GET_ACCOUNT, &[]);
        self.client.send(operation).await
    }

    /// Remove the account logo. Only administrators and account owners can use this endpoint.
    ///
    /// `DELETE /account/logo.json` — idempotent; retries up to 2 attempt(s) on 429, 503.
    pub async fn remove_account_logo(&self) -> Result<(), Error> {
        let operation = self.client.operation(&routes::REMOVE_ACCOUNT_LOGO, &[]);
        self.client.send_unit(operation).await
    }

    /// Upload or replace the account logo.
    /// Accepted formats: PNG, JPEG, GIF, WebP, AVIF, HEIC. Maximum 5 MB.
    /// Owners and admins only.
    ///
    /// `PUT /account/logo.json` — idempotent; retries up to 2 attempt(s) on 429, 503.
    pub async fn update_account_logo(
        &self,
        filename: &str,
        content_type: &str,
        body: Bytes,
    ) -> Result<(), Error> {
        let mut operation = self.client.operation(&routes::UPDATE_ACCOUNT_LOGO, &[]);
        operation.multipart("logo", filename, content_type, &body);
        self.client.send_unit(operation).await
    }

    /// Rename the current account. Only account owners can use this endpoint.
    ///
    /// `PUT /account/name.json` — idempotent; retries up to 2 attempt(s) on 429, 503.
    pub async fn update_account_name(
        &self,
        body: &UpdateAccountNameRequestContent,
    ) -> Result<UpdateAccountNameResponseContent, Error> {
        let mut operation = self.client.operation(&routes::UPDATE_ACCOUNT_NAME, &[]);
        operation.json(body)?;
        self.client.send(operation).await
    }
}