Skip to content

Commit aaa4027

Browse files
committed
Implement DeleteFavoriteRequest
1 parent 1b1c6c5 commit aaa4027

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.proxerme.library.connection.ucp.result;
2+
3+
import android.support.annotation.Nullable;
4+
5+
import com.proxerme.library.connection.ProxerResult;
6+
7+
/**
8+
* {@inheritDoc}
9+
*/
10+
public class DeleteFavoriteResult extends ProxerResult<Void> {
11+
12+
protected DeleteFavoriteResult() {
13+
}
14+
15+
@Override
16+
@Nullable
17+
public Void getData() {
18+
return null;
19+
}
20+
}

0 commit comments

Comments
 (0)