#![warn(missing_docs)]
pub mod api;
mod http;
mod error;
#[derive(Clone)]
pub struct UrlScanClient {
api_key: String,
domain: String,
endpoint: String,
}
impl UrlScanClient {
pub fn new(api_key: &str) -> Self {
UrlScanClient {
api_key: api_key.into(),
domain: "https://urlscan.io/".into(),
endpoint: "api/v1/".into()
}
}
}
#[cfg(test)]
mod tests {
use crate::UrlScanClient;
static API_KEY: &str = "TODO";
static UUID: &str = "20d16cb9-72f1-4139-bd67-130e0bc02da8";
#[test]
fn test_client() {
let client = UrlScanClient::new(API_KEY);
assert_eq!(client.domain, "https://urlscan.io/");
assert_eq!(client.endpoint, "api/v1/");
}
#[test]
fn test_dom() {
let client = UrlScanClient::new(API_KEY);
let response = client.get_dom(UUID);
match response {
Ok(dom) => println!("{}", dom),
_ => println!("We got an error..."),
}
}
#[test]
fn test_result() {
let client = UrlScanClient::new(API_KEY);
let response = client.get_result(UUID);
match response {
Ok(result) => println!("{}", result),
_ => println!("Something went wrong :("),
}
}
#[test]
fn test_screenshot() {
let client: UrlScanClient = UrlScanClient::new(API_KEY);
let response = client.get_screenshot(UUID);
match response {
Ok(result) => {
println!("All good?");
_ = client.save_screenshot(result, "../urlscan.png");
},
_ => println!("Didn't get the screenshot :("),
}
}
}