mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 09:49:07 +01:00
add get user profile photos action
This commit is contained in:
parent
a447c26837
commit
c3f543786d
1 changed files with 46 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::requests::RequestContext;
|
||||
use crate::network;
|
||||
use crate::requests::{Request, RequestContext, RequestFuture, ResponseResult};
|
||||
use crate::types::UserProfilePhotos;
|
||||
|
||||
//TODO: complete implementation after user_profile_fotos will be added to
|
||||
// types/mod.rs
|
||||
///Use this method to get a list of profile pictures for a user. Returns a
|
||||
/// UserProfilePhotos object.
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
|
@ -17,3 +17,46 @@ pub struct GetUserProfilePhotos<'a> {
|
|||
/// accepted. Defaults to 100.
|
||||
limit: Option<i64>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> for GetUserProfilePhotos<'a> {
|
||||
type ReturnValue = UserProfilePhotos;
|
||||
|
||||
fn send(self) -> RequestFuture<'a, ResponseResult<Self::ReturnValue>> {
|
||||
Box::pin(async move {
|
||||
network::request_json(
|
||||
&self.ctx.client,
|
||||
&self.ctx.token,
|
||||
"getUserProfilePhotos",
|
||||
&self,
|
||||
)
|
||||
.await
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> GetUserProfilePhotos<'a> {
|
||||
pub fn new(ctx: RequestContext<'a>, user_id: i32) -> Self {
|
||||
Self {
|
||||
ctx,
|
||||
user_id,
|
||||
offset: None,
|
||||
limit: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn user_id<T>(mut self, user_id: T) -> Self
|
||||
where
|
||||
T: Into<i32>,
|
||||
{
|
||||
self.user_id = user_id.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn offset<T>(mut self, offset: T) -> Self
|
||||
where
|
||||
T: Into<i64>,
|
||||
{
|
||||
self.offset = Some(offset.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue