Search in sources :

Example 1 with GpodnetUploadChangesResponse

use of de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetUploadChangesResponse in project AntennaPod by AntennaPod.

the class NextcloudSyncService method uploadSubscriptionChanges.

@Override
public UploadChangesResponse uploadSubscriptionChanges(List<String> addedFeeds, List<String> removedFeeds) throws NextcloudSynchronizationServiceException {
    try {
        HttpUrl.Builder url = makeUrl("/index.php/apps/gpoddersync/subscription_change/create");
        final JSONObject requestObject = new JSONObject();
        requestObject.put("add", new JSONArray(addedFeeds));
        requestObject.put("remove", new JSONArray(removedFeeds));
        RequestBody requestBody = RequestBody.create(MediaType.get("application/json"), requestObject.toString());
        performRequest(url, "POST", requestBody);
    } catch (Exception e) {
        e.printStackTrace();
        throw new NextcloudSynchronizationServiceException(e);
    }
    return new GpodnetUploadChangesResponse(System.currentTimeMillis() / 1000, new HashMap<>());
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) GpodnetUploadChangesResponse(de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetUploadChangesResponse) HttpUrl(okhttp3.HttpUrl) SyncServiceException(de.danoeh.antennapod.net.sync.model.SyncServiceException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) JSONException(org.json.JSONException) RequestBody(okhttp3.RequestBody)

Example 2 with GpodnetUploadChangesResponse

use of de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetUploadChangesResponse in project AntennaPod by AntennaPod.

the class GpodnetService method uploadEpisodeActions.

/**
 * Updates the episode actions
 * <p/>
 * This method requires authentication.
 *
 * @param episodeActions Collection of episode actions.
 * @return a GpodnetUploadChangesResponse. See {@link GpodnetUploadChangesResponse}
 * for details.
 * @throws GpodnetServiceException            if added or removed contain duplicates or if there
 *                                            is an authentication error.
 */
@Override
public UploadChangesResponse uploadEpisodeActions(List<EpisodeAction> episodeActions) throws SyncServiceException {
    requireLoggedIn();
    UploadChangesResponse response = null;
    for (int i = 0; i < episodeActions.size(); i += UPLOAD_BULK_SIZE) {
        response = uploadEpisodeActionsPartial(episodeActions, i, Math.min(episodeActions.size(), i + UPLOAD_BULK_SIZE));
    }
    return response;
}
Also used : UploadChangesResponse(de.danoeh.antennapod.net.sync.model.UploadChangesResponse) GpodnetUploadChangesResponse(de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetUploadChangesResponse)

Aggregations

GpodnetUploadChangesResponse (de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetUploadChangesResponse)2 SyncServiceException (de.danoeh.antennapod.net.sync.model.SyncServiceException)1 UploadChangesResponse (de.danoeh.antennapod.net.sync.model.UploadChangesResponse)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 HttpUrl (okhttp3.HttpUrl)1 RequestBody (okhttp3.RequestBody)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1