avanza_rs/account/
get.rs

1use crate::client::Client;
2use crate::error::Error;
3
4use super::Account;
5
6impl Client {
7    pub async fn get_acccount(&self, account_id: &str) -> Result<Account, Error> {
8        let res = self.list_accounts().await?;
9        let account = res
10            .0
11            .into_iter()
12            .find(|account| return account.id == account_id);
13        match account {
14            Some(account) => {
15                return Ok(account);
16            }
17            None => {
18                return Err(Error::AccountNotFound(String::from(
19                    "Account with id not found",
20                )))
21            }
22        }
23    }
24}