feat: command to list available dates
This commit is contained in:
parent
bfd438cf71
commit
d1245ab365
3 changed files with 68 additions and 4 deletions
|
|
@ -17,17 +17,17 @@ impl AffluencesClient {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn available(&mut self, site_id: uuid::Uuid, date: NaiveDate, resource_type: u32) -> reqwest::Result<Vec<Resource>> {
|
||||
pub async fn available(&self, site_id: uuid::Uuid, date: NaiveDate, resource_type: u32) -> reqwest::Result<Vec<Resource>> {
|
||||
let url = format!("https://reservation.affluences.com/api/resources/{}/available", site_id);
|
||||
self.client.get(url).query(&[("date", date.format("%Y-%m-%d").to_string()), ("type", resource_type.to_string())]).send().await?.json::<Vec<Resource>>().await
|
||||
}
|
||||
|
||||
pub async fn site_data(&mut self, slug: &str) -> reqwest::Result<SiteData> {
|
||||
pub async fn site_data(&self, slug: &str) -> reqwest::Result<SiteData> {
|
||||
let url = format!("https://api.affluences.com/app/v3/sites/{}", slug);
|
||||
Ok(self.client.get(url).send().await?.json::<Data<SiteData>>().await?.data)
|
||||
}
|
||||
|
||||
pub async fn make_reservation(&mut self, resource_id: u32, reservation: &Reservation) -> reqwest::Result<ReservationResponse> {
|
||||
pub async fn make_reservation(&self, resource_id: u32, reservation: &Reservation) -> reqwest::Result<ReservationResponse> {
|
||||
let url = format!("https://reservation.affluences.com/api/reserve/{}", resource_id);
|
||||
self.client.post(url).json(reservation).send().await?.json::<ReservationResponse>().await
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue