use of org.datatransferproject.transfer.instagram.photos.model.MediaFeedData in project data-transfer-project by google.
the class InstagramPhotoExporter method exportPhotos.
private ExportResult<PhotosContainerResource> exportPhotos(TokensAndUrlAuthData authData, Optional<PaginationData> pageData) {
Preconditions.checkNotNull(authData);
MediaResponse response;
try {
response = makeRequest(MEDIA_URL, MediaResponse.class, authData);
} catch (IOException e) {
return new ExportResult<>(e);
}
List<PhotoModel> photos = new ArrayList<>();
// TODO: check out paging.
for (MediaFeedData photo : response.getData()) {
// TODO json mapping is broken.
String photoId = photo.getId();
String url = photo.getImages().getStandardResolution().getUrl();
String text = (photo.getCaption() != null) ? photo.getCaption().getText() : null;
photos.add(new PhotoModel("Instagram photo: " + photoId, url, text, null, photoId, FAKE_ALBUM_ID, false));
}
List<PhotoAlbum> albums = new ArrayList<>();
if (!photos.isEmpty() && !pageData.isPresent()) {
albums.add(new PhotoAlbum(FAKE_ALBUM_ID, "Imported Instagram Photos", "Photos imported from instagram"));
}
return new ExportResult<>(ResultType.END, new PhotosContainerResource(albums, photos));
}
Aggregations