urlscan/api/submission/
mod.rs1use crate::{UrlScanClient, error::UrlScanError, http::post};
2
3pub mod model;
5pub use model::Submission;
6use reqwest::header::{HeaderMap, HeaderValue};
7
8impl UrlScanClient {
9 pub fn scan_url(&self, url: &str, visibility: &str, _tags: Vec<String>) -> Result<Submission, UrlScanError> {
13 let request_url = format!("{}{}scan/", &self.domain, &self.endpoint);
14
15 let mut headers = HeaderMap::new();
16 headers.insert("Content-Type", HeaderValue::from_str("application/json").unwrap());
17 headers.insert("API-Key", HeaderValue::from_str(&self.api_key).unwrap());
18
19 let body = format!("{{\"url\": \"{}\", \"visibility\": \"{}\", \"tags\": [] }}", url, visibility);
20
21 post::<Submission>(&request_url, headers, body)
22 }
23
24 }