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
66
67
68
use actix_web::{HttpResponse, ResponseError};
use derive_more::Display;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GetMenuThemeBody {
    pub menu: Option<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GetMenuThemeResult {
    pub menu_theme: Option<MenuThemeAggregation>
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MenuThemeAggregation {
    pub id: Option<String>,
    pub menu: Option<String>,
    pub background_style: Option<Vec<BackgroundStyleAggregation>>,
    pub font_styles: Option<Vec<FontStyleAggregation>>,
    pub color_palette: Option<Vec<ColorAggregation>>,
    pub title_background: Option<Vec<TitleBackgroundAggregation>>
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct FontStyleAggregation {
    pub kind: Option<String>,
    pub value: Option<String>
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ColorAggregation {
    pub kind: Option<String>,
    pub value: Option<String>
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct BackgroundStyleAggregation {
    pub kind: Option<String>,
    pub value: Option<Vec<String>>
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TitleBackgroundAggregation {
    pub kind: Option<String>,
    pub value: Option<String>
}

#[derive(Debug, Display)]
pub enum GetMenuThemeError {
    #[display(fmt = "invalid_object_id")]
    InvalidObjectId,
    #[display(fmt = "menu_theme_not_found")]
    MenuThemeNotFound,
    Default(String),
}

impl ResponseError for GetMenuThemeError {
    fn error_response(&self) -> HttpResponse {
        match self {
            GetMenuThemeError::InvalidObjectId => HttpResponse::NotAcceptable().body("invalid_object_id"),
            GetMenuThemeError::MenuThemeNotFound => {
                HttpResponse::Conflict().body("menu_theme_not_found")
            }
            GetMenuThemeError::Default(error) => HttpResponse::BadRequest().body(error),
        }
    }
}