From 572d712329cd8d06baef694f1caa8bcc03b02546 Mon Sep 17 00:00:00 2001 From: perp Date: Sat, 25 May 2024 00:25:57 +0100 Subject: [PATCH] Added fetch data endpoint --- Cargo.lock | 4 ++-- construct-models/Cargo.toml | 2 +- construct/Cargo.toml | 2 +- construct/src/data/mod.rs | 19 +++++++++++++++++++ construct/src/lib.rs | 5 +++-- 5 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 construct/src/data/mod.rs diff --git a/Cargo.lock b/Cargo.lock index a3e5590..32fa18a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -99,7 +99,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "construct" -version = "1.2.0" +version = "1.3.0" dependencies = [ "async-trait", "construct-models", @@ -109,7 +109,7 @@ dependencies = [ [[package]] name = "construct-models" -version = "1.2.0" +version = "1.3.0" dependencies = [ "reqwest", "serde", diff --git a/construct-models/Cargo.toml b/construct-models/Cargo.toml index 3ecabff..30da47e 100644 --- a/construct-models/Cargo.toml +++ b/construct-models/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "construct-models" -version = "1.2.0" +version = "1.3.0" edition = "2021" authors.workspace = true license.workspace = true diff --git a/construct/Cargo.toml b/construct/Cargo.toml index e98eeaa..24cf0a4 100644 --- a/construct/Cargo.toml +++ b/construct/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "construct" -version = "1.2.0" +version = "1.3.0" edition = "2021" authors.workspace = true license.workspace = true diff --git a/construct/src/data/mod.rs b/construct/src/data/mod.rs new file mode 100644 index 0000000..f59089a --- /dev/null +++ b/construct/src/data/mod.rs @@ -0,0 +1,19 @@ +use construct_models::data::Data; + +use crate::prelude::*; + +impl Construct { + /// Returns data on the types of scans (series) Censys performs + pub async fn fetch_data(&self) -> Result { + Ok(self + .client + .get(format!("{}/v1/data", self.base_url)) + .basic_auth(&self.api_id, Some(&self.api_secret)) + .send() + .await? + .process_error() + .await? + .json() + .await?) + } +} diff --git a/construct/src/lib.rs b/construct/src/lib.rs index 49f47fa..ea4e3b3 100644 --- a/construct/src/lib.rs +++ b/construct/src/lib.rs @@ -1,8 +1,9 @@ use async_trait::async_trait; use construct_models::Error; -pub mod account; -pub mod metadata; +mod account; +mod data; +mod metadata; pub(crate) mod prelude { pub(crate) use crate::{Construct, ResponseExt, Result};