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
use crate::{impl_default, impl_display};
/// Represents the Zulip API endpoint variants.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Endpoint {
/// Represents the `Send Message` API endpoint.
SendMessage,
/// Represents the `Get Messages` API endpoint.
GetMessages,
/// Represents the `Upload File` API endpoint.
UploadFile,
/// Represents the `Resumable Upload File` API endpoint.
ResumableUploadFile,
/// Represents the `Edit Message` API endpoint.
EditMessage,
/// Represents the `Delete Message` API endpoint.
DeleteMessage,
/// Represents the `Get Message` API endpoint.
GetMessage,
/// Represents the `Get Message History` API endpoint.
GetMessageHistory,
/// Represents the `Report Message` API endpoint.
ReportMessage,
/// Represents the `Matches Narrow` API endpoint.
MatchesNarrow,
/// Represents the `Register` API endpoint.
Register,
/// Represents the `Reactions` API endpoint.
Reaction,
/// Represents the `Render` API endpoint.
Render,
/// Represents the `Fetch API Key` API endpoint.
FetchApiKey,
/// Represents the `Update Message Flags` API endpoint.
UpdateMessageFlags,
/// Represents the `Update Message Flags for Narrow` API endpoint.
UpdateMessageFlagsNarrow,
/// Represents the `Mark All as Read` API endpoint.
MarkAllAsRead,
/// Represents the `Mark Stream as Read` API endpoint.
MarkStreamAsRead,
/// Represents the `Mark Topic as Read` API endpoint.
MarkTopicAsRead,
}
impl Endpoint {
/// Represents the string value for the `Send Message` endpoint.
pub const SEND_MESSAGE: &str = "api/v1/messages";
/// Represents the string value for the `Get Messages` endpoint.
pub const GET_MESSAGES: &str = "api/v1/messages";
/// Represents the string value for the `Upload File` endpoint.
pub const UPLOAD_FILE: &str = "api/v1/user_uploads";
/// Represents the string value for the `Resumable Upload File` endpoint.
pub const RESUMABLE_UPLOAD_FILE: &str = "api/v1/tus";
/// Represents the string value for the `Edit Message` endpoint.
pub const EDIT_MESSAGE: &str = "api/v1/messages";
/// Represents the string value for the `Delete Message` endpoint.
pub const DELETE_MESSAGE: &str = "api/v1/messages";
/// Represents the string value for the `Get Message` endpoint.
pub const GET_MESSAGE: &str = "api/v1/messages";
/// Represents the string value for the `Get Message History` endpoint.
pub const GET_MESSAGE_HISTORY: &str = "api/v1/messages";
/// Represents the string value for the `Report Message` endpoint.
pub const REPORT_MESSAGE: &str = "api/v1/messages";
/// Represents the string value for the `Matches Narrow` endpoint.
pub const MATCHES_NARROW: &str = "api/v1/messages/matches_narrow";
/// Represents the string value for the `Register` endpoint.
pub const REGISTER: &str = "api/v1/register";
/// Represents the string value for the `Reactions` endpoint.
pub const REACTION: &str = "api/v1/messages";
/// Represents the string value for the `Render` endpoint.
pub const RENDER: &str = "api/v1/messages/render";
/// Represents the string value for the `Fetch API Key` endpoint.
pub const FETCH_API_KEY: &str = "api/v1/fetch_api_key";
/// Represents the string value for the `Update Message Flags` endpoint.
pub const UPDATE_MESSAGE_FLAGS: &str = "api/v1/messages/flags";
/// Represents the string value for the `Update Message Flags for Narrow` endpoint.
pub const UPDATE_MESSAGE_FLAGS_NARROW: &str = "api/v1/messages/flags/narrow";
/// Represents the string value for the `Mark All as Read` endpoint.
pub const MARK_ALL_AS_READ: &str = "api/v1/mark_all_as_read";
/// Represents the string value for the `Mark Stream as Read` endpoint.
pub const MARK_STREAM_AS_READ: &str = "api/v1/mark_stream_as_read";
/// Represents the string value for the `Mark Topic as Read` endpoint.
pub const MARK_TOPIC_AS_READ: &str = "api/v1/mark_topic_as_read";
/// Creates a new [Endpoint].
pub const fn new() -> Self {
Self::SendMessage
}
/// Gets the string representation of the [Endpoint].
pub const fn as_str(&self) -> &'static str {
match self {
Self::SendMessage => Self::SEND_MESSAGE,
Self::GetMessages => Self::GET_MESSAGES,
Self::UploadFile => Self::UPLOAD_FILE,
Self::ResumableUploadFile => Self::RESUMABLE_UPLOAD_FILE,
Self::EditMessage => Self::EDIT_MESSAGE,
Self::DeleteMessage => Self::DELETE_MESSAGE,
Self::GetMessage => Self::GET_MESSAGE,
Self::GetMessageHistory => Self::GET_MESSAGE_HISTORY,
Self::ReportMessage => Self::REPORT_MESSAGE,
Self::MatchesNarrow => Self::MATCHES_NARROW,
Self::Register => Self::REGISTER,
Self::Reaction => Self::REACTION,
Self::Render => Self::RENDER,
Self::FetchApiKey => Self::FETCH_API_KEY,
Self::UpdateMessageFlags => Self::UPDATE_MESSAGE_FLAGS,
Self::UpdateMessageFlagsNarrow => Self::UPDATE_MESSAGE_FLAGS_NARROW,
Self::MarkAllAsRead => Self::MARK_ALL_AS_READ,
Self::MarkStreamAsRead => Self::MARK_STREAM_AS_READ,
Self::MarkTopicAsRead => Self::MARK_TOPIC_AS_READ,
}
}
}
impl From<Endpoint> for &'static str {
fn from(val: Endpoint) -> Self {
val.as_str()
}
}
impl From<Endpoint> for String {
fn from(val: Endpoint) -> Self {
val.as_str().to_string()
}
}
impl_default!(Endpoint);
impl_display!(Endpoint: str);