use reqwest::{
Client,
header::{HeaderMap, HeaderValue},
};
#[derive(Debug)]
pub struct JupiterClient {
pub client: Client,
pub base_url: String,
}
impl JupiterClient {
pub fn new(base_url: &str) -> Self {
let mut headers = HeaderMap::new();
headers.insert("Accept", "application/json".parse().unwrap());
headers.insert("Content-Type", "application/json".parse().unwrap());
let client = Client::builder()
.default_headers(headers)
.build()
.expect("Failed to build client with API key");
JupiterClient {
client,
base_url: base_url.to_string(),
}
}
pub fn with_api_key(self, api_key: &str) -> Self {
let mut headers = HeaderMap::new();
headers.insert("x-api-key", HeaderValue::from_str(api_key).unwrap());
headers.insert("Accept", "application/json".parse().unwrap());
headers.insert("Content-Type", "application/json".parse().unwrap());
let client = Client::builder()
.default_headers(headers)
.build()
.expect("Failed to build client with API key");
JupiterClient {
client,
base_url: self.base_url,
}
}
}
mod recurring_api;
mod swap_api;
mod token_api;
mod trigger_api;
mod ultra_api;