File tree Expand file tree Collapse file tree
main/java/me/proxer/library/api/ucp
test/java/me/proxer/library/api/ucp Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package me .proxer .library .api .ucp ;
2+
3+ import lombok .experimental .Accessors ;
4+ import me .proxer .library .api .Endpoint ;
5+ import me .proxer .library .api .ProxerCall ;
6+
7+ /**
8+ * Endpoint for deleting a comment. Does also delete the associated {link {@link me.proxer.library.entity.info.Entry}}
9+ * from the list of the user.
10+ *
11+ * @author Ruben Gees
12+ */
13+ @ Accessors (fluent = true )
14+ public final class DeleteCommentEndpoint implements Endpoint <Void > {
15+
16+ private final InternalApi internalApi ;
17+
18+ private final String id ;
19+
20+ DeleteCommentEndpoint (final InternalApi internalApi , final String id ) {
21+ this .internalApi = internalApi ;
22+ this .id = id ;
23+ }
24+
25+ /**
26+ * {@inheritDoc}
27+ */
28+ @ Override
29+ public ProxerCall <Void > build () {
30+ return internalApi .deleteComment (id );
31+ }
32+ }
Original file line number Diff line number Diff line change 99import me .proxer .library .enums .MediaLanguage ;
1010import me .proxer .library .enums .UserMediaListFilterType ;
1111import me .proxer .library .enums .UserMediaListSortCriteria ;
12- import retrofit2 .http .Field ;
13- import retrofit2 .http .FormUrlEncoded ;
14- import retrofit2 .http .GET ;
15- import retrofit2 .http .POST ;
16- import retrofit2 .http .Query ;
12+ import retrofit2 .http .*;
1713
1814import javax .annotation .ParametersAreNullableByDefault ;
1915import java .util .List ;
@@ -32,6 +28,10 @@ interface InternalApi {
3228 @ POST ("ucp/deletereminder" )
3329 ProxerCall <Void > deleteBookmark (@ Field ("id" ) String id );
3430
31+ @ FormUrlEncoded
32+ @ POST ("ucp/deletecomment" )
33+ ProxerCall <Void > deleteComment (@ Field ("id" ) String id );
34+
3535 @ GET ("ucp/listsum" )
3636 ProxerCall <Integer > watchedEpisodes ();
3737
Original file line number Diff line number Diff line change @@ -34,6 +34,13 @@ public DeleteBookmarkEndpoint deleteBookmark(final String id) {
3434 return new DeleteBookmarkEndpoint (internalApi , id );
3535 }
3636
37+ /**
38+ * Returns the respective endpoint.
39+ */
40+ public DeleteCommentEndpoint deleteComment (final String id ) {
41+ return new DeleteCommentEndpoint (internalApi , id );
42+ }
43+
3744 /**
3845 * Returns the respective endpoint.
3946 */
Original file line number Diff line number Diff line change 1+ package me .proxer .library .api .ucp ;
2+
3+ import me .proxer .library .ProxerTest ;
4+ import me .proxer .library .api .ProxerException ;
5+ import okhttp3 .mockwebserver .MockResponse ;
6+ import org .junit .Test ;
7+
8+ import java .io .IOException ;
9+
10+ import static org .assertj .core .api .Assertions .assertThat ;
11+
12+ /**
13+ * @author Ruben Gees
14+ */
15+ public class DeleteCommentEndpointTest extends ProxerTest {
16+
17+ @ Test
18+ public void testDefault () throws ProxerException , IOException {
19+ server .enqueue (new MockResponse ().setBody (fromResource ("empty.json" )));
20+
21+ final Void result = api .ucp ()
22+ .deleteComment ("123" )
23+ .build ()
24+ .execute ();
25+
26+ assertThat (result ).isNull ();
27+ }
28+
29+ @ Test
30+ public void testPath () throws ProxerException , IOException , InterruptedException {
31+ server .enqueue (new MockResponse ().setBody (fromResource ("empty.json" )));
32+
33+ api .ucp ().deleteComment ("321" )
34+ .build ()
35+ .execute ();
36+
37+ assertThat (server .takeRequest ().getPath ()).isEqualTo ("/api/v1/ucp/deletecomment" );
38+ }
39+
40+ @ Test
41+ public void testParameter () throws IOException , ProxerException , InterruptedException {
42+ server .enqueue (new MockResponse ().setBody (fromResource ("empty.json" )));
43+
44+ api .ucp ().deleteComment ("321" )
45+ .build ()
46+ .execute ();
47+
48+ assertThat (server .takeRequest ().getBody ().readUtf8 ()).isEqualTo ("id=321" );
49+ }
50+ }
You can’t perform that action at this time.
0 commit comments