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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::{field_access, impl_default, impl_display, BotType, ProfileData, Role};
/// Represents basic data on a given Zulip user.
///
/// **Changes**: Removed `is_billing_admin` field in Zulip 10.0 (feature level 363), as it was replaced by the `can_manage_billing_group` realm setting.
///
/// Modified from `openapi-generator-cli` output:
///
/// ```shell,no_build,no_run
/// $ openapi-generator-cli generate -g rust -i ./zerver/openapi/zulip.yaml -o zulip-openapi --skip-validate-spec
/// ```
///
/// ```text
/// /*
/// * Zulip REST API
/// *
/// * Powerful open source group chat
/// *
/// * The version of the OpenAPI document: 1.0.0
/// *
/// * Generated by: https://openapi-generator.tech
/// */
/// ```
///
/// See [zerver/openapi/zulip.yaml](https://github.com/zulip/zulip/blob/main/zerver/openapi/zulip.yaml) for the original OpenAPI configuration.
///
/// Configuration slightly modified to work with the Rust generator of [`openapi-generator-cli`](https://openapi-generator.tech).
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct User {
#[serde(skip_serializing_if = "Option::is_none")]
user_id: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
delivery_email: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
email: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
full_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
date_joined: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
is_active: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
is_owner: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
is_admin: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
is_guest: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
is_bot: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
bot_type: Option<BotType>,
#[serde(skip_serializing_if = "Option::is_none")]
bot_owner_id: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
role: Option<Role>,
#[serde(skip_serializing_if = "Option::is_none")]
timezone: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
avatar_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
avatar_version: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
profile_data: Option<HashMap<String, ProfileData>>,
}
impl User {
/// A dictionary containing basic data on a given Zulip user.
///
/// **Changes**: Removed `is_billing_admin` field in Zulip 10.0 (feature level 363), as it was replaced by the `can_manage_billing_group` realm setting.
pub const fn new() -> Self {
Self {
user_id: None,
delivery_email: None,
email: None,
full_name: None,
date_joined: None,
is_active: None,
is_owner: None,
is_admin: None,
is_guest: None,
is_bot: None,
bot_type: None,
bot_owner_id: None,
role: None,
timezone: None,
avatar_url: None,
avatar_version: None,
profile_data: None,
}
}
}
field_access! {
User {
/// The unique ID of the user.
user_id: option { u64 },
/// A boolean specifying whether the user account has been deactivated.
is_active: option { bool },
/// A boolean specifying whether the user is an organization owner. If true, `is_admin` will also be true. **Changes**: New in Zulip 3.0 (feature level 8).
is_owner: option { bool },
/// A boolean specifying whether the user is an organization administrator.
is_admin: option { bool },
/// A boolean specifying whether the user is a guest user.
is_guest: option { bool },
/// A boolean specifying whether the user is a bot or full account.
is_bot: option { bool },
/// An integer describing the type of bot.
bot_type: option { BotType },
/// If the user is a bot (i.e. `is_bot` is true), then `bot_owner_id` is the user ID of the bot's owner (usually, whoever created the bot).
///
/// Will be `null` for legacy bots that do not have an owner.
///
/// **Changes**: New in Zulip 3.0 (feature level 1). In previous versions, there was a `bot_owner` field containing the email address of the bot's owner.
bot_owner_id: option { u64 },
/// [Organization-level role](https://zulip.com/api/roles-and-permissions) of the user.
role: option { Role },
/// Version for the user's avatar. Used for cache-busting requests for the user's avatar. Clients generally shouldn't need to use this; most avatar URLs sent by Zulip will already end with `?v={avatar_version}`.
avatar_version: option { u64 },
}
}
field_access! {
User {
/// The user's real email address.
///
/// This value will be `null` if you cannot access user's real email address.
/// For bot users, this field is always set to the real email of the bot, because bot users always have `email_address_visibility` set to everyone.
///
/// **Changes**: Prior to Zulip 7.0 (feature level 163), this field was present only when `email_address_visibility` was restricted and you had access to the user's real email.
/// As of this feature level, this field is always present, including the case when `email_address_visibility` is set to everyone (and therefore not restricted).
delivery_email: option_cow_deref { str, String },
/// The Zulip API email address of the user or bot.
///
/// If you do not have permission to view the email address of the target user, this will be a fake email address that is usable for the Zulip API but nothing else.
email: option_cow_deref { str, String },
/// Full name of the user or bot, used for all display purposes.
full_name: option_cow_deref { str, String },
/// The time the user account was created.
date_joined: option_cow_deref { str, String },
/// The IANA identifier of the user's [profile time zone](https://zulip.com/help/change-your-timezone), which is used primarily to display the user's local time to other users.
timezone: option_cow_deref { str, String },
/// URL for the user's avatar.
///
/// Will be `null` if the `client_gravatar` query parameter was set to `true`,
/// the current user has access to this user's real email address,
/// and this user's avatar is hosted by the Gravatar provider (i.e. this user has never uploaded an avatar).
///
/// **Changes**: Before Zulip 7.0 (feature level 163),
/// access to a user's real email address was a realm-level setting.
/// As of this feature level, `email_address_visibility` is a user setting.
///
/// In Zulip 3.0 (feature level 18), if the client has the `user_avatar_url_field_optional` capability, this will be missing at the server's sole discretion.
avatar_url: option_cow_deref { str, String },
}
}
field_access! {
User {
/// Only present if `is_bot` is false; bots can't have custom profile fields.
///
/// A dictionary containing custom profile field data for the user.
/// Each entry maps the integer ID of a custom profile field in the organization to a dictionary containing the user's data for that field.
/// Generally the data includes just a single `value` key; for those custom profile fields supporting Markdown, a `rendered_value` key will also be present.
profile_data: option_ref { HashMap<String, ProfileData> },
}
}
impl_default!(User);
impl_display!(User);