1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use clap::ArgEnum;
use strum_macros::Display;

#[derive(Clone, ArgEnum, Display, Debug)]
#[strum(serialize_all = "lowercase")]
pub enum InputType {
    TextQuery,
    PhoneNumber,
}

#[derive(Debug)]
pub struct Request<'a> {
    pub url: &'a str,
    pub token: &'a str,
    pub input: String,
    pub input_type: String,
    pub fields: Vec<Field>,
}

#[derive(Clone, ArgEnum, Display, Debug)]
#[strum(serialize_all = "snake_case")]
pub enum Field {
    // AddressComponent,
    // AdrAddress,
    // FormattedPhoneNumber,
    // InternationalPhoneNumber,
    // Review,
    // Type,
    // Url,
    // UtcOffset,
    // Website,
    // Vicinity,
    BusinessStatus,
    FormattedAddress,
    Geometry,
    Icon,
    IconMaskBaseUri,
    IconBackgroundColor,
    Name,
    Photo,
    PlaceId,
    PlusCode,

    OpeningHours,

    PriceLevel,
    Rating,
    UserRatingsTotal,
}

impl Request<'_> {
    pub fn add_field(&mut self, field: Field) -> &mut Self {
        self.fields.push(field);

        self
    }

    pub fn add_fields(&mut self, fields: Vec<Field>) -> &mut Self {
        fields.into_iter().for_each(|field| {
            self.add_field(field);
        });

        self
    }
}