termii_rust/async_impl/rest/insights/
status.rs1use std::{collections::HashMap, sync::Arc};
4
5use crate::{
6 async_impl::http::client,
7 common::{errors, insights::status::StatusItem},
8};
9
10#[derive(Debug)]
11pub struct Status<'a> {
12 api_key: &'a str,
13 client: Arc<client::HttpClient>,
14}
15
16impl<'a> Status<'a> {
17 pub(crate) fn new(api_key: &'a str, client: Arc<client::HttpClient>) -> Status<'a> {
18 Status { api_key, client }
19 }
20
21 pub async fn get(
38 &self,
39 phone_number: &str,
40 country_code: &str,
41 ) -> Result<StatusItem, errors::HttpError> {
42 let mut params = HashMap::new();
43 params.insert("api_key", self.api_key);
44 params.insert("phone_number", phone_number);
45 params.insert("country_code", country_code);
46
47 let response = self
48 .client
49 .get("insight/number/query", Some(params), None)
50 .await?;
51
52 let status_response = response_or_error_text_async!(response, StatusItem);
53
54 Ok(status_response)
55 }
56}