1use macros::make_path_parts;
4use serde::{Deserialize, Serialize};
5use strum_macros::EnumIter;
6
7make_path_parts!(CreateSearchKeyPath => "/v1/search/key");
8
9#[derive(Serialize, Deserialize, Debug, Clone)]
11pub struct CreateSearchKeyResponse {
12    pub key: String,
14    }
16
17make_path_parts!(WebImageSearchPath => "/v1/search/web/image");
18
19#[derive(Serialize, Deserialize, Clone, Debug, Default)]
21#[serde(rename_all = "camelCase")]
22pub struct WebImageSearchQuery {
23    #[serde(default)]
25    pub q: String,
26
27    #[serde(skip_serializing_if = "Option::is_none")]
29    pub image_type: Option<ImageType>,
30}
31
32#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, EnumIter)]
34#[serde(rename_all = "camelCase")]
35pub enum ImageType {
36    Clipart = 0,
38    AnimatedGif = 1,
40    Photo = 2,
42    Line = 3,
44    Transparent = 4,
46    All = 5,
48    Illustration = 6,
50    Vector = 7,
52}
53
54impl ImageType {
56    #[must_use]
58    pub fn to_str(self) -> &'static str {
59        match self {
60            Self::Clipart => "Clipart",
61            Self::AnimatedGif => "AnimatedGif",
62            Self::Photo => "Photo",
63            Self::Line => "Line",
64            Self::Transparent => "Transparent",
65            Self::All => "All",
66            Self::Illustration => "Illustration",
67            Self::Vector => "Vector",
68        }
69    }
70
71    pub fn enabled_types() -> Vec<ImageType> {
73        vec![Self::All, Self::Photo, Self::Illustration, Self::Vector]
74    }
75}
76
77#[derive(Serialize, Deserialize, Debug, Clone)]
79pub struct WebImageSearchItem {
80    pub thumbnail_url: url::Url,
82    pub url: url::Url,
84}
85
86#[derive(Serialize, Deserialize, Debug)]
89pub struct WebImageSearchResponse {
90    pub images: Vec<WebImageSearchItem>,
92}