use of org.dataportabilityproject.serviceProviders.instagram.model.MediaResponse in project data-transfer-project by google.
the class InstagramPhotoService method export.
@Override
public PhotosModelWrapper export(ExportInformation exportInformation) throws IOException {
MediaResponse response = makeRequest("https://api.instagram.com/v1/users/self/media/recent", MediaResponse.class);
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, FAKE_ALBUM_ID));
}
List<PhotoAlbum> albums = new ArrayList<>();
if (!photos.isEmpty() && !exportInformation.getPaginationInformation().isPresent()) {
albums.add(new PhotoAlbum(FAKE_ALBUM_ID, "Imported Instagram Photos", "Photos imported from instagram"));
}
return new PhotosModelWrapper(albums, photos, null);
}
Aggregations