File tree Expand file tree Collapse file tree
library/src/main/java/com/proxerme/library Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .proxerme .library .connection .info .request ;
2+
3+ import android .support .annotation .NonNull ;
4+
5+ import com .proxerme .library .connection .ProxerResult ;
6+ import com .proxerme .library .connection .info .InfoRequest ;
7+ import com .proxerme .library .connection .info .result .SetUserInfoResult ;
8+ import com .proxerme .library .parameters .ViewStateParameter ;
9+ import com .squareup .moshi .Moshi ;
10+
11+ import java .io .IOException ;
12+
13+ import okhttp3 .ResponseBody ;
14+
15+ /**
16+ * Request to set the user view state of an anime or manga. See the list of possible user view states.
17+ *
18+ * @author Desnoo
19+ */
20+ public class SetUserInfoRequest extends InfoRequest <Void > {
21+
22+ private static final String ENDPOINT = "setuserinfo" ;
23+
24+ private String id ;
25+ private String type ;
26+
27+ /**
28+ * The Constructor.
29+ *
30+ * @param id The id of the anime/manga.
31+ * @param type The list type where the anime/manga should be add to.
32+ * See {@link com.proxerme.library.parameters.ViewStateParameter.ViewState} for parameters.
33+ */
34+ public SetUserInfoRequest (@ NonNull String id , @ ViewStateParameter .ViewState String type ) {
35+ this .id = id ;
36+ this .type = type ;
37+ }
38+
39+ @ Override
40+ protected ProxerResult <Void > parse (@ NonNull Moshi moshi , @ NonNull ResponseBody body ) throws IOException {
41+ return moshi .adapter (SetUserInfoResult .class ).fromJson (body .source ());
42+ }
43+
44+ @ NonNull
45+ @ Override
46+ protected String getApiEndpoint () {
47+ return ENDPOINT ;
48+ }
49+ }
Original file line number Diff line number Diff line change 1+ package com .proxerme .library .connection .info .result ;
2+
3+ import android .support .annotation .Nullable ;
4+
5+ import com .proxerme .library .connection .ProxerResult ;
6+ import com .proxerme .library .connection .info .request .SetUserInfoRequest ;
7+
8+ /**
9+ * The class that represents the result of {@link com.proxerme.library.connection.info.request.SetUserInfoRequest}.
10+ *
11+ * @author Desnoo
12+ */
13+ public class SetUserInfoResult extends ProxerResult <Void > {
14+
15+ protected SetUserInfoResult (){
16+ }
17+
18+ @ Override
19+ @ Nullable
20+ public Void getData () {
21+ return null ;
22+ }
23+ }
Original file line number Diff line number Diff line change 1+ package com .proxerme .library .parameters ;
2+
3+ import android .support .annotation .StringDef ;
4+
5+ import java .lang .annotation .ElementType ;
6+ import java .lang .annotation .Retention ;
7+ import java .lang .annotation .RetentionPolicy ;
8+ import java .lang .annotation .Target ;
9+
10+ /**
11+ * Class containing the possible view states of animes/mangas of an user.
12+ *
13+ * @author Desnoo
14+ */
15+ public class ViewStateParameter {
16+
17+ public static final String WATCHLIST = "note" ;
18+ public static final String FAVOURITE = "favor" ;
19+ public static final String FINISHED = "finish" ;
20+
21+ /**
22+ * An annotation that represents the possible view states.
23+ */
24+ @ StringDef ({WATCHLIST , FAVOURITE , FINISHED })
25+ @ Retention (value = RetentionPolicy .SOURCE )
26+ @ Target ({ElementType .METHOD , ElementType .FIELD , ElementType .PARAMETER })
27+ public @interface ViewState {
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments