use crate::{Client, Error, BASE_URL};
use adiscord_types::api::channel::Channel;
use reqwest::StatusCode;
impl Client {
pub async fn get(&self, index: &str) -> Result<Channel, Error> {
let response = self
.client
.get(format!("{}/channels/{index}", BASE_URL))
.send()
.await
.unwrap();
let status = response.status();
match status {
StatusCode::OK => {
let body: Channel = response.json().await.unwrap();
Ok(body)
}
_ => {
let body: Error = response.json().await.unwrap();
Err(body)
}
}
}
}