use of org.dataportabilityproject.serviceProviders.smugmug.model.SmugMugAlbum in project data-transfer-project by google.
the class SmugMugPhotoService method getAlbums.
private PhotosModelWrapper getAlbums(Optional<PaginationInformation> paginationInformation) throws IOException {
String albumUri;
if (paginationInformation.isPresent()) {
albumUri = ((StringPaginationToken) paginationInformation.get()).getId();
} else {
SmugMugResponse<SmugMugUserResponse> userResponse = makeUserRequest(USER_URL);
albumUri = userResponse.getResponse().getUser().getUris().get("UserAlbums").getUri();
}
List<PhotoAlbum> albums = new ArrayList<>();
List<Resource> resources = new ArrayList<>();
SmugMugResponse<SmugmugAlbumsResponse> albumResponse = makeAlbumRequest(albumUri);
for (SmugMugAlbum album : albumResponse.getResponse().getAlbums()) {
albums.add(new PhotoAlbum(album.getAlbumKey(), album.getTitle(), album.getDescription()));
resources.add(new IdOnlyResource(album.getAlbumKey()));
}
StringPaginationToken pageToken = null;
if (albumResponse.getResponse().getPageInfo() != null && albumResponse.getResponse().getPageInfo().getNextPage() != null) {
pageToken = new StringPaginationToken(albumResponse.getResponse().getPageInfo().getNextPage());
}
return new PhotosModelWrapper(albums, null, new ContinuationInformation(resources, pageToken));
}
Aggregations