Skip to content

Commit 4040ddc

Browse files
committed
Add Tags of SetRequests. Add report request.
Forgot to add the tags previously, so they are added in here.
1 parent 784953e commit 4040ddc

7 files changed

Lines changed: 103 additions & 8 deletions

File tree

library/src/main/java/com/proxerme/library/connection/messenger/entity/SetAction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
* Use the this class with {@link com.proxerme.library.connection.messenger.request.SetFavourRequest},
1111
* {@link com.proxerme.library.connection.messenger.request.SetUnfavourRequest},
1212
* {@link com.proxerme.library.connection.messenger.request.SetBlockRequest},
13-
* {@link com.proxerme.library.connection.messenger.request.SetUnblockRequest} or
14-
* {@link com.proxerme.library.connection.messenger.request.SetUnreadRequest}.
13+
* {@link com.proxerme.library.connection.messenger.request.SetUnblockRequest},
14+
* {@link com.proxerme.library.connection.messenger.request.SetUnreadRequest} or
15+
* {@link com.proxerme.library.connection.messenger.request.SetReportRequest}.
1516
*
1617
*
1718
* @author Desnoo

library/src/main/java/com/proxerme/library/connection/messenger/request/SetBlockRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public String getConferenceId() {
5050

5151
@Override
5252
protected int getTag() {
53-
return ProxerTag.MESSENGER_SET_UNFAVOUR;
53+
return ProxerTag.MESSENGER_SET_BLOCK;
5454
}
5555

5656
@Override
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package com.proxerme.library.connection.messenger.request;
2+
3+
import android.support.annotation.NonNull;
4+
import android.support.annotation.Nullable;
5+
6+
import com.afollestad.bridge.Form;
7+
import com.afollestad.bridge.Response;
8+
import com.proxerme.library.connection.ProxerRequest;
9+
import com.proxerme.library.connection.messenger.result.SetActionResult;
10+
import com.proxerme.library.info.ProxerTag;
11+
import com.proxerme.library.info.ProxerUrlHolder;
12+
13+
/**
14+
* The class that represents the SetReportRequest. Use this to report a conference with a reason.
15+
*
16+
* @author Desnoo
17+
*/
18+
public class SetReportRequest extends ProxerRequest<SetActionResult> {
19+
20+
private static final String SET_REPORT_URL = "/api/v1/messenger/report";
21+
private static final String CONFERENCE_ID = "conference_id";
22+
private static final String REASON = "text";
23+
24+
private String conferenceId;
25+
private String reason;
26+
27+
/**
28+
* Package constructor.
29+
*/
30+
SetReportRequest() {
31+
}
32+
33+
/**
34+
* The constructor.
35+
*
36+
* @param conferenceId The conference id of the conference to mark as unread.
37+
* @param reason The reason for the report.
38+
*/
39+
public SetReportRequest(@NonNull String conferenceId, @NonNull String reason) {
40+
this.conferenceId = conferenceId;
41+
this.reason = reason;
42+
}
43+
44+
/**
45+
* Returns the id of the conference.
46+
*
47+
* @return The conference id.
48+
*/
49+
@NonNull
50+
public String getConferenceId() {
51+
return conferenceId;
52+
}
53+
54+
/**
55+
* Returns the Reason.
56+
*
57+
* @return The Reason.
58+
**/
59+
@NonNull
60+
public String getReason() {
61+
return reason;
62+
}
63+
64+
@Override
65+
protected int getTag() {
66+
return ProxerTag.MESSENGER_SET_REPORT;
67+
}
68+
69+
@Override
70+
protected SetActionResult parse(@NonNull Response response) throws Exception {
71+
return response.asClass(SetActionResult.class);
72+
}
73+
74+
@NonNull
75+
@Override
76+
protected String getURL() {
77+
return ProxerUrlHolder.getHost() + SET_REPORT_URL;
78+
}
79+
80+
@Nullable
81+
@Override
82+
protected Form getBody() {
83+
return new Form()
84+
.add(CONFERENCE_ID, conferenceId)
85+
.add(REASON, reason);
86+
}
87+
}

library/src/main/java/com/proxerme/library/connection/messenger/request/SetUnblockRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public String getConferenceId() {
5050

5151
@Override
5252
protected int getTag() {
53-
return ProxerTag.MESSENGER_SET_UNFAVOUR;
53+
return ProxerTag.MESSENGER_SET_UNBLOCK;
5454
}
5555

5656
@Override

library/src/main/java/com/proxerme/library/connection/messenger/request/SetUnreadRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public String getConferenceId() {
5050

5151
@Override
5252
protected int getTag() {
53-
return ProxerTag.MESSENGER_SET_UNFAVOUR;
53+
return ProxerTag.MESSENGER_SET_UNREAD;
5454
}
5555

5656
@Override

library/src/main/java/com/proxerme/library/connection/messenger/result/SetActionResult.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
* The result of {@link com.proxerme.library.connection.messenger.request.SetFavourRequest},
1111
* {@link com.proxerme.library.connection.messenger.request.SetUnfavourRequest},
1212
* {@link com.proxerme.library.connection.messenger.request.SetBlockRequest},
13-
* {@link com.proxerme.library.connection.messenger.request.SetUnblockRequest} or
14-
* {@link com.proxerme.library.connection.messenger.request.SetUnreadRequest}.
13+
* {@link com.proxerme.library.connection.messenger.request.SetUnblockRequest}
14+
* {@link com.proxerme.library.connection.messenger.request.SetUnreadRequest} or
15+
* {@link com.proxerme.library.connection.messenger.request.SetReportRequest}.
1516
*
1617
* @author Desnoo
1718
*/

library/src/main/java/com/proxerme/library/info/ProxerTag.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,20 @@ public class ProxerTag {
3535
public static final int MESSENGER_CONFERENCE_INFO = 54;
3636
public static final int MESSENGER_SET_FAVOUR = 55;
3737
public static final int MESSENGER_SET_UNFAVOUR = 56;
38+
public static final int MESSENGER_SET_BLOCK = 57;
39+
public static final int MESSENGER_SET_UNBLOCK = 58;
40+
public static final int MESSENGER_SET_UNREAD = 59;
41+
public static final int MESSENGER_SET_REPORT = 60;
3842

3943
/**
4044
* An annotation representing all the different tags.
4145
*/
4246
@IntDef({LOGIN, NEWS, LOGOUT, USER_INFO, USER_TOPTEN, USER_MEDIA_LIST, MEDIA_LIST, MEDIA_SEARCH,
4347
INFO_ENTRY_CORE, INFO_ENTRY_SYNONYM, INFO_ENTRY_SEASON, MESSENGER_CONFERENCES,
4448
MESSENGER_MESSAGES, MESSENGER_SEND_MESSAGE, MESSENGER_CONFERENCE_CONSTANTS,
45-
MESSENGER_CONFERENCE_INFO, MESSENGER_SET_FAVOUR, MESSENGER_SET_UNFAVOUR})
49+
MESSENGER_CONFERENCE_INFO, MESSENGER_SET_FAVOUR, MESSENGER_SET_UNFAVOUR,
50+
MESSENGER_CONFERENCE_INFO, MESSENGER_SET_FAVOUR, MESSENGER_SET_UNFAVOUR, MESSENGER_SET_BLOCK,
51+
MESSENGER_SET_UNBLOCK, MESSENGER_SET_UNREAD, MESSENGER_SET_REPORT})
4652
@Retention(RetentionPolicy.SOURCE)
4753
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
4854
public @interface ConnectionTag {

0 commit comments

Comments
 (0)