|
| 1 | +package com.proxerme.library.connection.ucp.request; |
| 2 | + |
| 3 | +import android.support.annotation.NonNull; |
| 4 | +import android.support.annotation.Nullable; |
| 5 | + |
| 6 | +import com.proxerme.library.connection.ProxerResult; |
| 7 | +import com.proxerme.library.connection.ucp.UcpRequest; |
| 8 | +import com.proxerme.library.connection.ucp.result.DeleteFavoriteResult; |
| 9 | +import com.squareup.moshi.Moshi; |
| 10 | + |
| 11 | +import java.io.IOException; |
| 12 | + |
| 13 | +import okhttp3.FormBody; |
| 14 | +import okhttp3.RequestBody; |
| 15 | +import okhttp3.ResponseBody; |
| 16 | + |
| 17 | +/** |
| 18 | + * Deletes the {@link com.proxerme.library.connection.ucp.entitiy.UcpToptenEntity} (specified |
| 19 | + * through the id in the constructor) from the list of the user. The user needs to be logged in for |
| 20 | + * this API. |
| 21 | + * |
| 22 | + * @author Ruben Gees |
| 23 | + */ |
| 24 | +public class DeleteFavoriteRequest extends UcpRequest<Void> { |
| 25 | + |
| 26 | + private static final String ENDPOINT = "deletetopten"; |
| 27 | + |
| 28 | + private static final String ID_PARAMETER = "id"; |
| 29 | + |
| 30 | + private String id; |
| 31 | + |
| 32 | + /** |
| 33 | + * The constructor. |
| 34 | + * |
| 35 | + * @param id The id of the reminder to delete. |
| 36 | + */ |
| 37 | + public DeleteFavoriteRequest(@NonNull String id) { |
| 38 | + this.id = id; |
| 39 | + } |
| 40 | + |
| 41 | + @Override |
| 42 | + protected ProxerResult<Void> parse(@NonNull Moshi moshi, @NonNull ResponseBody body) |
| 43 | + throws IOException { |
| 44 | + return moshi.adapter(DeleteFavoriteResult.class).fromJson(body.source()); |
| 45 | + } |
| 46 | + |
| 47 | + @NonNull |
| 48 | + @Override |
| 49 | + protected String getApiEndpoint() { |
| 50 | + return ENDPOINT; |
| 51 | + } |
| 52 | + |
| 53 | + @Override |
| 54 | + protected String getMethod() { |
| 55 | + return POST; |
| 56 | + } |
| 57 | + |
| 58 | + @Nullable |
| 59 | + @Override |
| 60 | + protected RequestBody getRequestBody() { |
| 61 | + return new FormBody.Builder() |
| 62 | + .add(ID_PARAMETER, id) |
| 63 | + .build(); |
| 64 | + } |
| 65 | +} |
0 commit comments