add get user profile photos action
-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
+ }
+}
