Added fetch data endpoint

This commit is contained in:
perp 2024-05-25 00:25:57 +01:00
parent 72e6533857
commit 572d712329
5 changed files with 26 additions and 6 deletions

4
Cargo.lock generated
View File

@ -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",

View File

@ -1,6 +1,6 @@
[package]
name = "construct-models"
version = "1.2.0"
version = "1.3.0"
edition = "2021"
authors.workspace = true
license.workspace = true

View File

@ -1,6 +1,6 @@
[package]
name = "construct"
version = "1.2.0"
version = "1.3.0"
edition = "2021"
authors.workspace = true
license.workspace = true

19
construct/src/data/mod.rs Normal file
View File

@ -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<Data> {
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?)
}
}

View File

@ -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};