Search in sources :

Example 1 with MediaFeedData

use of org.dataportabilityproject.serviceProviders.instagram.model.MediaFeedData 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);
}
Also used : MediaResponse(org.dataportabilityproject.serviceProviders.instagram.model.MediaResponse) PhotoModel(org.dataportabilityproject.dataModels.photos.PhotoModel) ArrayList(java.util.ArrayList) PhotosModelWrapper(org.dataportabilityproject.dataModels.photos.PhotosModelWrapper) MediaFeedData(org.dataportabilityproject.serviceProviders.instagram.model.MediaFeedData) PhotoAlbum(org.dataportabilityproject.dataModels.photos.PhotoAlbum)

Aggregations

ArrayList (java.util.ArrayList)1 PhotoAlbum (org.dataportabilityproject.dataModels.photos.PhotoAlbum)1 PhotoModel (org.dataportabilityproject.dataModels.photos.PhotoModel)1 PhotosModelWrapper (org.dataportabilityproject.dataModels.photos.PhotosModelWrapper)1 MediaFeedData (org.dataportabilityproject.serviceProviders.instagram.model.MediaFeedData)1 MediaResponse (org.dataportabilityproject.serviceProviders.instagram.model.MediaResponse)1