Skip to content

Commit 784953e

Browse files
committed
Implement SetUnread
1 parent e88c9dd commit 784953e

8 files changed

Lines changed: 286 additions & 57 deletions

File tree

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

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,28 @@
55
import android.support.annotation.NonNull;
66

77
/**
8-
* The respone class used by {@link com.proxerme.library.connection.messenger.request.SetFavourRequest}
9-
* and GetFavour
8+
* This class is general class to match a simple request with an id.
9+
*
10+
* Use the this class with {@link com.proxerme.library.connection.messenger.request.SetFavourRequest},
11+
* {@link com.proxerme.library.connection.messenger.request.SetUnfavourRequest},
12+
* {@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}.
15+
*
1016
*
1117
* @author Desnoo
1218
*/
13-
public class Favour implements Parcelable {
19+
public class SetAction implements Parcelable {
1420

15-
public static final Creator<Favour> CREATOR = new Creator<Favour>() {
21+
public static final Creator<SetAction> CREATOR = new Creator<SetAction>() {
1622
@Override
17-
public Favour createFromParcel(Parcel in) {
18-
return new Favour(in);
23+
public SetAction createFromParcel(Parcel in) {
24+
return new SetAction(in);
1925
}
2026

2127
@Override
22-
public Favour[] newArray(int size) {
23-
return new Favour[size];
28+
public SetAction[] newArray(int size) {
29+
return new SetAction[size];
2430
}
2531
};
2632

@@ -31,7 +37,7 @@ public Favour[] newArray(int size) {
3137
*
3238
* @param status The status of the response of the request.
3339
*/
34-
public Favour(@NonNull String status) {
40+
public SetAction(@NonNull String status) {
3541
this.status = status;
3642
}
3743

@@ -40,15 +46,15 @@ public Favour(@NonNull String status) {
4046
*
4147
* @param in The parcel to parse.
4248
*/
43-
protected Favour(Parcel in) {
49+
protected SetAction(Parcel in) {
4450
status = in.readString();
4551
}
4652

4753

4854
/**
4955
* Get the status of the {@link com.proxerme.library.connection.messenger.request.SetFavourRequest}.
5056
*
51-
* @return A string containing the status of the favor request.
57+
* @return A string containing the status of a set request.
5258
*/
5359
@NonNull
5460
public String getStatus() {
@@ -71,9 +77,9 @@ public boolean equals(Object o) {
7177
if (this == o) return true;
7278
if (o == null || getClass() != o.getClass()) return false;
7379

74-
Favour favour = (Favour) o;
80+
SetAction setAction = (SetAction) o;
7581

76-
return status.equals(favour.status);
82+
return status.equals(setAction.status);
7783

7884
}
7985

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 SetBlockRequest. Use this to block a conference.
15+
*
16+
* @author Desnoo
17+
*/
18+
public class SetBlockRequest extends ProxerRequest<SetActionResult> {
19+
20+
private static final String SET_BLOCK_URL = "/api/v1/messenger/setblock";
21+
private static final String CONFERENCE_ID = "conference_id";
22+
23+
private String conferenceId;
24+
25+
26+
/**
27+
* Package constructor.
28+
*/
29+
SetBlockRequest() {
30+
}
31+
32+
/**
33+
* The constructor.
34+
*
35+
* @param conferenceId The conference id of the conference to block.
36+
*/
37+
public SetBlockRequest(@NonNull String conferenceId) {
38+
this.conferenceId = conferenceId;
39+
}
40+
41+
/**
42+
* Returns the id of the conference.
43+
*
44+
* @return The conference id.
45+
*/
46+
@NonNull
47+
public String getConferenceId() {
48+
return conferenceId;
49+
}
50+
51+
@Override
52+
protected int getTag() {
53+
return ProxerTag.MESSENGER_SET_UNFAVOUR;
54+
}
55+
56+
@Override
57+
protected SetActionResult parse(@NonNull Response response) throws Exception {
58+
return response.asClass(SetActionResult.class);
59+
}
60+
61+
@NonNull
62+
@Override
63+
protected String getURL() {
64+
return ProxerUrlHolder.getHost() + SET_BLOCK_URL;
65+
}
66+
67+
@Nullable
68+
@Override
69+
protected Form getBody() {
70+
return new Form()
71+
.add(CONFERENCE_ID, conferenceId);
72+
}
73+
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.afollestad.bridge.Form;
77
import com.afollestad.bridge.Response;
88
import com.proxerme.library.connection.ProxerRequest;
9-
import com.proxerme.library.connection.messenger.result.FavourResult;
9+
import com.proxerme.library.connection.messenger.result.SetActionResult;
1010
import com.proxerme.library.info.ProxerTag;
1111
import com.proxerme.library.info.ProxerUrlHolder;
1212

@@ -15,7 +15,7 @@
1515
*
1616
* @author Desnoo
1717
*/
18-
public class SetFavourRequest extends ProxerRequest<FavourResult> {
18+
public class SetFavourRequest extends ProxerRequest<SetActionResult> {
1919

2020
private static final String SET_FAVOUR_URL = "/api/v1/messenger/setfavour";
2121
private static final String CONFERENCE_ID = "conference_id";
@@ -54,8 +54,8 @@ protected int getTag() {
5454
}
5555

5656
@Override
57-
protected FavourResult parse(@NonNull Response response) throws Exception {
58-
return response.asClass(FavourResult.class);
57+
protected SetActionResult parse(@NonNull Response response) throws Exception {
58+
return response.asClass(SetActionResult.class);
5959
}
6060

6161
@NonNull
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 SetUnblockRequest. Use this to unblock a conference.
15+
*
16+
* @author Desnoo
17+
*/
18+
public class SetUnblockRequest extends ProxerRequest<SetActionResult> {
19+
20+
private static final String SET_UNBLOCK_URL = "/api/v1/messenger/setunblock";
21+
private static final String CONFERENCE_ID = "conference_id";
22+
23+
private String conferenceId;
24+
25+
26+
/**
27+
* Package constructor.
28+
*/
29+
SetUnblockRequest() {
30+
}
31+
32+
/**
33+
* The constructor.
34+
*
35+
* @param conferenceId The conference id of the conference to unblock.
36+
*/
37+
public SetUnblockRequest(@NonNull String conferenceId) {
38+
this.conferenceId = conferenceId;
39+
}
40+
41+
/**
42+
* Returns the id of the conference.
43+
*
44+
* @return The conference id.
45+
*/
46+
@NonNull
47+
public String getConferenceId() {
48+
return conferenceId;
49+
}
50+
51+
@Override
52+
protected int getTag() {
53+
return ProxerTag.MESSENGER_SET_UNFAVOUR;
54+
}
55+
56+
@Override
57+
protected SetActionResult parse(@NonNull Response response) throws Exception {
58+
return response.asClass(SetActionResult.class);
59+
}
60+
61+
@NonNull
62+
@Override
63+
protected String getURL() {
64+
return ProxerUrlHolder.getHost() + SET_UNBLOCK_URL;
65+
}
66+
67+
@Nullable
68+
@Override
69+
protected Form getBody() {
70+
return new Form()
71+
.add(CONFERENCE_ID, conferenceId);
72+
}
73+
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.afollestad.bridge.Form;
77
import com.afollestad.bridge.Response;
88
import com.proxerme.library.connection.ProxerRequest;
9-
import com.proxerme.library.connection.messenger.result.FavourResult;
9+
import com.proxerme.library.connection.messenger.result.SetActionResult;
1010
import com.proxerme.library.info.ProxerTag;
1111
import com.proxerme.library.info.ProxerUrlHolder;
1212

@@ -16,7 +16,7 @@
1616
*
1717
* @author Desnoo
1818
*/
19-
public class SetUnfavourRequest extends ProxerRequest<FavourResult> {
19+
public class SetUnfavourRequest extends ProxerRequest<SetActionResult> {
2020

2121
private static final String SET_UNFAVOUR_URL = "/api/v1/messenger/setunfavour";
2222
private static final String CONFERENCE_ID = "conference_id";
@@ -54,8 +54,8 @@ protected int getTag() {
5454
}
5555

5656
@Override
57-
protected FavourResult parse(@NonNull Response response) throws Exception {
58-
return response.asClass(FavourResult.class);
57+
protected SetActionResult parse(@NonNull Response response) throws Exception {
58+
return response.asClass(SetActionResult.class);
5959
}
6060

6161
@NonNull
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 SetUnreadRequest. Use this to mark a conference as not read.
15+
*
16+
* @author Desnoo
17+
*/
18+
public class SetUnreadRequest extends ProxerRequest<SetActionResult> {
19+
20+
private static final String SET_UNREAD_URL = "/api/v1/messenger/setunread";
21+
private static final String CONFERENCE_ID = "conference_id";
22+
23+
private String conferenceId;
24+
25+
26+
/**
27+
* Package constructor.
28+
*/
29+
SetUnreadRequest() {
30+
}
31+
32+
/**
33+
* The constructor.
34+
*
35+
* @param conferenceId The conference id of the conference to mark as unread.
36+
*/
37+
public SetUnreadRequest(@NonNull String conferenceId) {
38+
this.conferenceId = conferenceId;
39+
}
40+
41+
/**
42+
* Returns the id of the conference.
43+
*
44+
* @return The conference id.
45+
*/
46+
@NonNull
47+
public String getConferenceId() {
48+
return conferenceId;
49+
}
50+
51+
@Override
52+
protected int getTag() {
53+
return ProxerTag.MESSENGER_SET_UNFAVOUR;
54+
}
55+
56+
@Override
57+
protected SetActionResult parse(@NonNull Response response) throws Exception {
58+
return response.asClass(SetActionResult.class);
59+
}
60+
61+
@NonNull
62+
@Override
63+
protected String getURL() {
64+
return ProxerUrlHolder.getHost() + SET_UNREAD_URL;
65+
}
66+
67+
@Nullable
68+
@Override
69+
protected Form getBody() {
70+
return new Form()
71+
.add(CONFERENCE_ID, conferenceId);
72+
}
73+
}

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

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)