Skip to content

Commit 4376352

Browse files
committed
Implement tag list api
1 parent 5b2beda commit 4376352

13 files changed

Lines changed: 296 additions & 5 deletions

File tree

library/src/main/java/me/proxer/library/api/list/InternalApi.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,11 @@ ProxerCall<List<IndustryProject>> industryProjectList(@Query("id") String id,
6969
@Query("isH") Integer includeHentai,
7070
@Query("p") Integer page,
7171
@Query("limit") Integer limit);
72+
73+
@GET("list/tags")
74+
ProxerCall<List<Tag>> tagList(@Query("search") String search,
75+
@Query("type") TagType type,
76+
@Query("sort") TagSortCriteria sort,
77+
@Query("sort_type") TagSortType sortType,
78+
@Query("subtype") TagSubType subType);
7279
}

library/src/main/java/me/proxer/library/api/list/ListApi.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,11 @@ public TranslatorGroupProjectListEndpoint translatorGroupProjectList(final Strin
5656
public IndustryProjectListEndpoint industryProjectList(final String industryId) {
5757
return new IndustryProjectListEndpoint(internalApi, industryId);
5858
}
59+
60+
/**
61+
* Returns the respective endpoint.
62+
*/
63+
public TagListEndpoint tagList() {
64+
return new TagListEndpoint(internalApi);
65+
}
5966
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package me.proxer.library.api.list;
2+
3+
import lombok.Setter;
4+
import lombok.experimental.Accessors;
5+
import me.proxer.library.api.Endpoint;
6+
import me.proxer.library.api.ProxerCall;
7+
import me.proxer.library.entity.list.Tag;
8+
import me.proxer.library.enums.TagSortCriteria;
9+
import me.proxer.library.enums.TagSubType;
10+
import me.proxer.library.enums.TagType;
11+
12+
import javax.annotation.Nullable;
13+
import java.util.List;
14+
15+
@Accessors(fluent = true)
16+
public final class TagListEndpoint implements Endpoint<List<Tag>> {
17+
18+
private final InternalApi internalApi;
19+
/**
20+
* Sets the name to search for.
21+
*/
22+
@Nullable
23+
@Setter
24+
private String name;
25+
/**
26+
* Sets the type to filter by.
27+
*/
28+
@Nullable
29+
@Setter
30+
private TagType type;
31+
/**
32+
* Sets the criteria to sort by.
33+
*/
34+
@Nullable
35+
@Setter
36+
private TagSortCriteria sortCriteria;
37+
/**
38+
* Sets the sub type to filter by.
39+
*/
40+
@Nullable
41+
@Setter
42+
private TagSubType subType;
43+
@Nullable
44+
private TagSortType sortType;
45+
46+
TagListEndpoint(final InternalApi internalApi) {
47+
this.internalApi = internalApi;
48+
}
49+
50+
/**
51+
* Sets the sort type to be ascending.
52+
*/
53+
public TagListEndpoint sortAscending() {
54+
sortType = TagSortType.ASCENDING;
55+
56+
return this;
57+
}
58+
59+
/**
60+
* Sets the sort type to be ascending.
61+
*/
62+
public TagListEndpoint sortDescending() {
63+
sortType = TagSortType.DESCENDING;
64+
65+
return this;
66+
}
67+
68+
@Override
69+
public ProxerCall<List<Tag>> build() {
70+
return internalApi.tagList(name, type, sortCriteria, sortType, subType);
71+
}
72+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package me.proxer.library.api.list;
2+
3+
import com.squareup.moshi.Json;
4+
5+
/**
6+
* @author Ruben Gees
7+
*/
8+
enum TagSortType {
9+
@Json(name = "ASC") ASCENDING,
10+
@Json(name = "DESC") DESCENDING
11+
}

library/src/main/java/me/proxer/library/entity/info/Entry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public class Entry implements ProxerIdItem {
147147
* Returns the tags.
148148
*/
149149
@Json(name = "tags")
150-
private List<Tag> tags;
150+
private List<InfoTag> tags;
151151

152152
/**
153153
* Returns the average of all ratings.

library/src/main/java/me/proxer/library/entity/info/Tag.java renamed to library/src/main/java/me/proxer/library/entity/info/InfoTag.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
import java.util.Date;
1212

1313
/**
14-
* Entity representing a single tag.
14+
* Entity representing a single tag in the context of an {@link Entry}.
1515
*
1616
* @author Ruben Gees
1717
*/
1818
@Value
1919
@EqualsAndHashCode(onParam = @__({@Nullable}))
20-
public class Tag implements ProxerIdItem, ProxerDateItem {
20+
public class InfoTag implements ProxerIdItem, ProxerDateItem {
2121

2222
/**
2323
* Returns the id of the associated entry.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package me.proxer.library.entity.list;
2+
3+
import com.squareup.moshi.Json;
4+
import lombok.EqualsAndHashCode;
5+
import lombok.Getter;
6+
import lombok.Value;
7+
import me.proxer.library.entity.ProxerIdItem;
8+
import me.proxer.library.enums.TagSubType;
9+
import me.proxer.library.enums.TagType;
10+
11+
import javax.annotation.Nullable;
12+
13+
/**
14+
* Entity representing a single tag.
15+
*
16+
* @author Ruben Gees
17+
*/
18+
@Value
19+
@EqualsAndHashCode(onParam = @__({@Nullable}))
20+
public class Tag implements ProxerIdItem {
21+
22+
/**
23+
* Returns the id.
24+
*/
25+
@Getter(onMethod = @__({@Override}))
26+
@Json(name = "id")
27+
private String id;
28+
29+
/**
30+
* Returns the type.
31+
*/
32+
@Json(name = "type")
33+
private TagType type;
34+
35+
/**
36+
* Returns the name.
37+
*/
38+
@Json(name = "tag")
39+
private String name;
40+
41+
/**
42+
* Returns the name.
43+
*/
44+
@Json(name = "description")
45+
private String description;
46+
47+
/**
48+
* Returns the type.
49+
*/
50+
@Json(name = "subtype")
51+
private TagSubType subType;
52+
53+
/**
54+
* Returns the type.
55+
*/
56+
@Json(name = "is_spoiler")
57+
private boolean isSpoiler;
58+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package me.proxer.library.enums;
2+
3+
import com.squareup.moshi.Json;
4+
5+
/**
6+
* Enum holding the available sort options of the tag search.
7+
*
8+
* @author Ruben Gees
9+
*/
10+
public enum TagSortCriteria {
11+
@Json(name = "id") ID,
12+
@Json(name = "type") TYPE,
13+
@Json(name = "tag") NAME,
14+
@Json(name = "description") DESCRIPTION,
15+
@Json(name = "subtype") SUBTYPE,
16+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package me.proxer.library.enums;
2+
3+
import com.squareup.moshi.Json;
4+
5+
/**
6+
* Enum holding the sub types of a {@link me.proxer.library.entity.list.Tag}.
7+
*
8+
* @author Ruben Gees
9+
*/
10+
public enum TagSubType {
11+
@Json(name = "misc") MISCELLANEOUS,
12+
@Json(name = "persoenlichkeiten") PERSONALITIES,
13+
@Json(name = "gefuehle") FEELINGS,
14+
@Json(name = "zeichnung") DRAWING,
15+
@Json(name = "uebernatuerliches") SUPERNATURAL,
16+
@Json(name = "sport") SPORT,
17+
@Json(name = "menschen") PEOPLE,
18+
@Json(name = "zukunft") FUTURE,
19+
@Json(name = "story") STORY,
20+
@Json(name = "prota") PROTAGONIST
21+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package me.proxer.library.enums;
2+
3+
import com.squareup.moshi.Json;
4+
5+
/**
6+
* Enum holding the types of a {@link me.proxer.library.entity.list.Tag}.
7+
*
8+
* @author Ruben Gees
9+
*/
10+
public enum TagType {
11+
@Json(name = "entry_genre") GENRE,
12+
@Json(name = "entry_tag") TAG,
13+
@Json(name = "entry_tag_h") H_TAG
14+
}

0 commit comments

Comments
 (0)