messaging_api_line/models/
flex_image.rs

1/*
2 * LINE Messaging API
3 *
4 * This document describes LINE Messaging API.
5 *
6 * The version of the OpenAPI document: 0.0.1
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct FlexImage {
16    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
17    pub r#type: Option<String>,
18    /// Image URL (Max character limit: 2000) Protocol: HTTPS (TLS 1.2 or later) Image format: JPEG or PNG Maximum image size: 1024×1024 pixels Maximum file size: 10 MB (300 KB when the animated property is true)
19    #[serde(rename = "url")]
20    pub url: String,
21    /// The ratio of the width or height of this component within the parent box.
22    #[serde(rename = "flex", skip_serializing_if = "Option::is_none")]
23    pub flex: Option<i32>,
24    /// The minimum amount of space to include before this component in its parent container.
25    #[serde(rename = "margin", skip_serializing_if = "Option::is_none")]
26    pub margin: Option<String>,
27    /// Reference for offsetTop, offsetBottom, offsetStart, and offsetEnd. Specify one of the following values:  `relative`: Use the previous box as reference. `absolute`: Use the top left of parent element as reference. The default value is relative.
28    #[serde(rename = "position", skip_serializing_if = "Option::is_none")]
29    pub position: Option<Position>,
30    /// Offset.
31    #[serde(rename = "offsetTop", skip_serializing_if = "Option::is_none")]
32    pub offset_top: Option<String>,
33    /// Offset.
34    #[serde(rename = "offsetBottom", skip_serializing_if = "Option::is_none")]
35    pub offset_bottom: Option<String>,
36    /// Offset.
37    #[serde(rename = "offsetStart", skip_serializing_if = "Option::is_none")]
38    pub offset_start: Option<String>,
39    /// Offset.
40    #[serde(rename = "offsetEnd", skip_serializing_if = "Option::is_none")]
41    pub offset_end: Option<String>,
42    /// Alignment style in horizontal direction.
43    #[serde(rename = "align", skip_serializing_if = "Option::is_none")]
44    pub align: Option<Align>,
45    /// Alignment style in vertical direction.
46    #[serde(rename = "gravity", skip_serializing_if = "Option::is_none")]
47    pub gravity: Option<Gravity>,
48    /// The maximum image width. This is md by default.
49    #[serde(rename = "size", skip_serializing_if = "Option::is_none")]
50    pub size: Option<String>,
51    /// Aspect ratio of the image. `{width}:{height}` format. Specify the value of `{width}` and `{height}` in the range from `1` to `100000`. However, you cannot set `{height}` to a value that is more than three times the value of `{width}`. The default value is `1:1`.
52    #[serde(rename = "aspectRatio", skip_serializing_if = "Option::is_none")]
53    pub aspect_ratio: Option<String>,
54    /// The display style of the image if the aspect ratio of the image and that specified by the aspectRatio property do not match.
55    #[serde(rename = "aspectMode", skip_serializing_if = "Option::is_none")]
56    pub aspect_mode: Option<AspectMode>,
57    /// Background color of the image. Use a hexadecimal color code.
58    #[serde(rename = "backgroundColor", skip_serializing_if = "Option::is_none")]
59    pub background_color: Option<String>,
60    #[serde(rename = "action", skip_serializing_if = "Option::is_none")]
61    pub action: Option<Box<models::Action>>,
62    /// When this is `true`, an animated image (APNG) plays. You can specify a value of true up to 10 images in a single message. You can't send messages that exceed this limit. This is `false` by default. Animated images larger than 300 KB aren't played back.
63    #[serde(rename = "animated", skip_serializing_if = "Option::is_none")]
64    pub animated: Option<bool>,
65}
66
67impl FlexImage {
68    pub fn new(r#type: String, url: String) -> FlexImage {
69        FlexImage {
70            r#type: Some(r#type),
71            url,
72            flex: None,
73            margin: None,
74            position: None,
75            offset_top: None,
76            offset_bottom: None,
77            offset_start: None,
78            offset_end: None,
79            align: None,
80            gravity: None,
81            size: None,
82            aspect_ratio: None,
83            aspect_mode: None,
84            background_color: None,
85            action: None,
86            animated: None,
87        }
88    }
89}
90/// Reference for offsetTop, offsetBottom, offsetStart, and offsetEnd. Specify one of the following values:  `relative`: Use the previous box as reference. `absolute`: Use the top left of parent element as reference. The default value is relative.
91#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
92pub enum Position {
93    #[serde(rename = "relative")]
94    Relative,
95    #[serde(rename = "absolute")]
96    Absolute,
97}
98
99impl Default for Position {
100    fn default() -> Position {
101        Self::Relative
102    }
103}
104/// Alignment style in horizontal direction.
105#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
106pub enum Align {
107    #[serde(rename = "start")]
108    Start,
109    #[serde(rename = "end")]
110    End,
111    #[serde(rename = "center")]
112    Center,
113}
114
115impl Default for Align {
116    fn default() -> Align {
117        Self::Start
118    }
119}
120/// Alignment style in vertical direction.
121#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
122pub enum Gravity {
123    #[serde(rename = "top")]
124    Top,
125    #[serde(rename = "bottom")]
126    Bottom,
127    #[serde(rename = "center")]
128    Center,
129}
130
131impl Default for Gravity {
132    fn default() -> Gravity {
133        Self::Top
134    }
135}
136/// The display style of the image if the aspect ratio of the image and that specified by the aspectRatio property do not match.
137#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
138pub enum AspectMode {
139    #[serde(rename = "fit")]
140    Fit,
141    #[serde(rename = "cover")]
142    Cover,
143}
144
145impl Default for AspectMode {
146    fn default() -> AspectMode {
147        Self::Fit
148    }
149}