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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! チャンネル関連のイベントペイロード

use serde::{Deserialize, Serialize};
#[cfg(feature = "time")]
use time::OffsetDateTime;

use super::types::{Channel, User};

/// CHANNEL_CREATEDペイロード
/// - [traQの型定義](https://github.com/traPtitech/traQ/blob/d2bc98f1e0e68f4acc371eb78e6a49a167446761/service/bot/event/payload/ev_channel_created.go#L9-L13)
/// - [traQ-bot-consoleのリファレンス](https://github.com/traPtitech/traQ-bot-console/blob/dev/src/docs/bot/events/channel.md#channel_created)
///
/// ## Example
/// ```
/// use traq_bot_http::payloads::ChannelCreatedPayload;
/// let payload = r##"{
///     "eventTime": "2019-05-08T13:45:51.506206852Z",
///     "channel": {
///         "id": "711afb4c-23e7-46dc-b845-5160f7088ce9",
///         "name": "yamada",
///         "path": "#gps/yamada",
///         "parentId": "ea452867-553b-4808-a14f-a47ee0009ee6",
///         "creator": {
///             "id": "dfdff0c9-5de0-46ee-9721-2525e8bb3d45",
///             "name": "takashi_trap",
///             "displayName": "寺田 健二",
///             "iconId": "2bc06cda-bdb9-4a68-8000-62f907f36a92",
///             "bot": false
///         },
///         "createdAt": "2019-05-08T13:45:51.487718Z",
///         "updatedAt": "2019-05-08T13:45:51.487718Z"
///     }
/// }"##;
/// let payload: ChannelCreatedPayload = serde_json::from_str(payload).unwrap();
/// println!("{payload:?}");
/// ```
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub struct ChannelCreatedPayload {
    #[cfg(feature = "time")]
    #[serde(rename = "eventTime", with = "time::serde::rfc3339")]
    pub event_time: OffsetDateTime,
    #[cfg(not(feature = "time"))]
    #[serde(rename = "eventTime")]
    pub event_time: String,
    pub channel: Channel,
}

/// CHANNEL_TOPIC_CHANGEDペイロード
/// - [traQの型定義](https://github.com/traPtitech/traQ/blob/d2bc98f1e0e68f4acc371eb78e6a49a167446761/service/bot/event/payload/ev_channel_topic_changed.go#L9-L15)
/// - [traQ-bot-consoleのリファレンス](https://github.com/traPtitech/traQ-bot-console/blob/dev/src/docs/bot/events/channel.md#channel_topic_changed)
///
/// ## Example
/// ```
/// use traq_bot_http::payloads::ChannelTopicChangedPayload;
/// let payload = r##"{
///     "eventTime": "2019-05-09T11:32:49.505357701Z",
///     "channel": {
///         "id": "9aba50da-f605-4cd0-a428-5e4558cb911e",
///         "name": "bot",
///         "path": "#a/bot",
///         "parentId": "ea452867-553b-4808-a14f-a47ee0009ee6",
///         "creator": {
///             "id": "dfdff0c9-5de0-46ee-9721-2525e8bb3d45",
///             "name": "takashi_trap",
///             "displayName": "寺田 健二",
///             "iconId": "2bc06cda-bdb9-4a68-8000-62f907f36a92",
///             "bot": false
///         },
///         "createdAt": "2019-05-08T13:45:51.487718Z",
///         "updatedAt": "2019-05-08T13:45:51.487718Z"
///     },
///     "topic": "トピック",
///     "updater": {
///         "id": "dfdff0c9-5de0-46ee-9721-2525e8bb3d45",
///         "name": "takashi_trap",
///         "displayName": "寺田 健二",
///         "iconId": "2bc06cda-bdb9-4a68-8000-62f907f36a92",
///         "bot": false
///     }
/// }"##;
/// let payload: ChannelTopicChangedPayload = serde_json::from_str(payload).unwrap();
/// println!("{payload:?}");
/// ```
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub struct ChannelTopicChangedPayload {
    #[cfg(feature = "time")]
    #[serde(rename = "eventTime", with = "time::serde::rfc3339")]
    pub event_time: OffsetDateTime,
    #[cfg(not(feature = "time"))]
    #[serde(rename = "eventTime")]
    pub event_time: String,
    pub channel: Channel,
    pub topic: String,
    pub updater: User,
}