1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use crate::client::Client;
use crate::error::Error;

use super::Account;

impl Client {
    pub async fn get_acccount(&self, account_id: &str) -> Result<Account, Error> {
        let res = self.list_accounts().await?;
        let account = res
            .0
            .into_iter()
            .find(|account| return account.id == account_id);
        match account {
            Some(account) => {
                return Ok(account);
            }
            None => {
                return Err(Error::AccountNotFound(String::from(
                    "Account with id not found",
                )))
            }
        }
    }
}