zulip_api/message/realm_emoji.rs
1use serde::{Deserialize, Serialize};
2
3use crate::{field_access, impl_default, impl_display};
4
5/// Represents details about the emoji with the specified ID. It has the following properties:
6///
7/// Modified from `openapi-generator-cli` output:
8///
9/// ```shell,no_build,no_run
10/// $ openapi-generator-cli generate -g rust -i ./zerver/openapi/zulip.yaml -o zulip-openapi --skip-validate-spec
11/// ```
12///
13/// ```text
14/// /*
15/// * Zulip REST API
16/// *
17/// * Powerful open source group chat
18/// *
19/// * The version of the OpenAPI document: 1.0.0
20/// *
21/// * Generated by: https://openapi-generator.tech
22/// */
23/// ```
24///
25/// See [zerver/openapi/zulip.yaml](https://github.com/zulip/zulip/blob/main/zerver/openapi/zulip.yaml) for the original OpenAPI configuration.
26///
27/// Configuration slightly modified to work with the Rust generator of [`openapi-generator-cli`](https://openapi-generator.tech).
28#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
29pub struct RealmEmoji {
30 #[serde(skip_serializing_if = "Option::is_none")]
31 id: Option<String>,
32 #[serde(skip_serializing_if = "Option::is_none")]
33 name: Option<String>,
34 #[serde(skip_serializing_if = "Option::is_none")]
35 source_url: Option<String>,
36 #[serde(skip_serializing_if = "Option::is_none")]
37 still_url: Option<String>,
38 #[serde(skip_serializing_if = "Option::is_none")]
39 deactivated: Option<bool>,
40 #[serde(skip_serializing_if = "Option::is_none")]
41 author_id: Option<u64>,
42}
43
44impl RealmEmoji {
45 /// Creates a new [RealmEmoji].
46 pub const fn new() -> Self {
47 Self {
48 id: None,
49 name: None,
50 source_url: None,
51 still_url: None,
52 deactivated: None,
53 author_id: None,
54 }
55 }
56}
57
58field_access! {
59 RealmEmoji {
60 /// The ID for this emoji, same as the object's key.
61 id: option_cow_deref { str, String },
62 /// The user-friendly name for this emoji.
63 ///
64 /// Users in the organization can use this emoji by writing this name between colons (`:name :`).
65 name: option_cow_deref { str, String },
66 /// The path relative to the organization's URL where the emoji's image can be found.
67 source_url: option_cow_deref { str, String },
68 /// Only non-null when the emoji's image is animated.
69 ///
70 /// The path relative to the organization's URL where a still (not animated) version of the emoji can be found.
71 /// (This is currently always the first frame of the animation).
72 ///
73 /// This is useful for clients to display the emoji in contexts where continuously animating it would be a bad user experience (e.g. because it would be distracting).
74 ///
75 /// **Changes**: New in Zulip 5.0 (added as optional field in feature level 97 and then made mandatory, but nullable, in feature level 113).
76 still_url: option_cow_deref { str, String },
77 }
78}
79
80field_access! {
81 RealmEmoji {
82 /// Whether the emoji has been deactivated or not.
83 deactivated: option { bool },
84 /// The user ID of the user who uploaded the custom emoji.
85 ///
86 /// Will be `null` if the uploader is unknown.
87 ///
88 /// **Changes**: New in Zulip 3.0 (feature level 7). Previously was accessible via an `author` object with an `id` field.
89 author_id: option { u64 },
90 }
91}
92
93impl_default!(RealmEmoji);
94impl_display!(RealmEmoji);