Skip to content

Commit 2e7fced

Browse files
committed
Move getMemes() from Profile to User and change route
1 parent bb3f5f1 commit 2e7fced

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

src/main/java/me/memerator/api/object/Profile.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,6 @@ public int getNotificationCount() {
9898
return new JSONObject(MemeratorAPI.api.get("/notifications/count")).getInt("count");
9999
}
100100

101-
/**
102-
* @return a list of your memes
103-
*/
104-
public List<Meme> getMemes() {
105-
JSONArray response = new JSONArray(MemeratorAPI.api.get("/mymemes"));
106-
List<Meme> memes = new ArrayList<>();
107-
for(int i = 0; i < response.length(); i++) {
108-
memes.add(new Meme((JSONObject) response.get(i)));
109-
}
110-
return memes;
111-
}
112-
113101
/**
114102
* Returns as a UserIntegrations object, from there you can get each integration type.
115103
* @return the integrations.

src/main/java/me/memerator/api/object/User.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package me.memerator.api.object;
22

3+
import me.memerator.api.MemeratorAPI;
4+
import org.json.JSONArray;
35
import org.json.JSONObject;
46

57
import java.time.Instant;
8+
import java.util.ArrayList;
9+
import java.util.List;
610

711
public class User {
812
JSONObject values;
@@ -101,11 +105,22 @@ public String getJoinedAt() {
101105
return values.getString("joined");
102106
}
103107

104-
105108
/**
106109
* @return the user's join timestamp
107110
*/
108111
public Instant getJoinTimestamp() {
109112
return Instant.ofEpochSecond(values.getLong("joined_epoch_seconds"));
110113
}
114+
115+
/**
116+
* @return a list of this user's memes
117+
*/
118+
public List<Meme> getMemes() {
119+
JSONArray response = new JSONArray(MemeratorAPI.api.get("/profile/" + getId() + "/memes"));
120+
List<Meme> memes = new ArrayList<>();
121+
for(int i = 0; i < response.length(); i++) {
122+
memes.add(new Meme((JSONObject) response.get(i)));
123+
}
124+
return memes;
125+
}
111126
}

0 commit comments

Comments
 (0)