Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

SOCIALFB-140: added backdated_time field to album oject #168

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Album extends FacebookObject {

private int count;

private String coverPhoto;
private Photo coverPhoto;

private Date createdTime;

Expand All @@ -52,6 +52,8 @@ public class Album extends FacebookObject {

private Date updatedTime;

private Date backdatedTime;

public String getId() {
return id;
}
Expand All @@ -68,7 +70,7 @@ public int getCount() {
* The ID of the Photo object that is the cover photo for the album.
* @return A Photo object ID or null if the album does not have a cover photo
*/
public String getCoverPhoto() {
public Photo getCoverPhoto() {
return coverPhoto;
}

Expand Down Expand Up @@ -112,6 +114,10 @@ public Date getUpdatedTime() {
return updatedTime;
}

public Date getBackdatedTime() {
return backdatedTime;
}

public static enum Type { APP, COVER, PROFILE, MOBILE, WALL, NORMAL, ALBUM, UNKNOWN }

public static enum Privacy { EVERYONE, FRIENDS_OF_FRIENDS, FRIENDS, CUSTOM }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,6 @@ public interface GraphApi {
*/
String getApplicationNamespace();

static final String GRAPH_API_URL = "https://graph.facebook.com/v2.3/";
static final String GRAPH_API_URL = "https://graph.facebook.com/v2.4/";

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public PagedList<Album> getAlbums(String userId) {
return getAlbums(userId, new PagingParameters(25, 0, null, null));
}

public PagedList<Album> getAlbums(String userId, PagingParameters pagedListParameters) {
return graphApi.fetchConnections(userId, "albums", Album.class, getPagingParameters(pagedListParameters));
public PagedList<Album> getAlbums(String userId, PagingParameters pagingParameters) {
return graphApi.fetchConnections(userId, "albums", Album.class, pagingParameters.toMap(), ALBUM_FIELDS);
}

public Album getAlbum(String albumId) {
Expand Down Expand Up @@ -87,7 +87,7 @@ public PagedList<Photo> getPhotos(String objectId) {
}

public PagedList<Photo> getPhotos(String objectId, PagingParameters pagedListParameters) {
return graphApi.fetchConnections(objectId, "photos", Photo.class, getPagingParameters(pagedListParameters));
return graphApi.fetchConnections(objectId, "photos", Photo.class, getPagingParameters(pagedListParameters), PHOTO_FIELDS);
}

public Photo getPhoto(String photoId) {
Expand Down Expand Up @@ -175,4 +175,7 @@ public void tagVideo(String videoId, String userId) {
data.add("tag_uid", userId);
graphApi.publish(videoId, "tags", data);
}

private static final String PHOTO_FIELDS = "id,album,backdated_time,backdated_time_granularity,created_time,from,height,icon,images,link,name,page_story_id,place,picture,source,tags,updated_time,width";
private static final String ALBUM_FIELDS = "id,can_upload,count,cover_photo{" + PHOTO_FIELDS + "},created_time,from,link,name,privacy,type,updated_time,likes,comments,backdated_time";
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ abstract class AlbumMixin extends FacebookObjectMixin {
@JsonProperty("updated_time")
Date updatedTime;

@JsonProperty("backdated_time")
Date backdatedTime;

private static class TypeDeserializer extends JsonDeserializer<Type> {
@Override
public Type deserialize(JsonParser jp, DeserializationContext ctxt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class MediaTemplateTest extends AbstractFacebookApiTest {

@Test
public void getAlbums() {
mockServer.expect(requestTo(fbUrl("me/albums?offset=0&limit=25")))
mockServer.expect(requestTo(fbUrl("me/albums?limit=25&offset=0&fields=id%2Ccan_upload%2Ccount%2Ccover_photo%2Ccreated_time%2Cfrom%2Clink%2Cname%2Cprivacy%2Ctype%2Cupdated_time%2Clikes%2Ccomments%2Cbackdated_time")))
.andExpect(method(GET))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withSuccess(jsonResource("albums"), MediaType.APPLICATION_JSON));
Expand All @@ -42,7 +42,7 @@ public void getAlbums() {

@Test
public void getAlbums_forSpecificUser() {
mockServer.expect(requestTo(fbUrl("192837465/albums?offset=0&limit=25")))
mockServer.expect(requestTo(fbUrl("192837465/albums?limit=25&offset=0&fields=id%2Ccan_upload%2Ccount%2Ccover_photo%2Ccreated_time%2Cfrom%2Clink%2Cname%2Cprivacy%2Ctype%2Cupdated_time%2Clikes%2Ccomments%2Cbackdated_time")))
.andExpect(method(GET))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withSuccess(jsonResource("albums"), MediaType.APPLICATION_JSON));
Expand Down