termii_rust/async_impl/rest/insights/
balance.rs1use std::{collections::HashMap, sync::Arc};
4
5use crate::{
6 async_impl::http::client,
7 common::{errors, insights::balance::BalanceItem},
8};
9
10#[derive(Debug)]
11#[allow(dead_code)]
12pub struct Balance<'a> {
13 api_key: &'a str,
14 client: Arc<client::HttpClient>,
15}
16
17impl<'a> Balance<'a> {
18 pub(crate) fn new(api_key: &'a str, client: Arc<client::HttpClient>) -> Balance<'a> {
19 Balance { api_key, client }
20 }
21
22 pub async fn get(&self) -> Result<BalanceItem, errors::HttpError> {
39 let mut params = HashMap::new();
40 params.insert("api_key", self.api_key);
41
42 let response = self.client.get("get-balance", Some(params), None).await?;
43
44 let balance_item = response_or_error_text_async!(response, BalanceItem);
45
46 Ok(balance_item)
47 }
48}