From 719f15be3ad467948455e4d856142db65b220876 Mon Sep 17 00:00:00 2001 From: Aaryn101 Date: Fri, 13 Dec 2013 21:32:29 -0700 Subject: [PATCH] API complete --- src/main/java/lol4j/client/Lol4JClient.java | 3 +- .../lol4j/client/impl/Lol4JClientImpl.java | 32 ++++ .../protocol/dto/stats/AggregatedStatDto.java | 2 + .../dto/summoner/MasteryPagesDto.java | 1 - .../lol4j/protocol/dto/summoner/RuneDto.java | 46 ++++++ .../protocol/dto/summoner/RunePageDto.java | 46 ++++++ .../protocol/dto/summoner/RunePagesDto.java | 28 ++++ .../protocol/dto/summoner/RuneSlotDto.java | 28 ++++ .../protocol/dto/summoner/SummonerDto.java | 66 ++++++++ .../dto/summoner/SummonerNameDto.java | 28 ++++ .../dto/summoner/SummonerNameListDto.java | 18 +++ .../dto/team/MatchHistorySummaryDto.java | 109 +++++++++++++ .../protocol/dto/team/MessageOfDayDto.java | 37 +++++ .../lol4j/protocol/dto/team/RosterDto.java | 28 ++++ .../java/lol4j/protocol/dto/team/TeamDto.java | 146 ++++++++++++++++++ .../lol4j/protocol/dto/team/TeamIdDto.java | 19 +++ .../protocol/dto/team/TeamMemberInfoDto.java | 48 ++++++ .../protocol/dto/team/TeamStatDetailDto.java | 82 ++++++++++ .../protocol/dto/team/TeamStatSummaryDto.java | 28 ++++ .../protocol/resource/ChampionResource.java | 3 +- .../lol4j/protocol/resource/GameResource.java | 3 +- .../protocol/resource/LeagueResource.java | 3 +- .../protocol/resource/StatsResource.java | 5 +- .../protocol/resource/SummonerResource.java | 16 +- .../lol4j/protocol/resource/TeamResource.java | 13 ++ .../resource/impl/AbstractResourceImpl.java | 7 +- .../resource/impl/ChampionResourceImpl.java | 15 +- .../resource/impl/GameResourceImpl.java | 11 +- .../resource/impl/LeagueResourceImpl.java | 13 +- .../resource/impl/ResourceFactory.java | 12 +- .../resource/impl/StatsResourceImpl.java | 41 ++--- .../resource/impl/SummonerResourceImpl.java | 62 +++++++- .../resource/impl/TeamResourceImpl.java | 34 ++++ .../lol4j/service/impl/ApiRequestManager.java | 17 +- 34 files changed, 974 insertions(+), 76 deletions(-) create mode 100644 src/main/java/lol4j/protocol/dto/summoner/RuneDto.java create mode 100644 src/main/java/lol4j/protocol/dto/summoner/RunePageDto.java create mode 100644 src/main/java/lol4j/protocol/dto/summoner/RunePagesDto.java create mode 100644 src/main/java/lol4j/protocol/dto/summoner/RuneSlotDto.java create mode 100644 src/main/java/lol4j/protocol/dto/summoner/SummonerDto.java create mode 100644 src/main/java/lol4j/protocol/dto/summoner/SummonerNameDto.java create mode 100644 src/main/java/lol4j/protocol/dto/summoner/SummonerNameListDto.java create mode 100644 src/main/java/lol4j/protocol/dto/team/MatchHistorySummaryDto.java create mode 100644 src/main/java/lol4j/protocol/dto/team/MessageOfDayDto.java create mode 100644 src/main/java/lol4j/protocol/dto/team/RosterDto.java create mode 100644 src/main/java/lol4j/protocol/dto/team/TeamDto.java create mode 100644 src/main/java/lol4j/protocol/dto/team/TeamIdDto.java create mode 100644 src/main/java/lol4j/protocol/dto/team/TeamMemberInfoDto.java create mode 100644 src/main/java/lol4j/protocol/dto/team/TeamStatDetailDto.java create mode 100644 src/main/java/lol4j/protocol/dto/team/TeamStatSummaryDto.java create mode 100644 src/main/java/lol4j/protocol/resource/TeamResource.java create mode 100644 src/main/java/lol4j/protocol/resource/impl/TeamResourceImpl.java diff --git a/src/main/java/lol4j/client/Lol4JClient.java b/src/main/java/lol4j/client/Lol4JClient.java index 2afbb3f..8693453 100644 --- a/src/main/java/lol4j/client/Lol4JClient.java +++ b/src/main/java/lol4j/client/Lol4JClient.java @@ -5,5 +5,6 @@ /** * Created by Aaryn101 on 12/10/13. */ -public interface Lol4JClient extends GameResource, ChampionResource, LeagueResource, StatsResource, SummonerResource { +public interface Lol4JClient extends GameResource, ChampionResource, LeagueResource, StatsResource, SummonerResource, + TeamResource { } diff --git a/src/main/java/lol4j/client/impl/Lol4JClientImpl.java b/src/main/java/lol4j/client/impl/Lol4JClientImpl.java index b8cac60..40e4d67 100644 --- a/src/main/java/lol4j/client/impl/Lol4JClientImpl.java +++ b/src/main/java/lol4j/client/impl/Lol4JClientImpl.java @@ -7,11 +7,16 @@ import lol4j.protocol.dto.stats.PlayerStatsSummaryListDto; import lol4j.protocol.dto.stats.RankedStatsDto; import lol4j.protocol.dto.summoner.MasteryPagesDto; +import lol4j.protocol.dto.summoner.RunePagesDto; +import lol4j.protocol.dto.summoner.SummonerDto; +import lol4j.protocol.dto.summoner.SummonerNameListDto; +import lol4j.protocol.dto.team.TeamDto; import lol4j.protocol.resource.*; import lol4j.protocol.resource.impl.ResourceFactory; import lol4j.util.Region; import lol4j.util.Season; +import java.util.List; import java.util.Map; /** @@ -23,6 +28,7 @@ public class Lol4JClientImpl implements Lol4JClient { private LeagueResource leagueResource; private StatsResource statsResource; private SummonerResource summonerResource; + private TeamResource teamResource; public Lol4JClientImpl(String apiKey) { ResourceFactory resourceFactory = new ResourceFactory(apiKey); @@ -32,6 +38,7 @@ public Lol4JClientImpl(String apiKey) { leagueResource = resourceFactory.createLeagueResource(); statsResource = resourceFactory.createStatsResource(); summonerResource = resourceFactory.createSummonerResource(); + teamResource = resourceFactory.createTeamResource(); } @Override @@ -63,4 +70,29 @@ public RankedStatsDto getRankedStats(Region region, long summonerId, Season seas public MasteryPagesDto getMasteryPages(Region region, long summonerId) { return summonerResource.getMasteryPages(region, summonerId); } + + @Override + public RunePagesDto getRunePages(Region region, long summonerId) { + return summonerResource.getRunePages(region, summonerId); + } + + @Override + public SummonerDto getSummoner(Region region, String name) { + return summonerResource.getSummoner(region, name); + } + + @Override + public SummonerDto getSummoner(Region region, long summonerId) { + return summonerResource.getSummoner(region, summonerId); + } + + @Override + public SummonerNameListDto getSummonerNames(Region region, List summonerIds) { + return summonerResource.getSummonerNames(region, summonerIds); + } + + @Override + public List getTeams(Region region, long summonerId) { + return teamResource.getTeams(region, summonerId); + } } diff --git a/src/main/java/lol4j/protocol/dto/stats/AggregatedStatDto.java b/src/main/java/lol4j/protocol/dto/stats/AggregatedStatDto.java index 7f82f09..892d6cf 100644 --- a/src/main/java/lol4j/protocol/dto/stats/AggregatedStatDto.java +++ b/src/main/java/lol4j/protocol/dto/stats/AggregatedStatDto.java @@ -1,12 +1,14 @@ package lol4j.protocol.dto.stats; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Created by Aaryn101 on 12/11/13. */ @JsonIgnoreProperties(ignoreUnknown = true) public class AggregatedStatDto { + @JsonProperty("c") private int count; private int id; private String name; diff --git a/src/main/java/lol4j/protocol/dto/summoner/MasteryPagesDto.java b/src/main/java/lol4j/protocol/dto/summoner/MasteryPagesDto.java index f36a66a..95d3def 100644 --- a/src/main/java/lol4j/protocol/dto/summoner/MasteryPagesDto.java +++ b/src/main/java/lol4j/protocol/dto/summoner/MasteryPagesDto.java @@ -18,7 +18,6 @@ public List getPages() { } public long getSummonerId() { - return summonerId; } diff --git a/src/main/java/lol4j/protocol/dto/summoner/RuneDto.java b/src/main/java/lol4j/protocol/dto/summoner/RuneDto.java new file mode 100644 index 0000000..20fa6b9 --- /dev/null +++ b/src/main/java/lol4j/protocol/dto/summoner/RuneDto.java @@ -0,0 +1,46 @@ +package lol4j.protocol.dto.summoner; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by Aaryn101 on 12/12/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class RuneDto { + private String description; + private int id; + private String name; + private int tier; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getTier() { + return tier; + } + + public void setTier(int tier) { + this.tier = tier; + } +} diff --git a/src/main/java/lol4j/protocol/dto/summoner/RunePageDto.java b/src/main/java/lol4j/protocol/dto/summoner/RunePageDto.java new file mode 100644 index 0000000..feb962b --- /dev/null +++ b/src/main/java/lol4j/protocol/dto/summoner/RunePageDto.java @@ -0,0 +1,46 @@ +package lol4j.protocol.dto.summoner; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Aaryn101 on 12/12/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class RunePageDto { + private boolean current; + private long id; + private String name; + private List slots = new ArrayList<>(); + + public List getSlots() { + return slots; + } + + public boolean isCurrent() { + + return current; + } + + public void setCurrent(boolean current) { + this.current = current; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/lol4j/protocol/dto/summoner/RunePagesDto.java b/src/main/java/lol4j/protocol/dto/summoner/RunePagesDto.java new file mode 100644 index 0000000..eb209e7 --- /dev/null +++ b/src/main/java/lol4j/protocol/dto/summoner/RunePagesDto.java @@ -0,0 +1,28 @@ +package lol4j.protocol.dto.summoner; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.HashSet; +import java.util.Set; + +/** + * Created by Aaryn101 on 12/12/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class RunePagesDto { + private Set pages = new HashSet<>(); + private long summonerId; + + public long getSummonerId() { + return summonerId; + } + + public void setSummonerId(long summonerId) { + this.summonerId = summonerId; + } + + public Set getPages() { + + return pages; + } +} diff --git a/src/main/java/lol4j/protocol/dto/summoner/RuneSlotDto.java b/src/main/java/lol4j/protocol/dto/summoner/RuneSlotDto.java new file mode 100644 index 0000000..bbbae45 --- /dev/null +++ b/src/main/java/lol4j/protocol/dto/summoner/RuneSlotDto.java @@ -0,0 +1,28 @@ +package lol4j.protocol.dto.summoner; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by Aaryn101 on 12/12/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class RuneSlotDto { + private RuneDto rune; + private int runeSlotId; + + public RuneDto getRune() { + return rune; + } + + public void setRune(RuneDto rune) { + this.rune = rune; + } + + public int getRuneSlotId() { + return runeSlotId; + } + + public void setRuneSlotId(int runeSlotId) { + this.runeSlotId = runeSlotId; + } +} diff --git a/src/main/java/lol4j/protocol/dto/summoner/SummonerDto.java b/src/main/java/lol4j/protocol/dto/summoner/SummonerDto.java new file mode 100644 index 0000000..1bf88f6 --- /dev/null +++ b/src/main/java/lol4j/protocol/dto/summoner/SummonerDto.java @@ -0,0 +1,66 @@ +package lol4j.protocol.dto.summoner; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +/** + * Created by Aaryn101 on 12/13/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class SummonerDto { + private long id; + private String name; + private int profileIconId; + private long revisionDate; + private Date revisionDateStr; + private long summonerLevel; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getProfileIconId() { + return profileIconId; + } + + public void setProfileIconId(int profileIconId) { + this.profileIconId = profileIconId; + } + + public long getRevisionDate() { + return revisionDate; + } + + public void setRevisionDate(long revisionDate) { + this.revisionDate = revisionDate; + } + + public Date getRevisionDateStr() { + return revisionDateStr; + } + + public void setRevisionDateStr(Date revisionDateStr) { + this.revisionDateStr = revisionDateStr; + } + + public long getSummonerLevel() { + return summonerLevel; + } + + public void setSummonerLevel(long summonerLevel) { + this.summonerLevel = summonerLevel; + } +} diff --git a/src/main/java/lol4j/protocol/dto/summoner/SummonerNameDto.java b/src/main/java/lol4j/protocol/dto/summoner/SummonerNameDto.java new file mode 100644 index 0000000..d760534 --- /dev/null +++ b/src/main/java/lol4j/protocol/dto/summoner/SummonerNameDto.java @@ -0,0 +1,28 @@ +package lol4j.protocol.dto.summoner; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by Aaryn101 on 12/13/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class SummonerNameDto { + private long id; + private String name; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/lol4j/protocol/dto/summoner/SummonerNameListDto.java b/src/main/java/lol4j/protocol/dto/summoner/SummonerNameListDto.java new file mode 100644 index 0000000..985b3d9 --- /dev/null +++ b/src/main/java/lol4j/protocol/dto/summoner/SummonerNameListDto.java @@ -0,0 +1,18 @@ +package lol4j.protocol.dto.summoner; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Aaryn101 on 12/13/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class SummonerNameListDto { + private List summoners = new ArrayList<>(); + + public List getSummoners() { + return summoners; + } +} diff --git a/src/main/java/lol4j/protocol/dto/team/MatchHistorySummaryDto.java b/src/main/java/lol4j/protocol/dto/team/MatchHistorySummaryDto.java new file mode 100644 index 0000000..c6b08ed --- /dev/null +++ b/src/main/java/lol4j/protocol/dto/team/MatchHistorySummaryDto.java @@ -0,0 +1,109 @@ +package lol4j.protocol.dto.team; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by Aaryn101 on 12/13/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class MatchHistorySummaryDto { + private int assists; + private long date; + private int deaths; + private long gameId; + private String gameMode; + private boolean invalid; + private int kills; + private int mapId; + private int opposingTeamKills; + private String opposingTeamName; + private boolean win; + + public int getAssists() { + return assists; + } + + public void setAssists(int assists) { + this.assists = assists; + } + + public long getDate() { + return date; + } + + public void setDate(long date) { + this.date = date; + } + + public int getDeaths() { + return deaths; + } + + public void setDeaths(int deaths) { + this.deaths = deaths; + } + + public long getGameId() { + return gameId; + } + + public void setGameId(long gameId) { + this.gameId = gameId; + } + + public String getGameMode() { + return gameMode; + } + + public void setGameMode(String gameMode) { + this.gameMode = gameMode; + } + + public boolean isInvalid() { + return invalid; + } + + public void setInvalid(boolean invalid) { + this.invalid = invalid; + } + + public int getKills() { + return kills; + } + + public void setKills(int kills) { + this.kills = kills; + } + + public int getMapId() { + return mapId; + } + + public void setMapId(int mapId) { + this.mapId = mapId; + } + + public int getOpposingTeamKills() { + return opposingTeamKills; + } + + public void setOpposingTeamKills(int opposingTeamKills) { + this.opposingTeamKills = opposingTeamKills; + } + + public String getOpposingTeamName() { + return opposingTeamName; + } + + public void setOpposingTeamName(String opposingTeamName) { + this.opposingTeamName = opposingTeamName; + } + + public boolean isWin() { + return win; + } + + public void setWin(boolean win) { + this.win = win; + } +} diff --git a/src/main/java/lol4j/protocol/dto/team/MessageOfDayDto.java b/src/main/java/lol4j/protocol/dto/team/MessageOfDayDto.java new file mode 100644 index 0000000..58c11ae --- /dev/null +++ b/src/main/java/lol4j/protocol/dto/team/MessageOfDayDto.java @@ -0,0 +1,37 @@ +package lol4j.protocol.dto.team; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by Aaryn101 on 12/13/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class MessageOfDayDto { + private long createDate; + private String message; + private int version; + + public long getCreateDate() { + return createDate; + } + + public void setCreateDate(long createDate) { + this.createDate = createDate; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } +} diff --git a/src/main/java/lol4j/protocol/dto/team/RosterDto.java b/src/main/java/lol4j/protocol/dto/team/RosterDto.java new file mode 100644 index 0000000..6003788 --- /dev/null +++ b/src/main/java/lol4j/protocol/dto/team/RosterDto.java @@ -0,0 +1,28 @@ +package lol4j.protocol.dto.team; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Aaryn101 on 12/13/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class RosterDto { + private List memberList = new ArrayList<>(); + private long ownerId; + + public List getMemberList() { + return memberList; + } + + public long getOwnerId() { + + return ownerId; + } + + public void setOwnerId(long ownerId) { + this.ownerId = ownerId; + } +} diff --git a/src/main/java/lol4j/protocol/dto/team/TeamDto.java b/src/main/java/lol4j/protocol/dto/team/TeamDto.java new file mode 100644 index 0000000..7c23107 --- /dev/null +++ b/src/main/java/lol4j/protocol/dto/team/TeamDto.java @@ -0,0 +1,146 @@ +package lol4j.protocol.dto.team; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * Created by Aaryn101 on 12/13/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class TeamDto { + private Date createDate; + private Date lastGameDate; + private Date lastJoinDate; + private Date lastJoinedRankedTeamQueueDate; + private List matchHistory = new ArrayList<>(); + private MessageOfDayDto messageOfDay; + private Date modifyDate; + private String name; + private RosterDto roster; + private Date secondLastJoinDate; + private String status; + private TeamIdDto teamId; + private TeamStatSummaryDto teamStatSummary; + private Date thirdLastJoinDate; + private long timestamp; + + public List getMatchHistory() { + return matchHistory; + } + + public MessageOfDayDto getMessageOfDay() { + + return messageOfDay; + } + + public void setMessageOfDay(MessageOfDayDto messageOfDay) { + this.messageOfDay = messageOfDay; + } + + public Date getModifyDate() { + return modifyDate; + } + + public void setModifyDate(Date modifyDate) { + this.modifyDate = modifyDate; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public RosterDto getRoster() { + return roster; + } + + public void setRoster(RosterDto roster) { + this.roster = roster; + } + + public Date getSecondLastJoinDate() { + return secondLastJoinDate; + } + + public void setSecondLastJoinDate(Date secondLastJoinDate) { + this.secondLastJoinDate = secondLastJoinDate; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public TeamIdDto getTeamId() { + return teamId; + } + + public void setTeamId(TeamIdDto teamId) { + this.teamId = teamId; + } + + public TeamStatSummaryDto getTeamStatSummary() { + return teamStatSummary; + } + + public void setTeamStatSummary(TeamStatSummaryDto teamStatSummary) { + this.teamStatSummary = teamStatSummary; + } + + public Date getThirdLastJoinDate() { + return thirdLastJoinDate; + } + + public void setThirdLastJoinDate(Date thirdLastJoinDate) { + this.thirdLastJoinDate = thirdLastJoinDate; + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public Date getLastJoinDate() { + return lastJoinDate; + } + + public void setLastJoinDate(Date lastJoinDate) { + this.lastJoinDate = lastJoinDate; + } + + public Date getLastJoinedRankedTeamQueueDate() { + return lastJoinedRankedTeamQueueDate; + } + + public void setLastJoinedRankedTeamQueueDate(Date lastJoinedRankedTeamQueueDate) { + this.lastJoinedRankedTeamQueueDate = lastJoinedRankedTeamQueueDate; + } + + public Date getLastGameDate() { + return lastGameDate; + } + + public void setLastGameDate(Date lastGameDate) { + this.lastGameDate = lastGameDate; + } + + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } +} diff --git a/src/main/java/lol4j/protocol/dto/team/TeamIdDto.java b/src/main/java/lol4j/protocol/dto/team/TeamIdDto.java new file mode 100644 index 0000000..3065068 --- /dev/null +++ b/src/main/java/lol4j/protocol/dto/team/TeamIdDto.java @@ -0,0 +1,19 @@ +package lol4j.protocol.dto.team; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by Aaryn101 on 12/13/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class TeamIdDto { + private String fullId; + + public String getFullId() { + return fullId; + } + + public void setFullId(String fullId) { + this.fullId = fullId; + } +} diff --git a/src/main/java/lol4j/protocol/dto/team/TeamMemberInfoDto.java b/src/main/java/lol4j/protocol/dto/team/TeamMemberInfoDto.java new file mode 100644 index 0000000..5a89e1c --- /dev/null +++ b/src/main/java/lol4j/protocol/dto/team/TeamMemberInfoDto.java @@ -0,0 +1,48 @@ +package lol4j.protocol.dto.team; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +/** + * Created by Aaryn101 on 12/13/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class TeamMemberInfoDto { + private Date inviteDate; + private Date joinDate; + private long playerId; + private String status; + + public Date getInviteDate() { + return inviteDate; + } + + public void setInviteDate(Date inviteDate) { + this.inviteDate = inviteDate; + } + + public Date getJoinDate() { + return joinDate; + } + + public void setJoinDate(Date joinDate) { + this.joinDate = joinDate; + } + + public long getPlayerId() { + return playerId; + } + + public void setPlayerId(long playerId) { + this.playerId = playerId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/src/main/java/lol4j/protocol/dto/team/TeamStatDetailDto.java b/src/main/java/lol4j/protocol/dto/team/TeamStatDetailDto.java new file mode 100644 index 0000000..43a7449 --- /dev/null +++ b/src/main/java/lol4j/protocol/dto/team/TeamStatDetailDto.java @@ -0,0 +1,82 @@ +package lol4j.protocol.dto.team; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by Aaryn101 on 12/13/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class TeamStatDetailDto { + private int averageGamesPlayed; + private int losses; + private int maxRating; + private int rating; + private int seedRating; + private TeamIdDto teamId; + private String teamStatType; + private int wins; + + public int getAverageGamesPlayed() { + return averageGamesPlayed; + } + + public void setAverageGamesPlayed(int averageGamesPlayed) { + this.averageGamesPlayed = averageGamesPlayed; + } + + public int getLosses() { + return losses; + } + + public void setLosses(int losses) { + this.losses = losses; + } + + public int getMaxRating() { + return maxRating; + } + + public void setMaxRating(int maxRating) { + this.maxRating = maxRating; + } + + public int getRating() { + return rating; + } + + public void setRating(int rating) { + this.rating = rating; + } + + public int getSeedRating() { + return seedRating; + } + + public void setSeedRating(int seedRating) { + this.seedRating = seedRating; + } + + public TeamIdDto getTeamId() { + return teamId; + } + + public void setTeamId(TeamIdDto teamId) { + this.teamId = teamId; + } + + public String getTeamStatType() { + return teamStatType; + } + + public void setTeamStatType(String teamStatType) { + this.teamStatType = teamStatType; + } + + public int getWins() { + return wins; + } + + public void setWins(int wins) { + this.wins = wins; + } +} diff --git a/src/main/java/lol4j/protocol/dto/team/TeamStatSummaryDto.java b/src/main/java/lol4j/protocol/dto/team/TeamStatSummaryDto.java new file mode 100644 index 0000000..d3e13d2 --- /dev/null +++ b/src/main/java/lol4j/protocol/dto/team/TeamStatSummaryDto.java @@ -0,0 +1,28 @@ +package lol4j.protocol.dto.team; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.HashSet; +import java.util.Set; + +/** + * Created by Aaryn101 on 12/13/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class TeamStatSummaryDto { + private TeamIdDto teamId; + private Set teamStatDetails = new HashSet<>(); + + public Set getTeamStatDetails() { + return teamStatDetails; + } + + public TeamIdDto getTeamId() { + + return teamId; + } + + public void setTeamId(TeamIdDto teamId) { + this.teamId = teamId; + } +} diff --git a/src/main/java/lol4j/protocol/resource/ChampionResource.java b/src/main/java/lol4j/protocol/resource/ChampionResource.java index 11f7b68..da09b01 100644 --- a/src/main/java/lol4j/protocol/resource/ChampionResource.java +++ b/src/main/java/lol4j/protocol/resource/ChampionResource.java @@ -1,6 +1,5 @@ package lol4j.protocol.resource; -import lol4j.exception.InvalidRegionException; import lol4j.protocol.dto.champion.ChampionListDto; import lol4j.util.Region; @@ -16,5 +15,5 @@ public interface ChampionResource { * @return champions * @if region specified is invalid */ - ChampionListDto getAllChampions(Region region, boolean freeToPlay) throws InvalidRegionException; + ChampionListDto getAllChampions(Region region, boolean freeToPlay); } diff --git a/src/main/java/lol4j/protocol/resource/GameResource.java b/src/main/java/lol4j/protocol/resource/GameResource.java index 4b1c1a7..9c64777 100644 --- a/src/main/java/lol4j/protocol/resource/GameResource.java +++ b/src/main/java/lol4j/protocol/resource/GameResource.java @@ -1,6 +1,5 @@ package lol4j.protocol.resource; -import lol4j.exception.InvalidRegionException; import lol4j.protocol.dto.game.RecentGamesDto; import lol4j.util.Region; @@ -8,5 +7,5 @@ * Created by Aaryn101 on 12/10/13. */ public interface GameResource { - RecentGamesDto getRecentGames(Region region, long summonerId) throws InvalidRegionException; + RecentGamesDto getRecentGames(Region region, long summonerId); } diff --git a/src/main/java/lol4j/protocol/resource/LeagueResource.java b/src/main/java/lol4j/protocol/resource/LeagueResource.java index 43e22c2..3821d22 100644 --- a/src/main/java/lol4j/protocol/resource/LeagueResource.java +++ b/src/main/java/lol4j/protocol/resource/LeagueResource.java @@ -1,6 +1,5 @@ package lol4j.protocol.resource; -import lol4j.exception.InvalidRegionException; import lol4j.protocol.dto.league.LeagueDto; import lol4j.util.Region; @@ -10,5 +9,5 @@ * Created by Aaryn101 on 12/11/13. */ public interface LeagueResource { - Map getLeaguesData(Region region, long summonerId) throws InvalidRegionException; + Map getLeaguesData(Region region, long summonerId); } diff --git a/src/main/java/lol4j/protocol/resource/StatsResource.java b/src/main/java/lol4j/protocol/resource/StatsResource.java index 1569fb4..24197f4 100644 --- a/src/main/java/lol4j/protocol/resource/StatsResource.java +++ b/src/main/java/lol4j/protocol/resource/StatsResource.java @@ -1,6 +1,5 @@ package lol4j.protocol.resource; -import lol4j.exception.InvalidRegionException; import lol4j.protocol.dto.stats.PlayerStatsSummaryListDto; import lol4j.protocol.dto.stats.RankedStatsDto; import lol4j.util.Region; @@ -10,7 +9,7 @@ * Created by Aaryn101 on 12/11/13. */ public interface StatsResource { - PlayerStatsSummaryListDto getPlayerStatsSummaries(Region region, long summonerId, Season season) throws InvalidRegionException; + PlayerStatsSummaryListDto getPlayerStatsSummaries(Region region, long summonerId, Season season); - RankedStatsDto getRankedStats(Region region, long summonerId, Season season) throws InvalidRegionException; + RankedStatsDto getRankedStats(Region region, long summonerId, Season season); } diff --git a/src/main/java/lol4j/protocol/resource/SummonerResource.java b/src/main/java/lol4j/protocol/resource/SummonerResource.java index 8deb1c7..d5c3156 100644 --- a/src/main/java/lol4j/protocol/resource/SummonerResource.java +++ b/src/main/java/lol4j/protocol/resource/SummonerResource.java @@ -1,12 +1,24 @@ package lol4j.protocol.resource; -import lol4j.exception.InvalidRegionException; import lol4j.protocol.dto.summoner.MasteryPagesDto; +import lol4j.protocol.dto.summoner.RunePagesDto; +import lol4j.protocol.dto.summoner.SummonerDto; +import lol4j.protocol.dto.summoner.SummonerNameListDto; import lol4j.util.Region; +import java.util.List; + /** * Created by Aaryn101 on 12/12/13. */ public interface SummonerResource { - MasteryPagesDto getMasteryPages(Region region, long summonerId) throws InvalidRegionException; + MasteryPagesDto getMasteryPages(Region region, long summonerId); + + RunePagesDto getRunePages(Region region, long summonerId); + + SummonerDto getSummoner(Region region, String name); + + SummonerDto getSummoner(Region region, long summonerId); + + SummonerNameListDto getSummonerNames(Region region, List summonerIds); } diff --git a/src/main/java/lol4j/protocol/resource/TeamResource.java b/src/main/java/lol4j/protocol/resource/TeamResource.java new file mode 100644 index 0000000..f82fd0a --- /dev/null +++ b/src/main/java/lol4j/protocol/resource/TeamResource.java @@ -0,0 +1,13 @@ +package lol4j.protocol.resource; + +import lol4j.protocol.dto.team.TeamDto; +import lol4j.util.Region; + +import java.util.List; + +/** + * Created by Aaryn101 on 12/13/13. + */ +public interface TeamResource { + List getTeams(Region region, long summonerId); +} diff --git a/src/main/java/lol4j/protocol/resource/impl/AbstractResourceImpl.java b/src/main/java/lol4j/protocol/resource/impl/AbstractResourceImpl.java index 6ade1c7..20e8fff 100644 --- a/src/main/java/lol4j/protocol/resource/impl/AbstractResourceImpl.java +++ b/src/main/java/lol4j/protocol/resource/impl/AbstractResourceImpl.java @@ -1,5 +1,6 @@ package lol4j.protocol.resource.impl; +import lol4j.exception.InvalidRegionException; import lol4j.service.impl.ApiRequestManager; import lol4j.util.Region; @@ -14,8 +15,10 @@ public abstract class AbstractResourceImpl { private ApiRequestManager apiRequestManager; private String baseUri; - public boolean isSupportedRegion(Region region) { - return supportedRegions.contains(region); + public void doSupportedRegionCheck(Region region) { + if (!supportedRegions.contains(region)) { + throw new InvalidRegionException(region); + } } public List getSupportedRegions() { diff --git a/src/main/java/lol4j/protocol/resource/impl/ChampionResourceImpl.java b/src/main/java/lol4j/protocol/resource/impl/ChampionResourceImpl.java index 1a58a51..314c98a 100644 --- a/src/main/java/lol4j/protocol/resource/impl/ChampionResourceImpl.java +++ b/src/main/java/lol4j/protocol/resource/impl/ChampionResourceImpl.java @@ -1,6 +1,5 @@ package lol4j.protocol.resource.impl; -import lol4j.exception.InvalidRegionException; import lol4j.protocol.dto.champion.ChampionListDto; import lol4j.protocol.resource.ChampionResource; import lol4j.util.Region; @@ -25,15 +24,11 @@ public ChampionResourceImpl() { @Override public ChampionListDto getAllChampions(Region region, boolean freeToPlay) { - if (isSupportedRegion(region)) { - String path = region.getName() + SLASH + RESOURCE_URI; - Map queryParams = new HashMap<>(); - queryParams.put("freeToPlay", freeToPlay); + doSupportedRegionCheck(region); + String path = region.getName() + SLASH + RESOURCE_URI; + Map queryParams = new HashMap<>(); + queryParams.put("freeToPlay", freeToPlay); - return getApiRequestManager().get(getBaseUri(), path, queryParams, ChampionListDto.class); - } - else { - throw new InvalidRegionException(region); - } + return getApiRequestManager().get(getBaseUri(), path, queryParams, ChampionListDto.class); } } diff --git a/src/main/java/lol4j/protocol/resource/impl/GameResourceImpl.java b/src/main/java/lol4j/protocol/resource/impl/GameResourceImpl.java index 6866fcf..01e05de 100644 --- a/src/main/java/lol4j/protocol/resource/impl/GameResourceImpl.java +++ b/src/main/java/lol4j/protocol/resource/impl/GameResourceImpl.java @@ -1,6 +1,5 @@ package lol4j.protocol.resource.impl; -import lol4j.exception.InvalidRegionException; import lol4j.protocol.dto.game.RecentGamesDto; import lol4j.protocol.resource.GameResource; import lol4j.util.Region; @@ -22,13 +21,9 @@ public GameResourceImpl() { @Override public RecentGamesDto getRecentGames(Region region, long summonerId) { - if (isSupportedRegion(region)) { - String path = region.getName() + SLASH + RESOURCE_URI + SLASH + summonerId + SLASH + "recent"; + doSupportedRegionCheck(region); + String path = region.getName() + SLASH + RESOURCE_URI + SLASH + summonerId + SLASH + "recent"; - return getApiRequestManager().get(getBaseUri(), path, null, RecentGamesDto.class); - } - else { - throw new InvalidRegionException(region); - } + return getApiRequestManager().get(getBaseUri(), path, null, RecentGamesDto.class); } } diff --git a/src/main/java/lol4j/protocol/resource/impl/LeagueResourceImpl.java b/src/main/java/lol4j/protocol/resource/impl/LeagueResourceImpl.java index 8f1c40e..35385ff 100644 --- a/src/main/java/lol4j/protocol/resource/impl/LeagueResourceImpl.java +++ b/src/main/java/lol4j/protocol/resource/impl/LeagueResourceImpl.java @@ -1,6 +1,5 @@ package lol4j.protocol.resource.impl; -import lol4j.exception.InvalidRegionException; import lol4j.protocol.dto.league.LeagueDto; import lol4j.protocol.resource.LeagueResource; import lol4j.util.Region; @@ -26,14 +25,10 @@ public LeagueResourceImpl() { @Override public Map getLeaguesData(Region region, long summonerId) { - if (isSupportedRegion(region)) { - String path = region.getName() + SLASH + RESOURCE_URI + SLASH + summonerId; + doSupportedRegionCheck(region); + String path = region.getName() + SLASH + RESOURCE_URI + SLASH + summonerId; - return getApiRequestManager() - .get(getBaseUri(), path, null, String.class, LeagueDto.class); - } - else { - throw new InvalidRegionException(region); - } + return getApiRequestManager() + .getMap(getBaseUri(), path, null, String.class, LeagueDto.class); } } diff --git a/src/main/java/lol4j/protocol/resource/impl/ResourceFactory.java b/src/main/java/lol4j/protocol/resource/impl/ResourceFactory.java index 17e96a2..e7758bb 100644 --- a/src/main/java/lol4j/protocol/resource/impl/ResourceFactory.java +++ b/src/main/java/lol4j/protocol/resource/impl/ResourceFactory.java @@ -8,7 +8,7 @@ */ public class ResourceFactory { private static final String LOL_BASE = "http://prod.api.pvp.net/api/lol"; - private static final String PVP_NET_BASE = "http://prod.api.pvp.net/api"; + private static final String API_BASE = "http://prod.api.pvp.net/api"; private ApiRequestManager apiRequestManager; public ResourceFactory(String apiKey) { @@ -35,7 +35,7 @@ public GameResource createGameResource() { public LeagueResource createLeagueResource() { LeagueResourceImpl leagueResource = new LeagueResourceImpl(); leagueResource.setApiRequestManager(apiRequestManager); - leagueResource.setBaseUri(PVP_NET_BASE); + leagueResource.setBaseUri(API_BASE); return leagueResource; } @@ -55,4 +55,12 @@ public SummonerResource createSummonerResource() { return summonerResource; } + + public TeamResource createTeamResource() { + TeamResourceImpl teamResource = new TeamResourceImpl(); + teamResource.setApiRequestManager(apiRequestManager); + teamResource.setBaseUri(API_BASE); + + return teamResource; + } } diff --git a/src/main/java/lol4j/protocol/resource/impl/StatsResourceImpl.java b/src/main/java/lol4j/protocol/resource/impl/StatsResourceImpl.java index 6f3d5dc..b0f437b 100644 --- a/src/main/java/lol4j/protocol/resource/impl/StatsResourceImpl.java +++ b/src/main/java/lol4j/protocol/resource/impl/StatsResourceImpl.java @@ -1,6 +1,5 @@ package lol4j.protocol.resource.impl; -import lol4j.exception.InvalidRegionException; import lol4j.protocol.dto.stats.PlayerStatsSummaryListDto; import lol4j.protocol.dto.stats.RankedStatsDto; import lol4j.protocol.resource.StatsResource; @@ -27,35 +26,27 @@ public StatsResourceImpl() { @Override public PlayerStatsSummaryListDto getPlayerStatsSummaries(Region region, long summonerId, Season season) { - if (isSupportedRegion(region)) { - String path = region.getName() + SLASH + RESOURCE_URI + SLASH + summonerId + SLASH + "summary"; - Map queryParams = null; - if (season != null) { - queryParams = new HashMap<>(); - queryParams.put("season", season.getName()); - } - - return getApiRequestManager().get(getBaseUri(), path, queryParams, PlayerStatsSummaryListDto.class); - } - else { - throw new InvalidRegionException(region); + doSupportedRegionCheck(region); + String path = region.getName() + SLASH + RESOURCE_URI + SLASH + summonerId + SLASH + "summary"; + Map queryParams = null; + if (season != null) { + queryParams = new HashMap<>(); + queryParams.put("season", season.getName()); } + + return getApiRequestManager().get(getBaseUri(), path, queryParams, PlayerStatsSummaryListDto.class); } @Override public RankedStatsDto getRankedStats(Region region, long summonerId, Season season) { - if (isSupportedRegion(region)) { - String path = region.getName() + SLASH + RESOURCE_URI + SLASH + summonerId + SLASH + "ranked"; - Map queryParams = null; - if (season != null) { - queryParams = new HashMap<>(); - queryParams.put("season", season.getName()); - } - - return getApiRequestManager().get(getBaseUri(), path, queryParams, RankedStatsDto.class); - } - else { - throw new InvalidRegionException(region); + doSupportedRegionCheck(region); + String path = region.getName() + SLASH + RESOURCE_URI + SLASH + summonerId + SLASH + "ranked"; + Map queryParams = null; + if (season != null) { + queryParams = new HashMap<>(); + queryParams.put("season", season.getName()); } + + return getApiRequestManager().get(getBaseUri(), path, queryParams, RankedStatsDto.class); } } diff --git a/src/main/java/lol4j/protocol/resource/impl/SummonerResourceImpl.java b/src/main/java/lol4j/protocol/resource/impl/SummonerResourceImpl.java index 04867fa..aa264c8 100644 --- a/src/main/java/lol4j/protocol/resource/impl/SummonerResourceImpl.java +++ b/src/main/java/lol4j/protocol/resource/impl/SummonerResourceImpl.java @@ -1,10 +1,14 @@ package lol4j.protocol.resource.impl; -import lol4j.exception.InvalidRegionException; import lol4j.protocol.dto.summoner.MasteryPagesDto; +import lol4j.protocol.dto.summoner.RunePagesDto; +import lol4j.protocol.dto.summoner.SummonerDto; +import lol4j.protocol.dto.summoner.SummonerNameListDto; import lol4j.protocol.resource.SummonerResource; import lol4j.util.Region; +import java.util.List; + /** * Created by Aaryn101 on 12/12/13. */ @@ -12,7 +16,13 @@ public class SummonerResourceImpl extends AbstractResourceImpl implements Summon private static final String RESOURCE_VERSION = "v1.1"; private static final String RESOURCE_PATH = "summoner"; private static final String SLASH = "/"; + private static final String COMMA = ","; private static final String RESOURCE_URI = RESOURCE_VERSION + SLASH + RESOURCE_PATH; + private static final String RUNES = "runes"; + private static final String MASTERIES = "masteries"; + private static final String BY_NAME = "by-name"; + private static final String NAME = "name"; + private static final int MAX_SUMMONER_IDS = 40; public SummonerResourceImpl() { getSupportedRegions().add(Region.NA); @@ -22,13 +32,53 @@ public SummonerResourceImpl() { @Override public MasteryPagesDto getMasteryPages(Region region, long summonerId) { - if (isSupportedRegion(region)) { - String path = region.getName() + SLASH + RESOURCE_URI + SLASH + summonerId + SLASH + "masteries"; + doSupportedRegionCheck(region); + String path = region.getName() + SLASH + RESOURCE_URI + SLASH + summonerId + SLASH + MASTERIES; + + return getApiRequestManager().get(getBaseUri(), path, null, MasteryPagesDto.class); + } + + @Override + public RunePagesDto getRunePages(Region region, long summonerId) { + doSupportedRegionCheck(region); + String path = region.getName() + SLASH + RESOURCE_URI + SLASH + summonerId + SLASH + RUNES; + + return getApiRequestManager().get(getBaseUri(), path, null, RunePagesDto.class); + } + + @Override + public SummonerDto getSummoner(Region region, String name) { + doSupportedRegionCheck(region); + if (name == null || name.isEmpty()) { + throw new IllegalArgumentException("Invalid summoner name"); + } + String path = region.getName() + SLASH + RESOURCE_URI + SLASH + BY_NAME + SLASH + name; + + return getApiRequestManager().get(getBaseUri(), path, null, SummonerDto.class); + } + + @Override + public SummonerDto getSummoner(Region region, long summonerId) { + doSupportedRegionCheck(region); + String path = region.getName() + SLASH + RESOURCE_URI + SLASH + summonerId; - return getApiRequestManager().get(getBaseUri(), path, null, MasteryPagesDto.class); + return getApiRequestManager().get(getBaseUri(), path, null, SummonerDto.class); + } + + @Override + public SummonerNameListDto getSummonerNames(Region region, List summonerIds) { + doSupportedRegionCheck(region); + if (summonerIds == null || summonerIds.size() > MAX_SUMMONER_IDS || summonerIds.size() == 0) { + throw new IllegalArgumentException("Invalid summoner id list"); } - else { - throw new InvalidRegionException(region); + StringBuilder path = new StringBuilder(); + path.append(region.getName()).append(SLASH).append(RESOURCE_URI).append(SLASH); + for (Long summonerId : summonerIds) { + path.append(summonerId).append(COMMA); } + path.deleteCharAt(path.length() - 1); + path.append(SLASH).append(NAME); + + return getApiRequestManager().get(getBaseUri(), path.toString(), null, SummonerNameListDto.class); } } diff --git a/src/main/java/lol4j/protocol/resource/impl/TeamResourceImpl.java b/src/main/java/lol4j/protocol/resource/impl/TeamResourceImpl.java new file mode 100644 index 0000000..74379b3 --- /dev/null +++ b/src/main/java/lol4j/protocol/resource/impl/TeamResourceImpl.java @@ -0,0 +1,34 @@ +package lol4j.protocol.resource.impl; + +import lol4j.protocol.dto.team.TeamDto; +import lol4j.protocol.resource.TeamResource; +import lol4j.util.Region; + +import java.util.List; + +/** + * Created by Aaryn101 on 12/13/13. + */ +public class TeamResourceImpl extends AbstractResourceImpl implements TeamResource { + private static final String RESOURCE_VERSION = "v2.1"; + private static final String RESOURCE_PATH = "team"; + private static final String SLASH = "/"; + private static final String RESOURCE_URI = RESOURCE_VERSION + SLASH + RESOURCE_PATH; + private static final String BY_SUMMONER = "by-summoner"; + + public TeamResourceImpl() { + getSupportedRegions().add(Region.TR); + getSupportedRegions().add(Region.NA); + getSupportedRegions().add(Region.EUNE); + getSupportedRegions().add(Region.EUW); + getSupportedRegions().add(Region.BR); + } + + @Override + public List getTeams(Region region, long summonerId) { + doSupportedRegionCheck(region); + String path = region.getName() + SLASH + RESOURCE_URI + SLASH + BY_SUMMONER + SLASH + summonerId; + + return getApiRequestManager().getList(getBaseUri(), path, null, TeamDto.class); + } +} diff --git a/src/main/java/lol4j/service/impl/ApiRequestManager.java b/src/main/java/lol4j/service/impl/ApiRequestManager.java index 0c1ddad..62f010c 100644 --- a/src/main/java/lol4j/service/impl/ApiRequestManager.java +++ b/src/main/java/lol4j/service/impl/ApiRequestManager.java @@ -15,6 +15,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.io.IOException; +import java.util.List; import java.util.Map; /** @@ -43,7 +44,21 @@ public T get(String baseUri, String path, Map queryParams, C return returnObj; } - public Map get(String baseUri, String path, Map queryParams, Class keyClass, Class valueClass) { + public List getList(String baseUri, String path, Map queryParams, Class clazz) { + String json = getJson(baseUri, path, queryParams); + TypeFactory typeFactory = TypeFactory.defaultInstance(); + List returnObj = null; + + try { + returnObj = objectMapper.readValue(json, typeFactory.constructCollectionType(List.class, clazz)); + } catch (IOException e) { + e.printStackTrace(); + } + + return returnObj; + } + + public Map getMap(String baseUri, String path, Map queryParams, Class keyClass, Class valueClass) { String json = getJson(baseUri, path, queryParams); TypeFactory typeFactory = TypeFactory.defaultInstance(); Map returnObj = null;