From 55bb56193efb6983772e5498780737752d83954e Mon Sep 17 00:00:00 2001 From: Ratan Kaliani Date: Fri, 10 Nov 2023 00:02:47 -0800 Subject: [PATCH] feat: add `api_key` to `SuccinctClient` (#287) --- client/src/request.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/request.rs b/client/src/request.rs index 4fb103743..a59d1d5e2 100644 --- a/client/src/request.rs +++ b/client/src/request.rs @@ -31,13 +31,16 @@ pub struct SuccinctClient { client: Client, /// The base url for the Succinct X API. (ex. https://alpha.succinct.xyz/api) base_url: String, + /// API key for the Succinct X API. + api_key: String, } impl SuccinctClient { - pub fn new(base_url: String) -> Self { + pub fn new(base_url: String, api_key: String) -> Self { Self { client: Client::new(), base_url, + api_key, } } @@ -67,6 +70,7 @@ impl SuccinctClient { .client .post(request_url) .header("Content-Type", "application/json") + .bearer_auth(self.api_key.clone()) .body(serialized_data) .send() .await