diff --git a/construct-http/src/account/mod.rs b/construct-http/src/account/mod.rs index 97f5dbf..d7e0e9e 100644 --- a/construct-http/src/account/mod.rs +++ b/construct-http/src/account/mod.rs @@ -5,13 +5,19 @@ use crate::prelude::*; /// Account endpoint group #[derive(Debug)] pub struct AccountGroup { - pub client: reqwest::Client, + client: reqwest::Client, + api_id: String, + api_secret: String, } impl AccountGroup { /// Return a new [`AccountGroup`] - pub fn new(client: reqwest::Client) -> Self { - Self { client } + pub fn new(client: reqwest::Client, api_id: &str, api_secret: &str) -> Self { + Self { + client, + api_id: api_id.to_string(), + api_secret: api_secret.to_string(), + } } /// Return information about your account @@ -19,6 +25,7 @@ impl AccountGroup { Ok(self .client .get(format!("{}/v1/account", BASE_URL)) + .basic_auth(&self.api_id, Some(&self.api_secret)) .send() .await? .process_error() diff --git a/construct/src/lib.rs b/construct/src/lib.rs index 11ce408..bd25f29 100644 --- a/construct/src/lib.rs +++ b/construct/src/lib.rs @@ -8,7 +8,7 @@ pub struct Construct { impl Construct { /// Return a new [`Construct`] - pub fn new() -> Self { + pub fn new(api_id: &str, api_secret: &str) -> Self { // Build HTTP client let client = reqwest::ClientBuilder::new() .user_agent(concat!("Construct", "/", env!("CARGO_PKG_VERSION"))) @@ -16,7 +16,7 @@ impl Construct { .unwrap(); Self { - account: AccountGroup::new(client), + account: AccountGroup::new(client, api_id, api_secret), } } } diff --git a/examples/basic.rs b/examples/basic.rs index cff31ee..54624d9 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -3,7 +3,7 @@ use construct::Construct; #[tokio::main] async fn main() { // Create new Construct - let construct = Construct::new(); + let construct = Construct::new("id", "secret"); // Fetch account information let account = construct.account.fetch().await.unwrap();