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
use crate::*;

use rsb_derive::Builder;
use rvstruct::*;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;

pub trait HasChannelInfo {
    fn get_channel_id(&self) -> &SlackChannelId;
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackChannelInfo {
    pub id: SlackChannelId,
    pub created: SlackDateTime,
    pub creator: Option<SlackUserId>,
    pub name: Option<String>,
    pub name_normalized: Option<String>,
    pub topic: Option<SlackChannelTopicInfo>,
    pub purpose: Option<SlackChannelPurposeInfo>,
    pub previous_names: Option<Vec<String>>,
    pub priority: Option<SlackChannelPriority>,
    pub num_members: Option<u64>,
    pub locale: Option<SlackLocale>,
    #[serde(flatten)]
    pub flags: SlackChannelFlags,
    #[serde(flatten)]
    pub last_state: SlackChannelCurrentState,
}

impl HasChannelInfo for SlackChannelInfo {
    fn get_channel_id(&self) -> &SlackChannelId {
        &self.id
    }
}

pub type SlackChannelTopicInfo = SlackChannelDetails;
pub type SlackChannelPurposeInfo = SlackChannelDetails;

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackChannelDetails {
    pub value: String,
    pub creator: Option<SlackUserId>,
    pub last_set: Option<SlackDateTime>,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackChannelFlags {
    pub is_channel: Option<bool>,
    pub is_group: Option<bool>,
    pub is_im: Option<bool>,
    pub is_archived: Option<bool>,
    pub is_general: Option<bool>,
    pub is_shared: Option<bool>,
    pub is_org_shared: Option<bool>,
    pub is_member: Option<bool>,
    pub is_private: Option<bool>,
    pub is_mpim: Option<bool>,
    pub is_user_deleted: Option<bool>,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackChannelCurrentState {
    pub last_read: Option<SlackTs>,
    pub unread_count: Option<u64>,
    pub unread_count_display: Option<u64>,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackBasicChannelInfo {
    pub id: SlackChannelId,
    pub name: Option<String>,
}

impl HasChannelInfo for SlackBasicChannelInfo {
    fn get_channel_id(&self) -> &SlackChannelId {
        &self.id
    }
}

#[derive(Debug, PartialEq, PartialOrd, Clone, Serialize, Deserialize, ValueStruct)]
pub struct SlackChannelPriority(pub f64);