use model::id::MessageId;
use utils::VecMap;
#[derive(Clone, Debug, Default)]
pub struct GetMessages(pub VecMap<&'static str, u64>);
impl GetMessages {
#[inline]
pub fn after<M: Into<MessageId>>(self, message_id: M) -> Self {
self._after(message_id.into())
}
fn _after(mut self, message_id: MessageId) -> Self {
self.0.insert("after", message_id.0);
self
}
#[inline]
pub fn around<M: Into<MessageId>>(self, message_id: M) -> Self {
self._around(message_id.into())
}
fn _around(mut self, message_id: MessageId) -> Self {
self.0.insert("around", message_id.0);
self
}
#[inline]
pub fn before<M: Into<MessageId>>(self, message_id: M) -> Self {
self._before(message_id.into())
}
fn _before(mut self, message_id: MessageId) -> Self {
self.0.insert("before", message_id.0);
self
}
pub fn limit(mut self, limit: u64) -> Self {
self.0
.insert("limit", if limit > 100 { 100 } else { limit });
self
}
pub fn most_recent(self) -> Self { self }
}