feat: start affluences cli for testing
This commit is contained in:
parent
8909ac57a8
commit
29f13d49b9
7 changed files with 269 additions and 14 deletions
|
|
@ -20,6 +20,15 @@ impl AffluencesClient {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn search(&self, query: String) -> reqwest::Result<SiteSearchResponse> {
|
||||
let url = "https://api.affluences.com/app/v3/sites";
|
||||
let body = SiteSearch{
|
||||
search_query: query
|
||||
};
|
||||
|
||||
Ok(self.client.post(url).json(&body).send().await?.json::<Data<SiteSearchResponse>>().await?.data)
|
||||
}
|
||||
|
||||
pub async fn available(
|
||||
&self,
|
||||
site_id: uuid::Uuid,
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
use serde::Deserialize;
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Data<T> {
|
||||
pub data: T,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SiteDataCategory {
|
||||
pub id: u32,
|
||||
pub name: String,
|
||||
pub name_plural: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SiteDataLocationCoordinates {
|
||||
pub latitude: f64,
|
||||
pub longitude: f64,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SiteDataLocationAddress {
|
||||
pub route: String,
|
||||
pub city: String,
|
||||
|
|
@ -27,47 +27,47 @@ pub struct SiteDataLocationAddress {
|
|||
pub country_code: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SiteDataLocation {
|
||||
pub coordinates: SiteDataLocationCoordinates,
|
||||
pub address: SiteDataLocationAddress,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SiteDataForecast {
|
||||
pub opened: bool,
|
||||
pub occupancy: u32,
|
||||
pub occupancy: Option<u32>,
|
||||
// waiting_time
|
||||
pub waiting_time_overflow: bool,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SiteDataNotice {
|
||||
pub message: String,
|
||||
pub url: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SiteDataService {
|
||||
pub id: u32,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SiteDataInfo {
|
||||
pub title: String,
|
||||
pub description: String,
|
||||
pub url: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SiteDataStatus {
|
||||
pub state: String,
|
||||
pub text: String,
|
||||
pub color: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SiteData {
|
||||
pub id: uuid::Uuid,
|
||||
pub slug: String,
|
||||
|
|
@ -104,3 +104,15 @@ pub struct SiteData {
|
|||
#[serde(rename = "publicationStatus")]
|
||||
pub publication_status: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct SiteSearch {
|
||||
pub search_query: String
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SiteSearchResponse {
|
||||
pub page: u32,
|
||||
pub max_size: u32,
|
||||
pub results: Vec<SiteData>
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue