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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
use crate::*;

use crate::SlackUserId;
use rsb_derive::Builder;
use rvstruct::*;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, skip_serializing_none, DisplayFromStr};

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackUser {
    pub id: SlackUserId,
    pub team_id: Option<SlackTeamId>,
    pub name: Option<String>,
    pub locale: Option<SlackLocale>,
    pub profile: Option<SlackUserProfile>,
    #[serde(flatten)]
    pub flags: SlackUserFlags,
    pub tz: Option<String>,
    pub tz_label: Option<String>,
    pub tz_offset: Option<i32>,
    pub updated: Option<SlackDateTime>,
    pub deleted: Option<bool>,
    pub color: Option<SlackColor>,
    pub real_name: Option<String>,
    pub enterprise_user: Option<SlackEnterpriseUser>,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackUserProfile {
    pub id: Option<SlackUserId>,
    pub display_name: Option<String>,
    pub real_name: Option<String>,
    pub real_name_normalized: Option<String>,
    pub avatar_hash: Option<SlackAvatarHash>,
    pub status_text: Option<String>,
    pub status_expiration: Option<SlackDateTime>,
    pub status_emoji: Option<SlackEmoji>,
    pub display_name_normalized: Option<String>,
    pub email: Option<EmailAddress>,
    #[serde(flatten)]
    pub icon: Option<SlackIcon>,
    pub team: Option<SlackTeamId>,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackUserFlags {
    pub is_admin: Option<bool>,
    pub is_app_user: Option<bool>,
    pub is_bot: Option<bool>,
    pub is_invited_user: Option<bool>,
    pub is_owner: Option<bool>,
    pub is_primary_owner: Option<bool>,
    pub is_restricted: Option<bool>,
    pub is_stranger: Option<bool>,
    pub is_ultra_restricted: Option<bool>,
    pub has_2fa: Option<bool>,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackBasicUserInfo {
    pub id: SlackUserId,
    pub team_id: Option<SlackTeamId>,
    pub username: Option<String>,
    pub name: Option<String>,
}

#[serde_as]
#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackUserGroup {
    pub id: SlackUserGroupId,
    pub team_id: SlackTeamId,
    pub enterprise_subteam_id: Option<SlackEnterpriseSubteamId>,
    pub is_usergroup: Option<bool>,
    pub is_subteam: Option<bool>,
    pub name: String,
    pub description: Option<String>,
    pub handle: String,
    pub is_external: bool,
    pub auto_provision: Option<bool>,
    pub date_create: SlackDateTime,
    pub date_update: Option<SlackDateTime>,
    pub date_delete: Option<SlackDateTime>,
    pub auto_type: Option<SlackAutoType>,
    pub created_by: SlackUserId,
    pub updated_by: Option<SlackUserId>,
    pub deleted_by: Option<SlackUserId>,
    pub prefs: SlackUserGroupPrefs,
    pub users: Option<Vec<SlackUserId>>,
    #[serde_as(as = "DisplayFromStr")]
    pub user_count: usize,
    pub channel_count: Option<u64>,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum SlackAutoType {
    Admin,
    Owner,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackUserGroupPrefs {
    pub channels: Vec<SlackChannelId>,
    pub groups: Vec<SlackUserGroupId>,
}

#[derive(Debug, Eq, PartialEq, Hash, Clone, Serialize, Deserialize, ValueStruct)]
pub struct SlackAvatarHash(pub String);

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackEnterpriseUser {
    pub id: SlackUserId,
    pub enterprise_id: SlackEnterpriseId,
    pub enterprise_name: Option<String>,
    #[serde(flatten)]
    pub flags: SlackUserFlags,
    pub teams: Option<Vec<SlackTeamId>>,
}