use reqwest::Client;
pub static API_BASE_URL: &str = "https://api.revolt.chat";
#[derive(Clone)]
pub struct Http;
impl Http
{
pub async fn post(destination: &str, token: &str, body: serde_json::Value) -> Result<(), reqwest::Error> {
let client = Client::new();
let res = client.post(format!("{}/{}", API_BASE_URL, destination))
.header("x-bot-token", format!("{token}", token = token))
.header("content-type", "application/json")
.body(body.to_string())
.send()
.await;
res.map(|_| ())
}
pub async fn get(destination: &str, token: &str) -> Result<(), reqwest::Error> {
let client = Client::new();
let res = client.get(format!("{}/{}", API_BASE_URL, destination))
.header("x-bot-token", format!("{token}", token = token))
.send()
.await;
res.map(|_| ())
}
pub async fn delete(destination: &str, token: &str, body: serde_json::Value) -> Result<(), reqwest::Error> {
let client = Client::new();
let res = client.delete(format!("{}/{}", API_BASE_URL, destination))
.header("x-bot-token", format!("{token}", token = token))
.header("content-type", "application/json")
.body(body.to_string())
.send()
.await;
res.map(|_| ())
}
}