use macros::make_path_parts;
use serde::{Deserialize, Serialize};
use strum_macros::EnumIter;
make_path_parts!(CreateSearchKeyPath => "/v1/search/key");
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct CreateSearchKeyResponse {
pub key: String,
}
make_path_parts!(WebImageSearchPath => "/v1/search/web/image");
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
#[serde(rename_all = "camelCase")]
pub struct WebImageSearchQuery {
#[serde(default)]
pub q: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub image_type: Option<ImageType>,
}
#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, EnumIter)]
#[serde(rename_all = "camelCase")]
pub enum ImageType {
Clipart = 0,
AnimatedGif = 1,
Photo = 2,
Line = 3,
Transparent = 4,
}
impl ImageType {
#[must_use]
pub fn to_str(self) -> &'static str {
match self {
Self::Clipart => "Clipart",
Self::AnimatedGif => "AnimatedGif",
Self::Photo => "Photo",
Self::Line => "Line",
Self::Transparent => "Transparent",
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct WebImageSearchItem {
pub thumbnail_url: url::Url,
pub url: url::Url,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct WebImageSearchResponse {
pub images: Vec<WebImageSearchItem>,
}