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
use crate::message::LineMessageObject;
use serde_derive::{Deserialize, Serialize};
use serde_json::{json, Value};

#[derive(Debug, Default, Deserialize, Serialize, Clone)]
pub struct LineMessageLocation {
    #[serde(rename = "type")]
    message_type: String,
    title: String,
    address: String,
    latitude: f32,
    longitude: f32,
}

impl LineMessageLocation {
    pub fn new(title: String, address: String, latitude: f32, longitude: f32) -> Self {
        Self {
            message_type: "location".to_string(),
            title,
            address,
            latitude,
            longitude,
        }
    }
}

impl LineMessageObject for LineMessageLocation {
    fn build(&self) -> Value {
        json!(self)
    }
}