use super::{IpReportResponse, VtClient};
use anyhow::{Context, Result};
use reqwest::Client;
use serde_json::from_str;
impl<'a> VtClient<'a> {
pub async fn report_ip_address(self, ip_address: &str) -> Result<IpReportResponse> {
let url = format!("{}/ip_addresses/{ip_address}", self.endpoint);
let resp = Client::new()
.get(&url)
.header("x-apikey", self.api_key)
.send()
.await
.context("Error! Probably maximum request limit achieved!")?;
let text: &str = &resp.text().await?;
Ok(from_str(text)?)
}
}