|
|
@ -1,5 +1,7 @@ |
|
|
|
use std::borrow::Cow; |
|
|
|
use std::borrow::Cow; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Builder for making a client.statuses() call
|
|
|
|
|
|
|
|
///
|
|
|
|
/// # Example
|
|
|
|
/// # Example
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
@ -19,40 +21,118 @@ pub struct StatusesRequest<'a> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl<'a> StatusesRequest<'a> { |
|
|
|
impl<'a> StatusesRequest<'a> { |
|
|
|
|
|
|
|
/// Construct a new `StatusesRequest` object
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// # Example
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
|
|
|
|
/// # extern crate elefren;
|
|
|
|
|
|
|
|
/// # use elefren::StatusesRequest;
|
|
|
|
|
|
|
|
/// let request = StatusesRequest::new();
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
pub fn new() -> Self { |
|
|
|
pub fn new() -> Self { |
|
|
|
Self::default() |
|
|
|
Self::default() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Set the `?only_media=1` flag for the .statuses() request
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// # Example
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
|
|
|
|
/// # extern crate elefren;
|
|
|
|
|
|
|
|
/// # use elefren::StatusesRequest;
|
|
|
|
|
|
|
|
/// let request = StatusesRequest::new().only_media();
|
|
|
|
|
|
|
|
/// assert_eq!(&request.to_querystring(), "?only_media=1");
|
|
|
|
pub fn only_media(mut self) -> Self { |
|
|
|
pub fn only_media(mut self) -> Self { |
|
|
|
self.only_media = true; |
|
|
|
self.only_media = true; |
|
|
|
self |
|
|
|
self |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Set the `?exclude_replies=1` flag for the .statuses() request
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// # Example
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
|
|
|
|
/// # extern crate elefren;
|
|
|
|
|
|
|
|
/// # use elefren::StatusesRequest;
|
|
|
|
|
|
|
|
/// let request = StatusesRequest::new().exclude_replies();
|
|
|
|
|
|
|
|
/// assert_eq!(&request.to_querystring(), "?exclude_replies=1");
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
pub fn exclude_replies(mut self) -> Self { |
|
|
|
pub fn exclude_replies(mut self) -> Self { |
|
|
|
self.exclude_replies = true; |
|
|
|
self.exclude_replies = true; |
|
|
|
self |
|
|
|
self |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Set the `?pinned=1` flag for the .statuses() request
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// # Example
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
|
|
|
|
/// # extern crate elefren;
|
|
|
|
|
|
|
|
/// # use elefren::StatusesRequest;
|
|
|
|
|
|
|
|
/// let request = StatusesRequest::new().pinned();
|
|
|
|
|
|
|
|
/// assert_eq!(&request.to_querystring(), "?pinned=1");
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
pub fn pinned(mut self) -> Self { |
|
|
|
pub fn pinned(mut self) -> Self { |
|
|
|
self.pinned = true; |
|
|
|
self.pinned = true; |
|
|
|
self |
|
|
|
self |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Set the `?max_id=:max_id` flag for the .statuses() request
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// # Example
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
|
|
|
|
/// # extern crate elefren;
|
|
|
|
|
|
|
|
/// # use elefren::StatusesRequest;
|
|
|
|
|
|
|
|
/// let request = StatusesRequest::new().max_id("foo");
|
|
|
|
|
|
|
|
/// assert_eq!(&request.to_querystring(), "?max_id=foo");
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
pub fn max_id<S: Into<Cow<'a, str>>>(mut self, max_id: S) -> Self { |
|
|
|
pub fn max_id<S: Into<Cow<'a, str>>>(mut self, max_id: S) -> Self { |
|
|
|
self.max_id = Some(max_id.into()); |
|
|
|
self.max_id = Some(max_id.into()); |
|
|
|
self |
|
|
|
self |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Set the `?since_id=:since_id` flag for the .statuses() request
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// # Example
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
|
|
|
|
/// # extern crate elefren;
|
|
|
|
|
|
|
|
/// # use elefren::StatusesRequest;
|
|
|
|
|
|
|
|
/// let request = StatusesRequest::new().since_id("foo");
|
|
|
|
|
|
|
|
/// assert_eq!(&request.to_querystring(), "?since_id=foo");
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
pub fn since_id<S: Into<Cow<'a, str>>>(mut self, since_id: S) -> Self { |
|
|
|
pub fn since_id<S: Into<Cow<'a, str>>>(mut self, since_id: S) -> Self { |
|
|
|
self.since_id = Some(since_id.into()); |
|
|
|
self.since_id = Some(since_id.into()); |
|
|
|
self |
|
|
|
self |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Set the `?limit=:limit` flag for the .statuses() request
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// # Example
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
|
|
|
|
/// # extern crate elefren;
|
|
|
|
|
|
|
|
/// # use elefren::StatusesRequest;
|
|
|
|
|
|
|
|
/// let request = StatusesRequest::new().limit(10);
|
|
|
|
|
|
|
|
/// assert_eq!(&request.to_querystring(), "?limit=10");
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
pub fn limit(mut self, limit: usize) -> Self { |
|
|
|
pub fn limit(mut self, limit: usize) -> Self { |
|
|
|
self.limit = Some(limit); |
|
|
|
self.limit = Some(limit); |
|
|
|
self |
|
|
|
self |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Turns this builder into a querystring
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// # Example
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
|
|
|
|
/// # extern crate elefren;
|
|
|
|
|
|
|
|
/// # use elefren::StatusesRequest;
|
|
|
|
|
|
|
|
/// let request = StatusesRequest::new().limit(10).pinned();
|
|
|
|
|
|
|
|
/// assert_eq!(&request.to_querystring(), "?pinned=1&limit=10");
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
pub fn to_querystring(&self) -> String { |
|
|
|
pub fn to_querystring(&self) -> String { |
|
|
|
let mut opts = vec![]; |
|
|
|
let mut opts = vec![]; |
|
|
|
|
|
|
|
|
|
|
|