chore: please clippy and rustfmt
parent
3fbec90bb4
commit
a74cf76b2b
|
@ -23,10 +23,18 @@ impl AffluencesClient {
|
||||||
pub async fn search(&self, query: String) -> reqwest::Result<SiteSearchResponse> {
|
pub async fn search(&self, query: String) -> reqwest::Result<SiteSearchResponse> {
|
||||||
let url = "https://api.affluences.com/app/v3/sites";
|
let url = "https://api.affluences.com/app/v3/sites";
|
||||||
let body = SiteSearch {
|
let body = SiteSearch {
|
||||||
search_query: query
|
search_query: query,
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(self.client.post(url).json(&body).send().await?.json::<Data<SiteSearchResponse>>().await?.data)
|
Ok(self
|
||||||
|
.client
|
||||||
|
.post(url)
|
||||||
|
.json(&body)
|
||||||
|
.send()
|
||||||
|
.await?
|
||||||
|
.json::<Data<SiteSearchResponse>>()
|
||||||
|
.await?
|
||||||
|
.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn available(
|
pub async fn available(
|
||||||
|
@ -81,3 +89,9 @@ impl AffluencesClient {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for AffluencesClient {
|
||||||
|
fn default() -> Self {
|
||||||
|
AffluencesClient::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use chrono::NaiveTime;
|
use chrono::NaiveTime;
|
||||||
use serde::{self, Deserialize, Deserializer, Serializer};
|
use serde::{self, Deserialize, Deserializer, Serializer};
|
||||||
|
|
||||||
const FORMAT: &'static str = "%H:%M";
|
const FORMAT: &str = "%H:%M";
|
||||||
|
|
||||||
pub fn serialize<S>(time: &NaiveTime, serializer: S) -> Result<S::Ok, S::Error>
|
pub fn serialize<S>(time: &NaiveTime, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct Data<T> {
|
pub struct Data<T> {
|
||||||
|
@ -107,12 +107,12 @@ pub struct SiteData {
|
||||||
|
|
||||||
#[derive(Serialize, Debug)]
|
#[derive(Serialize, Debug)]
|
||||||
pub struct SiteSearch {
|
pub struct SiteSearch {
|
||||||
pub search_query: String
|
pub search_query: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct SiteSearchResponse {
|
pub struct SiteSearchResponse {
|
||||||
pub page: u32,
|
pub page: u32,
|
||||||
pub max_size: u32,
|
pub max_size: u32,
|
||||||
pub results: Vec<SiteData>
|
pub results: Vec<SiteData>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use chrono::{Duration, NaiveDate};
|
||||||
use uuid::{uuid, Uuid};
|
use uuid::{uuid, Uuid};
|
||||||
|
|
||||||
const STERRE_BIB_ID: Uuid = uuid!("4737e57a-ee05-4f7b-901a-7bb541eeb297");
|
const STERRE_BIB_ID: Uuid = uuid!("4737e57a-ee05-4f7b-901a-7bb541eeb297");
|
||||||
const TIME_FORMAT: &'static str = "%H:%M";
|
const TIME_FORMAT: &str = "%H:%M";
|
||||||
|
|
||||||
/// Show this help menu
|
/// Show this help menu
|
||||||
#[poise::command(prefix_command, track_edits, slash_command)]
|
#[poise::command(prefix_command, track_edits, slash_command)]
|
||||||
|
@ -90,7 +90,7 @@ pub async fn available(ctx: Context<'_>, date: NaiveDate) -> Result<(), Error> {
|
||||||
let mut fields: Vec<(String, String, bool)> = Default::default();
|
let mut fields: Vec<(String, String, bool)> = Default::default();
|
||||||
|
|
||||||
for resource in &resources {
|
for resource in &resources {
|
||||||
if resource.hours.len() == 0 {
|
if resource.hours.is_empty() {
|
||||||
fields.push((
|
fields.push((
|
||||||
resource.resource_name.clone(),
|
resource.resource_name.clone(),
|
||||||
"Nothing available.".to_string(),
|
"Nothing available.".to_string(),
|
||||||
|
|
Loading…
Reference in New Issue