From 7010018bf3ee2cd195e4ac47abea40a839efbd51 Mon Sep 17 00:00:00 2001 From: xhsun Date: Wed, 7 Jun 2017 21:58:41 -0600 Subject: [PATCH 01/13] update TODO --- src/main/java/me/xhsun/guildwars2wrapper/GuildWars2.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2.java b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2.java index 41ce110..b4ea04e 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2.java @@ -14,7 +14,7 @@ * 1) use methods provided by {@link SynchronousRequest} to get data synchronously
* 2) use methods provided by {@link AsynchronousRequest} to get/process data asynchronously * TODO chatLinkToItemID - * TODO language selection, default english + * TODO language selection(en - english, de - german, es - spanish, fr - french), default english * TODO method to resolve back story question using answer id * TODO coins to gold/sliver/copper * @author xhsun From 9c34a3d2448c16260f86226ada6d656e467b38cc Mon Sep 17 00:00:00 2001 From: xhsun Date: Thu, 15 Jun 2017 10:54:58 -0600 Subject: [PATCH 02/13] done first endpoint for continents API --- .../AsynchronousRequest.java | 31 ++- .../guildwars2wrapper/GuildWars2API.java | 61 +++++ .../guildwars2wrapper/SynchronousRequest.java | 41 +++ .../guildwars2wrapper/error/ErrorCode.java | 2 +- .../xhsun/guildwars2wrapper/model/Color.java | 4 +- .../guildwars2wrapper/model/Currency.java | 4 +- .../xhsun/guildwars2wrapper/model/Item.java | 11 +- .../guildwars2wrapper/model/ItemStats.java | 4 +- .../guildwars2wrapper/model/Mastery.java | 4 +- .../model/MaterialCategory.java | 4 +- .../xhsun/guildwars2wrapper/model/Mini.java | 4 +- .../xhsun/guildwars2wrapper/model/Skin.java | 4 +- .../xhsun/guildwars2wrapper/model/Title.java | 4 +- .../xhsun/guildwars2wrapper/model/World.java | 4 +- .../model/achievements/Achievement.java | 4 +- .../achievements/AchievementCategory.java | 4 +- .../model/character/CharacterSAB.java | 8 +- .../model/continent/Continent.java | 46 ++++ .../model/continent/ContinentFloor.java | 35 +++ .../model/continent/ContinentMap.java | 253 ++++++++++++++++++ .../model/continent/ContinentRegion.java | 41 +++ .../model/guild/Upgrade.java | 4 +- .../model/indentifiable/Linkable.java | 24 ++ .../{Nameable.java => NameableInt.java} | 4 +- .../model/indentifiable/NameableStr.java | 23 ++ .../model/unlockable/Unlockable.java | 4 +- 26 files changed, 590 insertions(+), 42 deletions(-) create mode 100644 src/main/java/me/xhsun/guildwars2wrapper/model/continent/Continent.java create mode 100644 src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentFloor.java create mode 100644 src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentMap.java create mode 100644 src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentRegion.java create mode 100644 src/main/java/me/xhsun/guildwars2wrapper/model/indentifiable/Linkable.java rename src/main/java/me/xhsun/guildwars2wrapper/model/indentifiable/{Nameable.java => NameableInt.java} (81%) create mode 100644 src/main/java/me/xhsun/guildwars2wrapper/model/indentifiable/NameableStr.java diff --git a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java index c51765a..94885b1 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java @@ -13,6 +13,7 @@ import me.xhsun.guildwars2wrapper.model.character.*; import me.xhsun.guildwars2wrapper.model.commerce.Prices; import me.xhsun.guildwars2wrapper.model.commerce.Transaction; +import me.xhsun.guildwars2wrapper.model.continent.Continent; import me.xhsun.guildwars2wrapper.model.guild.Upgrade; import me.xhsun.guildwars2wrapper.model.pvp.Hero; import me.xhsun.guildwars2wrapper.model.unlockable.Finisher; @@ -810,8 +811,36 @@ public void getPrices(int[] ids, Callback> callback) throws GuildWa gw2API.getPrices(processIds(ids)).enqueue(callback); } - //Currencies + //Continents + /** + * For more info on continents API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws NullPointerException if given {@link Callback} is empty + * @see Continent continents info + */ + public void getAllContinentID(Callback> callback) throws NullPointerException { + gw2API.getAllContinentIDs().enqueue(callback); + } + + /** + * For more info on continents API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param ids list of currency id + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws GuildWars2Exception empty ID list + * @throws NullPointerException if given {@link Callback} is empty + * @see Continent continents info + */ + public void getContinentInfo(int[] ids, Callback> callback) throws GuildWars2Exception, NullPointerException { + isParamValid(new ParamChecker(ids)); + gw2API.getContinentInfo(processIds(ids)).enqueue(callback); + } + + //Currencies /** * For more info on Currency API go here
* Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions diff --git a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java index 9e24f6d..237df9c 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java @@ -12,6 +12,10 @@ import me.xhsun.guildwars2wrapper.model.character.*; import me.xhsun.guildwars2wrapper.model.commerce.Prices; import me.xhsun.guildwars2wrapper.model.commerce.Transaction; +import me.xhsun.guildwars2wrapper.model.continent.Continent; +import me.xhsun.guildwars2wrapper.model.continent.ContinentFloor; +import me.xhsun.guildwars2wrapper.model.continent.ContinentMap; +import me.xhsun.guildwars2wrapper.model.continent.ContinentRegion; import me.xhsun.guildwars2wrapper.model.guild.Upgrade; import me.xhsun.guildwars2wrapper.model.pvp.Hero; import me.xhsun.guildwars2wrapper.model.unlockable.Finisher; @@ -199,6 +203,49 @@ interface GuildWars2API { @GET("/v2/commerce/prices") Call> getPrices(@Query("ids") String ids); + //continents + @GET("/v2/continents") + Call> getAllContinentIDs(); + + @GET("/v2/continents") + Call> getContinentInfo(@Query("ids") String ids); + + @GET("/v2/continents/{continentId}/floors") + Call> getAllContinentFloorIDs(@Path("continentId") String continent); + + @GET("/v2/continents/{continentId}/floors") + Call> getContinentFloorInfo(@Path("continentId") String continent, @Query("ids") String ids); + + @GET("/v2/continents/{continentId}/floors/{floorId}/regions") + Call> getAllContinentRegionIDs(@Path("continentId") String continent, @Path("floorId") String floor); + + @GET("/v2/continents/{continentId}/floors/{floorId}/regions") + Call> getContinentRegionInfo(@Path("continentId") String continent, @Path("floorId") String floor, @Query("ids") String ids); + + @GET("/v2/continents/{continentId}/floors/{floorId}/regions/{regionId}/maps") + Call> getAllContinentMapIDs(@Path("continentId") String continent, @Path("floorId") String floor, @Path("regionId") String region); + + @GET("/v2/continents/{continentId}/floors/{floorId}/regions/{regionId}/maps") + Call> getContinentMapInfo(@Path("continentId") String continent, @Path("floorId") String floor, @Path("regionId") String region, @Query("ids") String ids); + + @GET("/v2/continents/{continentId}/floors/{floorId}/regions/{regionId}/maps/{mapId}/sectors") + Call> getAllContinentSectorIDs(@Path("continentId") String continent, @Path("floorId") String floor, @Path("regionId") String region, @Path("mapId") String map); + + @GET("/v2/continents/{continentId}/floors/{floorId}/regions/{regionId}/maps/{mapId}/sectors") + Call> getContinentSectorInfo(@Path("continentId") String continent, @Path("floorId") String floor, @Path("regionId") String region, @Path("mapId") String map, @Query("ids") String ids); + + @GET("/v2/continents/{continentId}/floors/{floorId}/regions/{regionId}/maps/{mapId}/pois") + Call> getAllContinentPOIIDs(@Path("continentId") String continent, @Path("floorId") String floor, @Path("regionId") String region, @Path("mapId") String map); + + @GET("/v2/continents/{continentId}/floors/{floorId}/regions/{regionId}/maps/{mapId}/pois") + Call> getContinentPOIInfo(@Path("continentId") String continent, @Path("floorId") String floor, @Path("regionId") String region, @Path("mapId") String map, @Query("ids") String ids); + + @GET("/v2/continents/{continentId}/floors/{floorId}/regions/{regionId}/maps/{mapId}/tasks") + Call> getAllContinentTaskIDs(@Path("continentId") String continent, @Path("floorId") String floor, @Path("regionId") String region, @Path("mapId") String map); + + @GET("/v2/continents/{continentId}/floors/{floorId}/regions/{regionId}/maps/{mapId}/tasks") + Call> getContinentTaskInfo(@Path("continentId") String continent, @Path("floorId") String floor, @Path("regionId") String region, @Path("mapId") String map, @Query("ids") String ids); + //currencies @GET("/v2/currencies") Call> getAllCurrencies(); @@ -283,6 +330,20 @@ interface GuildWars2API { @GET("/v2/outfits") Call> getOutfitInfo(@Query("ids") String ids); + //Professions + @GET("/v2/professions") + Call> getAllProfessionIDs(); + + @GET("/v2/professions") + Call> getProfessionInfo(@Query("ids") String ids); + + //PvP Amulets + @GET("/v2/pvp/amulets") + Call> getAllPvPAmuletIDs(); + + @GET("/v2/pvp/amulets") + Call> getPvPAmuletInfo(@Query("ids") String ids); + //PvP Heroes @GET("/v2/pvp/heroes") Call> getAllPvPHeroIDs(); diff --git a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java index 033a390..03cf8d8 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java @@ -14,6 +14,7 @@ import me.xhsun.guildwars2wrapper.model.character.*; import me.xhsun.guildwars2wrapper.model.commerce.Prices; import me.xhsun.guildwars2wrapper.model.commerce.Transaction; +import me.xhsun.guildwars2wrapper.model.continent.Continent; import me.xhsun.guildwars2wrapper.model.guild.Upgrade; import me.xhsun.guildwars2wrapper.model.pvp.Hero; import me.xhsun.guildwars2wrapper.model.unlockable.Finisher; @@ -1077,6 +1078,46 @@ public List getPrices(int[] ids) throws GuildWars2Exception { } } + //Continents + + /** + * For more info on continents API go here
+ * Get all continent ids + * + * @return list of continent ids + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Continent continent info + */ + public List getAllContinentID() throws GuildWars2Exception { + try { + Response> response = gw2API.getAllContinentIDs().execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on continents API go here
+ * Get continent info for the given continent id(s) + * + * @param ids list of continent id + * @return list of continent info + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Continent continent info + */ + public List getContinentInfo(int[] ids) throws GuildWars2Exception { + isParamValid(new ParamChecker(ids)); + try { + Response> response = gw2API.getContinentInfo(processIds(ids)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + //Currencies /** diff --git a/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java b/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java index e0f45fa..9d0f4b2 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java @@ -43,7 +43,7 @@ public static GuildWars2Exception checkErrorResponse(int code, String error) { case 400://no such character if (errorResponse != null && (errorResponse.getText().contains("key"))) return new GuildWars2Exception(ErrorCode.Key, "Invalid key"); - else if (errorResponse != null && (errorResponse.getText().contains("input") || errorResponse.getText().contains("output"))) + else if (errorResponse != null && errorResponse.getText().matches(".*\\\\b(input|output|id|ids)\\\\b.*")) return new GuildWars2Exception(ErrorCode.ID, "Invalid id"); return new GuildWars2Exception(ErrorCode.Character, "No such character for this account"); case 200://what... why pass OK response diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/Color.java b/src/main/java/me/xhsun/guildwars2wrapper/model/Color.java index 5c663cc..522e3e2 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/Color.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/Color.java @@ -1,7 +1,7 @@ package me.xhsun.guildwars2wrapper.model; import com.google.gson.annotations.Expose; -import me.xhsun.guildwars2wrapper.model.indentifiable.Nameable; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; import java.util.Arrays; import java.util.List; @@ -13,7 +13,7 @@ * @author xhsun * @since 2017-06-05 */ -public class Color extends Nameable { +public class Color extends NameableInt { public enum Categories { Gray, Brown, Red, Orange, Yellow, Green, Blue, Purple, Vibrant, Leather, Metal, diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/Currency.java b/src/main/java/me/xhsun/guildwars2wrapper/model/Currency.java index 01a2d38..573c3ad 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/Currency.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/Currency.java @@ -1,6 +1,6 @@ package me.xhsun.guildwars2wrapper.model; -import me.xhsun.guildwars2wrapper.model.indentifiable.Nameable; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; /** * For more info on Currency API go here
@@ -11,7 +11,7 @@ * @since 2017-02-07 */ -public class Currency extends Nameable { +public class Currency extends NameableInt { private String description; private String icon; private int order; diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/Item.java b/src/main/java/me/xhsun/guildwars2wrapper/model/Item.java index e56511d..84a8405 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/Item.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/Item.java @@ -1,6 +1,6 @@ package me.xhsun.guildwars2wrapper.model; -import me.xhsun.guildwars2wrapper.model.indentifiable.Nameable; +import me.xhsun.guildwars2wrapper.model.indentifiable.Linkable; import me.xhsun.guildwars2wrapper.model.util.itemDetail.ItemDetail; import java.util.List; @@ -13,7 +13,7 @@ * @since 2017-02-07 */ -public class Item extends Nameable { +public class Item extends Linkable { public enum Type { Armor, Back, Bag, Consumable, Container, CraftingMaterial, Gathering, Gizmo, MiniPet, Tool, Trait, Trinket, Trophy, UpgradeComponent, Weapon @@ -33,7 +33,6 @@ public enum Restriction { public enum GameType {Activity, Dungeon, Pve, Pvp, PvpLobby, Wvw} - private String chat_link; private String icon; private String description; private Type type; @@ -46,10 +45,6 @@ public enum GameType {Activity, Dungeon, Pve, Pvp, PvpLobby, Wvw} private List restrictions; private ItemDetail details; - public String getChatLink() { - return chat_link; - } - public String getIcon() { return icon; } @@ -98,7 +93,7 @@ public ItemDetail getDetails() { public String toString() { return "Item{" + "id=" + getId() + - ", chat_link='" + chat_link + '\'' + + ", chat_link='" + getChatLink() + '\'' + ", name='" + getName() + '\'' + ", icon='" + icon + '\'' + ", description='" + description + '\'' + diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/ItemStats.java b/src/main/java/me/xhsun/guildwars2wrapper/model/ItemStats.java index 75ed27c..ba21432 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/ItemStats.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/ItemStats.java @@ -1,7 +1,7 @@ package me.xhsun.guildwars2wrapper.model; -import me.xhsun.guildwars2wrapper.model.indentifiable.Nameable; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; import me.xhsun.guildwars2wrapper.model.util.itemDetail.ItemAttributes; /** @@ -12,7 +12,7 @@ * @see ItemAttributes item attribute * @since 2017-02-07 */ -public class ItemStats extends Nameable { +public class ItemStats extends NameableInt { private ItemAttributes attributes; public ItemAttributes getAttributes() { diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/Mastery.java b/src/main/java/me/xhsun/guildwars2wrapper/model/Mastery.java index 7d78b94..71c15e2 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/Mastery.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/Mastery.java @@ -1,6 +1,6 @@ package me.xhsun.guildwars2wrapper.model; -import me.xhsun.guildwars2wrapper.model.indentifiable.Nameable; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; import me.xhsun.guildwars2wrapper.model.util.comm.Region; import java.util.List; @@ -12,7 +12,7 @@ * @author xhsun * @since 2017-06-06 */ -public class Mastery extends Nameable { +public class Mastery extends NameableInt { private String requirement; private int order; private String background; diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/MaterialCategory.java b/src/main/java/me/xhsun/guildwars2wrapper/model/MaterialCategory.java index 654f282..cf24b4b 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/MaterialCategory.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/MaterialCategory.java @@ -1,6 +1,6 @@ package me.xhsun.guildwars2wrapper.model; -import me.xhsun.guildwars2wrapper.model.indentifiable.Nameable; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; import java.util.List; @@ -13,7 +13,7 @@ * @since 2017-02-07 */ -public class MaterialCategory extends Nameable { +public class MaterialCategory extends NameableInt { private List items; public List getItems() { diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/Mini.java b/src/main/java/me/xhsun/guildwars2wrapper/model/Mini.java index 79f2905..9ee98f9 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/Mini.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/Mini.java @@ -1,6 +1,6 @@ package me.xhsun.guildwars2wrapper.model; -import me.xhsun.guildwars2wrapper.model.indentifiable.Nameable; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; /** * For more info on Mini API go here
@@ -9,7 +9,7 @@ * @author xhsun * @since 2017-06-05 */ -public class Mini extends Nameable { +public class Mini extends NameableInt { private String unlock; private String icon; private int order; diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/Skin.java b/src/main/java/me/xhsun/guildwars2wrapper/model/Skin.java index 3c10edd..cd5dac5 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/Skin.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/Skin.java @@ -1,6 +1,6 @@ package me.xhsun.guildwars2wrapper.model; -import me.xhsun.guildwars2wrapper.model.indentifiable.Nameable; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; import me.xhsun.guildwars2wrapper.model.util.comm.Type; import me.xhsun.guildwars2wrapper.model.util.itemDetail.ItemDetail; @@ -16,7 +16,7 @@ * @since 2017-02-07 */ -public class Skin extends Nameable { +public class Skin extends NameableInt { public enum Flag {ShowInWardrobe, NoCost, HideIfLocked, OverrideRarity} private Item.Type type; private List flags; diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/Title.java b/src/main/java/me/xhsun/guildwars2wrapper/model/Title.java index 03a6898..c2adfce 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/Title.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/Title.java @@ -1,7 +1,7 @@ package me.xhsun.guildwars2wrapper.model; import me.xhsun.guildwars2wrapper.model.achievements.Achievement; -import me.xhsun.guildwars2wrapper.model.indentifiable.Nameable; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; import java.util.List; @@ -12,7 +12,7 @@ * @author xhsun * @since 2017-06-06 */ -public class Title extends Nameable { +public class Title extends NameableInt { private int achievement; private List achievements; private int ap_required; diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/World.java b/src/main/java/me/xhsun/guildwars2wrapper/model/World.java index 8840db7..c197657 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/World.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/World.java @@ -1,6 +1,6 @@ package me.xhsun.guildwars2wrapper.model; -import me.xhsun.guildwars2wrapper.model.indentifiable.Nameable; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; /** * For more info on World API go here
@@ -16,7 +16,7 @@ * @since 2017-02-07 */ -public class World extends Nameable { +public class World extends NameableInt { public enum Region {EU, NA, ERROR} private String population; diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/achievements/Achievement.java b/src/main/java/me/xhsun/guildwars2wrapper/model/achievements/Achievement.java index ef9189f..09a6cbc 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/achievements/Achievement.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/achievements/Achievement.java @@ -1,7 +1,7 @@ package me.xhsun.guildwars2wrapper.model.achievements; import com.google.gson.annotations.Expose; -import me.xhsun.guildwars2wrapper.model.indentifiable.Nameable; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; import me.xhsun.guildwars2wrapper.model.util.comm.Region; import java.util.List; @@ -13,7 +13,7 @@ * @author xhsun * @since 2017-06-05 */ -public class Achievement extends Nameable { +public class Achievement extends NameableInt { private enum Type { Default, ItemSet, Coins, Item, Mastery, Title, diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/achievements/AchievementCategory.java b/src/main/java/me/xhsun/guildwars2wrapper/model/achievements/AchievementCategory.java index 1dd3596..4b026a6 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/achievements/AchievementCategory.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/achievements/AchievementCategory.java @@ -1,6 +1,6 @@ package me.xhsun.guildwars2wrapper.model.achievements; -import me.xhsun.guildwars2wrapper.model.indentifiable.Nameable; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; import java.util.List; @@ -11,7 +11,7 @@ * @author xhsun * @since 2017-06-07 */ -public class AchievementCategory extends Nameable { +public class AchievementCategory extends NameableInt { private String description, icon; private int order; private List achievements; diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSAB.java b/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSAB.java index e2cd9c2..d46d94c 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSAB.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSAB.java @@ -1,7 +1,7 @@ package me.xhsun.guildwars2wrapper.model.character; import me.xhsun.guildwars2wrapper.model.indentifiable.IdentifiableInt; -import me.xhsun.guildwars2wrapper.model.indentifiable.Nameable; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; import java.util.List; @@ -14,17 +14,17 @@ */ public class CharacterSAB { private List zones; - private List unlocks, songs; + private List unlocks, songs; public List getZones() { return zones; } - public List getUnlocks() { + public List getUnlocks() { return unlocks; } - public List getSongs() { + public List getSongs() { return songs; } diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/continent/Continent.java b/src/main/java/me/xhsun/guildwars2wrapper/model/continent/Continent.java new file mode 100644 index 0000000..5154b1b --- /dev/null +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/continent/Continent.java @@ -0,0 +1,46 @@ +package me.xhsun.guildwars2wrapper.model.continent; + +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; + +import java.util.Arrays; +import java.util.List; + +/** + * For more info on continents API go here
+ * Model class for continents + * + * @author xhsun + * @since 2017-06-15 + */ +public class Continent extends NameableInt { + private double[] continent_dims; + private int min_zoom, max_zoom; + private List floors; + + public double[] getContinent_dims() { + return continent_dims; + } + + public int getMin_zoom() { + return min_zoom; + } + + public int getMax_zoom() { + return max_zoom; + } + + public List getFloors() { + return floors; + } + + @Override + public String toString() { + return "Continent{" + + super.toString() + + "continent_dims=" + Arrays.toString(continent_dims) + + ", min_zoom=" + min_zoom + + ", max_zoom=" + max_zoom + + ", floors=" + floors + + '}'; + } +} diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentFloor.java b/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentFloor.java new file mode 100644 index 0000000..d0afabd --- /dev/null +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentFloor.java @@ -0,0 +1,35 @@ +package me.xhsun.guildwars2wrapper.model.continent; + +import me.xhsun.guildwars2wrapper.model.indentifiable.IdentifiableInt; + +import java.util.Arrays; +import java.util.Map; + +/** + * For more info on continents floors API go here
+ * Model class for continents floor + * + * @author xhsun + * @since 2017-06-15 + */ +public class ContinentFloor extends IdentifiableInt { + private double[] texture_dims; + private Map regions; + + public double[] getTexture_dims() { + return texture_dims; + } + + public Map getRegions() { + return regions; + } + + @Override + public String toString() { + return "ContinentFloor{" + + "id=" + getId() + + ", texture_dims=" + Arrays.toString(texture_dims) + + ", regions=" + regions + + '}'; + } +} diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentMap.java b/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentMap.java new file mode 100644 index 0000000..e5eb808 --- /dev/null +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentMap.java @@ -0,0 +1,253 @@ +package me.xhsun.guildwars2wrapper.model.continent; + +import me.xhsun.guildwars2wrapper.model.indentifiable.*; +import me.xhsun.guildwars2wrapper.model.util.comm.Region; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * For more info on continents map API go here
+ * Model class for continents map + * + * @author xhsun + * @since 2017-06-15 + */ +public class ContinentMap extends NameableInt { + public enum PoIType {landmark, waypoint, vista} + + private int min_level, max_level; + private int default_floor; + private double[] label_coord; + private double[][] continent_rect, map_rect; + private Map points_of_interest; + private Map tasks; + private List skill_challenges; + private Map sectors; + private List adventures; + private List mastery_points; + + public int getMin_level() { + return min_level; + } + + public int getMax_level() { + return max_level; + } + + public int getDefault_floor() { + return default_floor; + } + + public double[] getLabel_coord() { + return label_coord; + } + + public double[][] getContinent_rect() { + return continent_rect; + } + + public double[][] getMap_rect() { + return map_rect; + } + + public Map getPoints_of_interest() { + return points_of_interest; + } + + public Map getTasks() { + return tasks; + } + + public List getSkill_challenges() { + return skill_challenges; + } + + public Map getSectors() { + return sectors; + } + + public List getAdventures() { + return adventures; + } + + public List getMastery_points() { + return mastery_points; + } + + @Override + public String toString() { + return "ContinentMap{" + + super.toString() + + "min_level=" + min_level + + ", max_level=" + max_level + + ", default_floor=" + default_floor + + ", label_coord=" + Arrays.toString(label_coord) + + ", continent_rect=" + Arrays.toString(continent_rect) + + ", map_rect=" + Arrays.toString(map_rect) + + ", points_of_interest=" + points_of_interest + + ", tasks=" + tasks + + ", skill_challenges=" + skill_challenges + + ", sectors=" + sectors + + ", adventures=" + adventures + + ", mastery_points=" + mastery_points + + '}'; + } + + public class PoI extends Linkable { + private PoIType type; + private int floor; + private double[] coord; + + public PoIType getType() { + return type; + } + + public int getFloor() { + return floor; + } + + public double[] getCoord() { + return coord; + } + + @Override + public String toString() { + return "PoI{" + + super.toString() + + ", type=" + type + + ", floor=" + floor + + ", coord=" + Arrays.toString(coord) + + '}'; + } + } + + public class Sector extends Linkable { + private int level; + private double[] coord; + private double[][] bounds; + + public int getLevel() { + return level; + } + + public double[] getCoord() { + return coord; + } + + public double[][] getBounds() { + return bounds; + } + + @Override + public String toString() { + return "Sector{" + + super.toString() + + "level=" + level + + ", coord=" + Arrays.toString(coord) + + ", bounds=" + Arrays.toString(bounds) + + '}'; + } + } + + public class Task extends IdentifiableInt { + private String objective; + private String chat_link; + private int level; + private double[] coord; + private double[][] bounds; + + public String getObjective() { + return objective; + } + + public String getChatLink() { + return chat_link; + } + + public int getLevel() { + return level; + } + + public double[] getCoord() { + return coord; + } + + public double[][] getBounds() { + return bounds; + } + + @Override + public String toString() { + return "Task{" + + "id=" + getId() + + ", objective='" + objective + '\'' + + ", chat_link='" + chat_link + '\'' + + ", level=" + level + + ", coord=" + Arrays.toString(coord) + + ", bounds=" + Arrays.toString(bounds) + + '}'; + } + } + + public class Mastery extends IdentifiableInt { + private double[] coord; + private Region region; + + public double[] getCoord() { + return coord; + } + + public Region getRegion() { + return region; + } + + @Override + public String toString() { + return "Mastery{" + + "id=" + getId() + + ", coord=" + Arrays.toString(coord) + + ", region=" + region + + '}'; + } + } + + public class Adventure extends NameableStr { + private String description; + private double[] coord; + + public String getDescription() { + return description; + } + + public double[] getCoord() { + return coord; + } + + @Override + public String toString() { + return "Adventure{" + + super.toString() + + "description='" + description + '\'' + + ", coord=" + Arrays.toString(coord) + + '}'; + } + } + + public class SkillChallenge extends IdentifiableStr { + private double[] coord; + + public double[] getCoord() { + return coord; + } + + @Override + public String toString() { + return "SkillChallenge{" + + "id=" + getId() + + ", coord=" + Arrays.toString(coord) + + '}'; + } + } +} diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentRegion.java b/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentRegion.java new file mode 100644 index 0000000..93d9baf --- /dev/null +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentRegion.java @@ -0,0 +1,41 @@ +package me.xhsun.guildwars2wrapper.model.continent; + +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; + +import java.util.Arrays; +import java.util.Map; + +/** + * For more info on continents region API go here
+ * Model class for continents region + * + * @author xhsun + * @since 2017-06-15 + */ +public class ContinentRegion extends NameableInt { + private double[] label_coord; + private double[][] continent_rect; + private Map maps; + + public double[] getLabel_coord() { + return label_coord; + } + + public double[][] getContinent_rect() { + return continent_rect; + } + + public Map getMaps() { + return maps; + } + + @Override + public String toString() { + return "ContinentRegion{" + + super.toString() + + "label_coord=" + Arrays.toString(label_coord) + + ", continent_rect=" + Arrays.toString(continent_rect) + + ", maps=" + maps + + '}'; + } +} diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/guild/Upgrade.java b/src/main/java/me/xhsun/guildwars2wrapper/model/guild/Upgrade.java index 16fb057..de19edf 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/guild/Upgrade.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/guild/Upgrade.java @@ -1,6 +1,6 @@ package me.xhsun.guildwars2wrapper.model.guild; -import me.xhsun.guildwars2wrapper.model.indentifiable.Nameable; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; import java.util.List; @@ -11,7 +11,7 @@ * @author xhsun * @since 2017-06-06 */ -public class Upgrade extends Nameable { +public class Upgrade extends NameableInt { public enum Type { AccumulatingCurrency, BankBag, Boost, Claimable, Consumable, Decoration, GuildHall, GuildHallExpedition, Hub, Queue, Unlock diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/indentifiable/Linkable.java b/src/main/java/me/xhsun/guildwars2wrapper/model/indentifiable/Linkable.java new file mode 100644 index 0000000..f0b0030 --- /dev/null +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/indentifiable/Linkable.java @@ -0,0 +1,24 @@ +package me.xhsun.guildwars2wrapper.model.indentifiable; + +/** + * For models that have an int id, string name, and string chat_link + * + * @author xhsun + * @since 2017-06-07 + */ +public class Linkable extends NameableInt { + private String chat_link; + + public String getChatLink() { + return chat_link; + } + + @Override + public String toString() { + return "{" + + "id=" + getId() + + ", name='" + getName() + '\'' + + ", chat_link='" + chat_link + '\'' + + '}'; + } +} diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/indentifiable/Nameable.java b/src/main/java/me/xhsun/guildwars2wrapper/model/indentifiable/NameableInt.java similarity index 81% rename from src/main/java/me/xhsun/guildwars2wrapper/model/indentifiable/Nameable.java rename to src/main/java/me/xhsun/guildwars2wrapper/model/indentifiable/NameableInt.java index c03c129..35c4cd9 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/indentifiable/Nameable.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/indentifiable/NameableInt.java @@ -6,7 +6,7 @@ * @author xhsun * @since 2017-06-07 */ -public class Nameable extends IdentifiableInt { +public class NameableInt extends IdentifiableInt { private String name; public String getName() { @@ -16,7 +16,7 @@ public String getName() { @Override public String toString() { return "{" + - "id=" + getName() + + "id=" + getId() + ", name='" + name + '\'' + '}'; } diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/indentifiable/NameableStr.java b/src/main/java/me/xhsun/guildwars2wrapper/model/indentifiable/NameableStr.java new file mode 100644 index 0000000..e66c5b0 --- /dev/null +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/indentifiable/NameableStr.java @@ -0,0 +1,23 @@ +package me.xhsun.guildwars2wrapper.model.indentifiable; + +/** + * For models that have an string id and string name + * + * @author xhsun + * @since 2017-06-07 + */ +public class NameableStr extends IdentifiableStr { + private String name; + + public String getName() { + return name; + } + + @Override + public String toString() { + return "{" + + "id=" + getId() + + ", name='" + name + '\'' + + '}'; + } +} diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/unlockable/Unlockable.java b/src/main/java/me/xhsun/guildwars2wrapper/model/unlockable/Unlockable.java index 6092caf..b757e67 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/unlockable/Unlockable.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/unlockable/Unlockable.java @@ -1,7 +1,7 @@ package me.xhsun.guildwars2wrapper.model.unlockable; import me.xhsun.guildwars2wrapper.model.Item; -import me.xhsun.guildwars2wrapper.model.indentifiable.Nameable; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; import me.xhsun.guildwars2wrapper.model.pvp.Hero.Skin; /** * Super class for model classes that have unlock item field @@ -9,7 +9,7 @@ * @author xhsun * @since 2017-06-06 */ -public class Unlockable extends Nameable { +public class Unlockable extends NameableInt { private int[] unlock_items;//item id private int order; private String icon; From 64703312f19df4c42b5e28a0299230e1edc31ce1 Mon Sep 17 00:00:00 2001 From: xhsun Date: Thu, 15 Jun 2017 11:19:18 -0600 Subject: [PATCH 03/13] done floors endpoint for continents API and also fixed error in errorCode that cause incorrect error message --- .../AsynchronousRequest.java | 31 ++++++++++++++- .../me/xhsun/guildwars2wrapper/Request.java | 1 - .../guildwars2wrapper/SynchronousRequest.java | 39 +++++++++++++++++++ .../guildwars2wrapper/error/ErrorCode.java | 2 +- .../model/continent/ContinentMap.java | 8 ++-- .../model/continent/ContinentRegion.java | 2 +- 6 files changed, 75 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java index 94885b1..7e02741 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java @@ -14,6 +14,7 @@ import me.xhsun.guildwars2wrapper.model.commerce.Prices; import me.xhsun.guildwars2wrapper.model.commerce.Transaction; import me.xhsun.guildwars2wrapper.model.continent.Continent; +import me.xhsun.guildwars2wrapper.model.continent.ContinentFloor; import me.xhsun.guildwars2wrapper.model.guild.Upgrade; import me.xhsun.guildwars2wrapper.model.pvp.Hero; import me.xhsun.guildwars2wrapper.model.unlockable.Finisher; @@ -812,7 +813,6 @@ public void getPrices(int[] ids, Callback> callback) throws GuildWa } //Continents - /** * For more info on continents API go here
* Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions @@ -840,6 +840,35 @@ public void getContinentInfo(int[] ids, Callback> callback) thro gw2API.getContinentInfo(processIds(ids)).enqueue(callback); } + /** + * For more info on continents API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param continentID {@link Continent#id} + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws NullPointerException if given {@link Callback} is empty + * @see ContinentFloor continents floor info + */ + public void getAllContinentFloorID(int continentID, Callback> callback) throws NullPointerException { + gw2API.getAllContinentFloorIDs(Integer.toString(continentID)).enqueue(callback); + } + + /** + * For more info on continents API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param continentID {@link Continent#id} + * @param ids list of currency id + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws GuildWars2Exception empty ID list + * @throws NullPointerException if given {@link Callback} is empty + * @see ContinentFloor continents floor info + */ + public void getContinentFloorInfo(int continentID, int[] ids, Callback> callback) throws GuildWars2Exception, NullPointerException { + isParamValid(new ParamChecker(ids)); + gw2API.getContinentFloorInfo(Integer.toString(continentID), processIds(ids)).enqueue(callback); + } + //Currencies /** * For more info on Currency API go here
diff --git a/src/main/java/me/xhsun/guildwars2wrapper/Request.java b/src/main/java/me/xhsun/guildwars2wrapper/Request.java index eaf77be..3990675 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/Request.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/Request.java @@ -97,7 +97,6 @@ void isParamValid(ParamChecker... items) throws GuildWars2Exception { throw new GuildWars2Exception(ErrorCode.ID, "List of id cannot be empty"); } } - } } diff --git a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java index 03cf8d8..5d8a2d4 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java @@ -15,6 +15,7 @@ import me.xhsun.guildwars2wrapper.model.commerce.Prices; import me.xhsun.guildwars2wrapper.model.commerce.Transaction; import me.xhsun.guildwars2wrapper.model.continent.Continent; +import me.xhsun.guildwars2wrapper.model.continent.ContinentFloor; import me.xhsun.guildwars2wrapper.model.guild.Upgrade; import me.xhsun.guildwars2wrapper.model.pvp.Hero; import me.xhsun.guildwars2wrapper.model.unlockable.Finisher; @@ -1118,6 +1119,44 @@ public List getContinentInfo(int[] ids) throws GuildWars2Exception { } } + /** + * For more info on continents API go here
+ * Get all continent floor ids + * + * @return list of continent floor ids + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see ContinentFloor continent floor info + */ + public List getAllContinentFloorID(int continentID) throws GuildWars2Exception { + try { + Response> response = gw2API.getAllContinentFloorIDs(Integer.toString(continentID)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on continents API go here
+ * Get continent info for the given continent floor id(s) + * + * @param ids list of continent floor id + * @return list of continent info + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see ContinentFloor continent floor info + */ + public List getContinentFloorInfo(int continentID, int[] ids) throws GuildWars2Exception { + isParamValid(new ParamChecker(ids)); + try { + Response> response = gw2API.getContinentFloorInfo(Integer.toString(continentID), processIds(ids)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + //Currencies /** diff --git a/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java b/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java index 9d0f4b2..31d8d4d 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java @@ -43,7 +43,7 @@ public static GuildWars2Exception checkErrorResponse(int code, String error) { case 400://no such character if (errorResponse != null && (errorResponse.getText().contains("key"))) return new GuildWars2Exception(ErrorCode.Key, "Invalid key"); - else if (errorResponse != null && errorResponse.getText().matches(".*\\\\b(input|output|id|ids)\\\\b.*")) + else if (errorResponse != null && errorResponse.getText().matches(".*\\b(input|output|id|ids)\\b.*")) return new GuildWars2Exception(ErrorCode.ID, "Invalid id"); return new GuildWars2Exception(ErrorCode.Character, "No such character for this account"); case 200://what... why pass OK response diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentMap.java b/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentMap.java index e5eb808..896b069 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentMap.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentMap.java @@ -84,8 +84,8 @@ public String toString() { ", max_level=" + max_level + ", default_floor=" + default_floor + ", label_coord=" + Arrays.toString(label_coord) + - ", continent_rect=" + Arrays.toString(continent_rect) + - ", map_rect=" + Arrays.toString(map_rect) + + ", continent_rect=" + Arrays.deepToString(continent_rect) + + ", map_rect=" + Arrays.deepToString(map_rect) + ", points_of_interest=" + points_of_interest + ", tasks=" + tasks + ", skill_challenges=" + skill_challenges + @@ -146,7 +146,7 @@ public String toString() { super.toString() + "level=" + level + ", coord=" + Arrays.toString(coord) + - ", bounds=" + Arrays.toString(bounds) + + ", bounds=" + Arrays.deepToString(bounds) + '}'; } } @@ -186,7 +186,7 @@ public String toString() { ", chat_link='" + chat_link + '\'' + ", level=" + level + ", coord=" + Arrays.toString(coord) + - ", bounds=" + Arrays.toString(bounds) + + ", bounds=" + Arrays.deepToString(bounds) + '}'; } } diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentRegion.java b/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentRegion.java index 93d9baf..44bd806 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentRegion.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentRegion.java @@ -34,7 +34,7 @@ public String toString() { return "ContinentRegion{" + super.toString() + "label_coord=" + Arrays.toString(label_coord) + - ", continent_rect=" + Arrays.toString(continent_rect) + + ", continent_rect=" + Arrays.deepToString(continent_rect) + ", maps=" + maps + '}'; } From 9895ef53d5b9bed2d570cc4d6539a3ce8a3e34ca Mon Sep 17 00:00:00 2001 From: xhsun Date: Thu, 15 Jun 2017 11:35:39 -0600 Subject: [PATCH 04/13] done regions endpoint for continents API --- .../AsynchronousRequest.java | 36 +++++++++++++- .../guildwars2wrapper/SynchronousRequest.java | 47 ++++++++++++++++++- .../guildwars2wrapper/error/ErrorCode.java | 2 +- .../model/continent/ContinentMap.java | 2 +- 4 files changed, 82 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java index 7e02741..a44b70d 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java @@ -15,6 +15,7 @@ import me.xhsun.guildwars2wrapper.model.commerce.Transaction; import me.xhsun.guildwars2wrapper.model.continent.Continent; import me.xhsun.guildwars2wrapper.model.continent.ContinentFloor; +import me.xhsun.guildwars2wrapper.model.continent.ContinentRegion; import me.xhsun.guildwars2wrapper.model.guild.Upgrade; import me.xhsun.guildwars2wrapper.model.pvp.Hero; import me.xhsun.guildwars2wrapper.model.unlockable.Finisher; @@ -829,7 +830,7 @@ public void getAllContinentID(Callback> callback) throws NullPoint * For more info on continents API go here
* Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions * - * @param ids list of currency id + * @param ids list of continents id * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} * @throws GuildWars2Exception empty ID list * @throws NullPointerException if given {@link Callback} is empty @@ -858,7 +859,7 @@ public void getAllContinentFloorID(int continentID, Callback> call * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions * * @param continentID {@link Continent#id} - * @param ids list of currency id + * @param ids list of floor id * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} * @throws GuildWars2Exception empty ID list * @throws NullPointerException if given {@link Callback} is empty @@ -869,6 +870,37 @@ public void getContinentFloorInfo(int continentID, int[] ids, Callbackhere
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws NullPointerException if given {@link Callback} is empty + * @see ContinentRegion continents region info + */ + public void getAllContinentRegionID(int continentID, int floorID, Callback> callback) throws NullPointerException { + gw2API.getAllContinentRegionIDs(Integer.toString(continentID), Integer.toString(floorID)).enqueue(callback); + } + + /** + * For more info on continents API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param ids list of region id + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws GuildWars2Exception empty ID list + * @throws NullPointerException if given {@link Callback} is empty + * @see ContinentRegion continents region info + */ + public void getContinentRegionInfo(int continentID, int floorID, int[] ids, Callback> callback) throws GuildWars2Exception, NullPointerException { + isParamValid(new ParamChecker(ids)); + gw2API.getContinentRegionInfo(Integer.toString(continentID), Integer.toString(floorID), processIds(ids)).enqueue(callback); + } + //Currencies /** * For more info on Currency API go here
diff --git a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java index 5d8a2d4..9548054 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java @@ -16,6 +16,7 @@ import me.xhsun.guildwars2wrapper.model.commerce.Transaction; import me.xhsun.guildwars2wrapper.model.continent.Continent; import me.xhsun.guildwars2wrapper.model.continent.ContinentFloor; +import me.xhsun.guildwars2wrapper.model.continent.ContinentRegion; import me.xhsun.guildwars2wrapper.model.guild.Upgrade; import me.xhsun.guildwars2wrapper.model.pvp.Hero; import me.xhsun.guildwars2wrapper.model.unlockable.Finisher; @@ -1123,6 +1124,7 @@ public List getContinentInfo(int[] ids) throws GuildWars2Exception { * For more info on continents API go here
* Get all continent floor ids * + * @param continentID {@link Continent#id} * @return list of continent floor ids * @throws GuildWars2Exception see {@link ErrorCode} for detail * @see ContinentFloor continent floor info @@ -1141,8 +1143,9 @@ public List getAllContinentFloorID(int continentID) throws GuildWars2Ex * For more info on continents API go here
* Get continent info for the given continent floor id(s) * + * @param continentID {@link Continent#id} * @param ids list of continent floor id - * @return list of continent info + * @return list of continent floor info * @throws GuildWars2Exception see {@link ErrorCode} for detail * @see ContinentFloor continent floor info */ @@ -1157,6 +1160,48 @@ public List getContinentFloorInfo(int continentID, int[] ids) th } } + /** + * For more info on continents API go here
+ * Get all continent region ids + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @return list of continent region ids + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see ContinentRegion continent region info + */ + public List getAllContinentRegionID(int continentID, int floorID) throws GuildWars2Exception { + try { + Response> response = gw2API.getAllContinentRegionIDs(Integer.toString(continentID), Integer.toString(floorID)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on continents API go here
+ * Get continent region info for the given continent region id(s) + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param ids list of continent region id + * @return list of continent region info + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see ContinentRegion continent region info + */ + public List getContinentRegionInfo(int continentID, int floorID, int[] ids) throws GuildWars2Exception { + isParamValid(new ParamChecker(ids)); + try { + Response> response = gw2API.getContinentRegionInfo(Integer.toString(continentID), Integer.toString(floorID), processIds(ids)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + //Currencies /** diff --git a/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java b/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java index 31d8d4d..c211c06 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java @@ -43,7 +43,7 @@ public static GuildWars2Exception checkErrorResponse(int code, String error) { case 400://no such character if (errorResponse != null && (errorResponse.getText().contains("key"))) return new GuildWars2Exception(ErrorCode.Key, "Invalid key"); - else if (errorResponse != null && errorResponse.getText().matches(".*\\b(input|output|id|ids)\\b.*")) + else if (errorResponse != null && errorResponse.getText().matches(".*\\b(input|output|id|ids|floor)\\b.*")) return new GuildWars2Exception(ErrorCode.ID, "Invalid id"); return new GuildWars2Exception(ErrorCode.Character, "No such character for this account"); case 200://what... why pass OK response diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentMap.java b/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentMap.java index 896b069..d816c44 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentMap.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/continent/ContinentMap.java @@ -15,7 +15,7 @@ * @since 2017-06-15 */ public class ContinentMap extends NameableInt { - public enum PoIType {landmark, waypoint, vista} + public enum PoIType {landmark, waypoint, vista, unlock} private int min_level, max_level; private int default_floor; From d6de4d713a9caca73b015034b45c73e300ff7fbf Mon Sep 17 00:00:00 2001 From: xhsun Date: Thu, 15 Jun 2017 11:43:13 -0600 Subject: [PATCH 05/13] done maps endpoint for continents API --- .../AsynchronousRequest.java | 34 ++++++++++++ .../guildwars2wrapper/SynchronousRequest.java | 53 ++++++++++++++++++- .../guildwars2wrapper/error/ErrorCode.java | 2 +- 3 files changed, 86 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java index a44b70d..1d7b3d8 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java @@ -15,6 +15,7 @@ import me.xhsun.guildwars2wrapper.model.commerce.Transaction; import me.xhsun.guildwars2wrapper.model.continent.Continent; import me.xhsun.guildwars2wrapper.model.continent.ContinentFloor; +import me.xhsun.guildwars2wrapper.model.continent.ContinentMap; import me.xhsun.guildwars2wrapper.model.continent.ContinentRegion; import me.xhsun.guildwars2wrapper.model.guild.Upgrade; import me.xhsun.guildwars2wrapper.model.pvp.Hero; @@ -901,6 +902,39 @@ public void getContinentRegionInfo(int continentID, int floorID, int[] ids, Call gw2API.getContinentRegionInfo(Integer.toString(continentID), Integer.toString(floorID), processIds(ids)).enqueue(callback); } + /** + * For more info on continents API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws NullPointerException if given {@link Callback} is empty + * @see ContinentMap continents map info + */ + public void getAllContinentMapID(int continentID, int floorID, int regionID, Callback> callback) throws NullPointerException { + gw2API.getAllContinentMapIDs(Integer.toString(continentID), Integer.toString(floorID), Integer.toString(regionID)).enqueue(callback); + } + + /** + * For more info on continents API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @param ids list of region map id + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws GuildWars2Exception empty ID list + * @throws NullPointerException if given {@link Callback} is empty + * @see ContinentMap continents map info + */ + public void getContinentMapInfo(int continentID, int floorID, int regionID, int[] ids, Callback> callback) throws GuildWars2Exception, NullPointerException { + isParamValid(new ParamChecker(ids)); + gw2API.getContinentMapInfo(Integer.toString(continentID), Integer.toString(floorID), Integer.toString(regionID), processIds(ids)).enqueue(callback); + } + //Currencies /** * For more info on Currency API go here
diff --git a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java index 9548054..0348560 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java @@ -16,6 +16,7 @@ import me.xhsun.guildwars2wrapper.model.commerce.Transaction; import me.xhsun.guildwars2wrapper.model.continent.Continent; import me.xhsun.guildwars2wrapper.model.continent.ContinentFloor; +import me.xhsun.guildwars2wrapper.model.continent.ContinentMap; import me.xhsun.guildwars2wrapper.model.continent.ContinentRegion; import me.xhsun.guildwars2wrapper.model.guild.Upgrade; import me.xhsun.guildwars2wrapper.model.pvp.Hero; @@ -1172,7 +1173,8 @@ public List getContinentFloorInfo(int continentID, int[] ids) th */ public List getAllContinentRegionID(int continentID, int floorID) throws GuildWars2Exception { try { - Response> response = gw2API.getAllContinentRegionIDs(Integer.toString(continentID), Integer.toString(floorID)).execute(); + Response> response = gw2API.getAllContinentRegionIDs(Integer.toString(continentID), + Integer.toString(floorID)).execute(); if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); return response.body(); } catch (IOException e) { @@ -1194,7 +1196,54 @@ public List getAllContinentRegionID(int continentID, int floorID) throw public List getContinentRegionInfo(int continentID, int floorID, int[] ids) throws GuildWars2Exception { isParamValid(new ParamChecker(ids)); try { - Response> response = gw2API.getContinentRegionInfo(Integer.toString(continentID), Integer.toString(floorID), processIds(ids)).execute(); + Response> response = gw2API.getContinentRegionInfo(Integer.toString(continentID), + Integer.toString(floorID), processIds(ids)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on continents API go here
+ * Get all continent map ids + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @return list of continent map ids + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see ContinentMap continent map info + */ + public List getAllContinentMapID(int continentID, int floorID, int regionID) throws GuildWars2Exception { + try { + Response> response = gw2API.getAllContinentMapIDs(Integer.toString(continentID), + Integer.toString(floorID), Integer.toString(regionID)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on continents API go here
+ * Get continent map info for the given continent map id(s) + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @param ids list of continent map id + * @return list of continent map info + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see ContinentMap continent map info + */ + public List getContinentMapInfo(int continentID, int floorID, int regionID, int[] ids) throws GuildWars2Exception { + isParamValid(new ParamChecker(ids)); + try { + Response> response = gw2API.getContinentMapInfo(Integer.toString(continentID), + Integer.toString(floorID), Integer.toString(regionID), processIds(ids)).execute(); if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); return response.body(); } catch (IOException e) { diff --git a/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java b/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java index c211c06..ec778ba 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java @@ -43,7 +43,7 @@ public static GuildWars2Exception checkErrorResponse(int code, String error) { case 400://no such character if (errorResponse != null && (errorResponse.getText().contains("key"))) return new GuildWars2Exception(ErrorCode.Key, "Invalid key"); - else if (errorResponse != null && errorResponse.getText().matches(".*\\b(input|output|id|ids|floor)\\b.*")) + else if (errorResponse != null && errorResponse.getText().matches(".*\\b(input|output|id|ids|floor|region)\\b.*")) return new GuildWars2Exception(ErrorCode.ID, "Invalid id"); return new GuildWars2Exception(ErrorCode.Character, "No such character for this account"); case 200://what... why pass OK response From 6862cdff4fd7b4523c87912714b0167d10d229d9 Mon Sep 17 00:00:00 2001 From: xhsun Date: Thu, 15 Jun 2017 11:57:26 -0600 Subject: [PATCH 06/13] done all endpoint for continents API --- .../AsynchronousRequest.java | 105 +++++++++++++ .../guildwars2wrapper/SynchronousRequest.java | 144 ++++++++++++++++++ .../guildwars2wrapper/error/ErrorCode.java | 2 +- 3 files changed, 250 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java index 1d7b3d8..752714c 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java @@ -935,6 +935,111 @@ public void getContinentMapInfo(int continentID, int floorID, int regionID, int[ gw2API.getContinentMapInfo(Integer.toString(continentID), Integer.toString(floorID), Integer.toString(regionID), processIds(ids)).enqueue(callback); } + /** + * For more info on continents API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @param mapID {@link ContinentMap#id} + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws NullPointerException if given {@link Callback} is empty + * @see ContinentMap.Sector continents map sector info + */ + public void getAllContinentSectorID(int continentID, int floorID, int regionID, int mapID, Callback> callback) throws NullPointerException { + gw2API.getAllContinentSectorIDs(Integer.toString(continentID), Integer.toString(floorID), Integer.toString(regionID), Integer.toString(mapID)).enqueue(callback); + } + + /** + * For more info on continents API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @param mapID {@link ContinentMap#id} + * @param ids list of region map sector id + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws GuildWars2Exception empty ID list + * @throws NullPointerException if given {@link Callback} is empty + * @see ContinentMap.Sector continents map sector info + */ + public void getContinentSectorInfo(int continentID, int floorID, int regionID, int mapID, int[] ids, Callback> callback) throws GuildWars2Exception, NullPointerException { + isParamValid(new ParamChecker(ids)); + gw2API.getContinentSectorInfo(Integer.toString(continentID), Integer.toString(floorID), Integer.toString(regionID), Integer.toString(mapID), processIds(ids)).enqueue(callback); + } + + /** + * For more info on continents API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @param mapID {@link ContinentMap#id} + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws NullPointerException if given {@link Callback} is empty + * @see ContinentMap.PoI continents map PoI info + */ + public void getAllContinentPOIID(int continentID, int floorID, int regionID, int mapID, Callback> callback) throws NullPointerException { + gw2API.getAllContinentPOIIDs(Integer.toString(continentID), Integer.toString(floorID), Integer.toString(regionID), Integer.toString(mapID)).enqueue(callback); + } + + /** + * For more info on continents API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @param mapID {@link ContinentMap#id} + * @param ids list of region map PoI id + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws GuildWars2Exception empty ID list + * @throws NullPointerException if given {@link Callback} is empty + * @see ContinentMap.PoI continents map PoI info + */ + public void getContinentPOIInfo(int continentID, int floorID, int regionID, int mapID, int[] ids, Callback> callback) throws GuildWars2Exception, NullPointerException { + isParamValid(new ParamChecker(ids)); + gw2API.getContinentPOIInfo(Integer.toString(continentID), Integer.toString(floorID), Integer.toString(regionID), Integer.toString(mapID), processIds(ids)).enqueue(callback); + } + + /** + * For more info on continents API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @param mapID {@link ContinentMap#id} + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws NullPointerException if given {@link Callback} is empty + * @see ContinentMap.Task continents map task info + */ + public void getAllContinentTaskID(int continentID, int floorID, int regionID, int mapID, Callback> callback) throws NullPointerException { + gw2API.getAllContinentTaskIDs(Integer.toString(continentID), Integer.toString(floorID), Integer.toString(regionID), Integer.toString(mapID)).enqueue(callback); + } + + /** + * For more info on continents API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @param mapID {@link ContinentMap#id} + * @param ids list of region map task id + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws GuildWars2Exception empty ID list + * @throws NullPointerException if given {@link Callback} is empty + * @see ContinentMap.Task continents map task info + */ + public void getContinentTaskInfo(int continentID, int floorID, int regionID, int mapID, int[] ids, Callback> callback) throws GuildWars2Exception, NullPointerException { + isParamValid(new ParamChecker(ids)); + gw2API.getContinentTaskInfo(Integer.toString(continentID), Integer.toString(floorID), Integer.toString(regionID), Integer.toString(mapID), processIds(ids)).enqueue(callback); + } + //Currencies /** * For more info on Currency API go here
diff --git a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java index 0348560..03674ff 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java @@ -1251,6 +1251,150 @@ public List getContinentMapInfo(int continentID, int floorID, int } } + /** + * For more info on continents API go here
+ * Get all continent map sector ids + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @param mapID {@link ContinentMap#id} + * @return list of continent map sector ids + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see ContinentMap.Sector continent map sector info + */ + public List getAllContinentSectorID(int continentID, int floorID, int regionID, int mapID) throws GuildWars2Exception { + try { + Response> response = gw2API.getAllContinentSectorIDs(Integer.toString(continentID), + Integer.toString(floorID), Integer.toString(regionID), Integer.toString(mapID)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on continents API go here
+ * Get continent map sector info for the given continent map sector id(s) + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @param mapID {@link ContinentMap#id} + * @param ids list of continent map sector id + * @return list of continent map sector info + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see ContinentMap.Sector continent map sector info + */ + public List getContinentSectorInfo(int continentID, int floorID, int regionID, int mapID, int[] ids) throws GuildWars2Exception { + isParamValid(new ParamChecker(ids)); + try { + Response> response = gw2API.getContinentSectorInfo(Integer.toString(continentID), + Integer.toString(floorID), Integer.toString(regionID), Integer.toString(mapID), processIds(ids)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on continents API go here
+ * Get all continent map PoI ids + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @param mapID {@link ContinentMap#id} + * @return list of continent map PoI ids + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see ContinentMap.Sector continent map PoI info + */ + public List getAllContinentPOIID(int continentID, int floorID, int regionID, int mapID) throws GuildWars2Exception { + try { + Response> response = gw2API.getAllContinentPOIIDs(Integer.toString(continentID), + Integer.toString(floorID), Integer.toString(regionID), Integer.toString(mapID)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on continents API go here
+ * Get continent map PoI info for the given continent map PoI id(s) + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @param mapID {@link ContinentMap#id} + * @param ids list of continent map PoI id + * @return list of continent map PoI info + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see ContinentMap.PoI continent map PoI info + */ + public List getContinentPOIInfo(int continentID, int floorID, int regionID, int mapID, int[] ids) throws GuildWars2Exception { + isParamValid(new ParamChecker(ids)); + try { + Response> response = gw2API.getContinentPOIInfo(Integer.toString(continentID), + Integer.toString(floorID), Integer.toString(regionID), Integer.toString(mapID), processIds(ids)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on continents API go here
+ * Get all continent map task ids + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @param mapID {@link ContinentMap#id} + * @return list of continent map task ids + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see ContinentMap.Task continent map task info + */ + public List getAllContinentTaskID(int continentID, int floorID, int regionID, int mapID) throws GuildWars2Exception { + try { + Response> response = gw2API.getAllContinentTaskIDs(Integer.toString(continentID), + Integer.toString(floorID), Integer.toString(regionID), Integer.toString(mapID)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on continents API go here
+ * Get continent map task info for the given continent map task id(s) + * + * @param continentID {@link Continent#id} + * @param floorID {@link ContinentFloor#id} + * @param regionID {@link ContinentRegion#id} + * @param mapID {@link ContinentMap#id} + * @param ids list of continent map task id + * @return list of continent map task info + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see ContinentMap.Task continent map task info + */ + public List getContinentTaskInfo(int continentID, int floorID, int regionID, int mapID, int[] ids) throws GuildWars2Exception { + isParamValid(new ParamChecker(ids)); + try { + Response> response = gw2API.getContinentTaskInfo(Integer.toString(continentID), + Integer.toString(floorID), Integer.toString(regionID), Integer.toString(mapID), processIds(ids)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + //Currencies /** diff --git a/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java b/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java index ec778ba..4c8d7db 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/error/ErrorCode.java @@ -43,7 +43,7 @@ public static GuildWars2Exception checkErrorResponse(int code, String error) { case 400://no such character if (errorResponse != null && (errorResponse.getText().contains("key"))) return new GuildWars2Exception(ErrorCode.Key, "Invalid key"); - else if (errorResponse != null && errorResponse.getText().matches(".*\\b(input|output|id|ids|floor|region)\\b.*")) + else if (errorResponse != null && errorResponse.getText().matches(".*\\b(input|output|id|ids|floor|region|map)\\b.*")) return new GuildWars2Exception(ErrorCode.ID, "Invalid id"); return new GuildWars2Exception(ErrorCode.Character, "No such character for this account"); case 200://what... why pass OK response From 9ebeeb27ee17c084a47600fc5bd2f97d92c733f5 Mon Sep 17 00:00:00 2001 From: xhsun Date: Thu, 15 Jun 2017 11:59:49 -0600 Subject: [PATCH 07/13] remove outdated TODO --- .../java/me/xhsun/guildwars2wrapper/SynchronousRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java index 03674ff..583e57e 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java @@ -848,7 +848,7 @@ public CharacterEquipment getCharacterEquipment(String API, String name) throws * @param name name of character * @return list of {@link BackStoryAnswer#id} * @throws GuildWars2Exception see {@link ErrorCode} for detail - * @see BackStoryAnswer hero points info TODO /v2/continents + * @see BackStoryAnswer hero points info */ public List getCharacterHeroPoints(String API, String name) throws GuildWars2Exception { isParamValid(new ParamChecker(ParamType.API, API), new ParamChecker(ParamType.CHAR, name)); From 75f4a812b112009d40535827b56979b2d05b1982 Mon Sep 17 00:00:00 2001 From: xhsun Date: Thu, 15 Jun 2017 12:53:18 -0600 Subject: [PATCH 08/13] done profession API --- .../AsynchronousRequest.java | 29 +++ .../guildwars2wrapper/GuildWars2API.java | 4 +- .../guildwars2wrapper/SynchronousRequest.java | 40 ++++ .../guildwars2wrapper/model/Profession.java | 197 ++++++++++++++++++ .../model/character/CharacterTraining.java | 3 +- .../model/util/comm/Type.java | 6 +- 6 files changed, 275 insertions(+), 4 deletions(-) create mode 100644 src/main/java/me/xhsun/guildwars2wrapper/model/Profession.java diff --git a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java index 752714c..aa5589d 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java @@ -1387,6 +1387,35 @@ public void getOutfitInfo(int[] ids, Callback> callback) throws Gui gw2API.getOutfitInfo(processIds(ids)).enqueue(callback); } + //Professions + + /** + * For more info on professions API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws NullPointerException if given {@link Callback} is empty + * @see Profession profession info + */ + public void getAllProfessionID(Callback> callback) throws NullPointerException { + gw2API.getAllProfessionIDs().enqueue(callback); + } + + /** + * For more info on professions API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param ids list of profession id + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws GuildWars2Exception empty ID list + * @throws NullPointerException if given {@link Callback} is empty + * @see Profession profession info + */ + public void getProfessionInfo(String[] ids, Callback> callback) throws GuildWars2Exception, NullPointerException { + isParamValid(new ParamChecker(ids)); + gw2API.getProfessionInfo(processIds(ids)).enqueue(callback); + } + //PvP Heroes /** diff --git a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java index 237df9c..5938ff2 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java @@ -146,6 +146,8 @@ interface GuildWars2API { @GET("/v2/build") Call getCurrentGameBuild(); + //TODO /v2/cats + //characters @GET("/v2/characters") Call> getAllCharacterName(@Query("access_token") String token); @@ -335,7 +337,7 @@ interface GuildWars2API { Call> getAllProfessionIDs(); @GET("/v2/professions") - Call> getProfessionInfo(@Query("ids") String ids); + Call> getProfessionInfo(@Query("ids") String ids); //PvP Amulets @GET("/v2/pvp/amulets") diff --git a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java index 583e57e..25236a4 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java @@ -1875,6 +1875,46 @@ public List getOutfitInfo(int[] ids) throws GuildWars2Exception { } } + //Professions + + /** + * For more info on professions API go here
+ * Get all profession id(s) + * + * @return list of profession id(s) + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Profession profession info + */ + public List getAllProfessionID() throws GuildWars2Exception { + try { + Response> response = gw2API.getAllProfessionIDs().execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on professions API go here
+ * Get profession info for the given profession id(s) + * + * @param ids list of profession id(s) + * @return list of profession info + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Profession Profession info + */ + public List getProfessionInfo(String[] ids) throws GuildWars2Exception { + isParamValid(new ParamChecker(ids)); + try { + Response> response = gw2API.getProfessionInfo(processIds(ids)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + //PvP Heroes /** diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/Profession.java b/src/main/java/me/xhsun/guildwars2wrapper/model/Profession.java new file mode 100644 index 0000000..3edb3ed --- /dev/null +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/Profession.java @@ -0,0 +1,197 @@ +package me.xhsun.guildwars2wrapper.model; + +import me.xhsun.guildwars2wrapper.model.indentifiable.IdentifiableInt; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableStr; +import me.xhsun.guildwars2wrapper.model.util.comm.Type; + +import java.util.List; +import java.util.Map; + +/** + * For more info on professions API go here
+ * Model class for professions + * + * @author xhsun + * @since 2017-06-15 + */ +public class Profession extends NameableStr { + public enum TrainingCategory {Skills, Specializations, EliteSpecializations} + + private enum TrackType {Trait, Skill} + + public enum WeaponSlot {Weapon_1, Weapon_2, Weapon_3, Weapon_4, Weapon_5, Profession_1, Profession_2, Profession_3, Profession_4, Profession_5, Utility, Heal, Elite} + + public enum Attunement {Fire, Water, Air, Earth} + + public enum Flag {Mainhand, Offhand, TwoHand, Aquatic, NoRacialSkills, NoWeaponSwap} + + private String icon, icon_big; + private List flags; + private List specializations; + private List training; + private List skills; + private Map weapons; + + public String getIcon() { + return icon; + } + + public String getIconBig() { + return icon_big; + } + + public List getSpecializations() { + return specializations; + } + + public List getTraining() { + return training; + } + + public Map getWeapons() { + return weapons; + } + + public List getFlags() { + return flags; + } + + public List getSkills() { + return skills; + } + + @Override + public String toString() { + return "Profession{" + + super.toString() + + ", icon='" + icon + '\'' + + ", icon_big='" + icon_big + '\'' + + ", flags=" + flags + + ", specializations=" + specializations + + ", training=" + training + + ", skills=" + skills + + ", weapons=" + weapons + + '}'; + } + + public class Training extends NameableInt { + private TrainingCategory category; + private List track; + + public TrainingCategory getCategory() { + return category; + } + + public List getTrack() { + return track; + } + + @Override + public String toString() { + return "Training{" + + super.toString() + + ", category=" + category + + ", track=" + track + + '}'; + } + } + + public class TrainingTrack { + private int cost, skill_id, trait_id; + private TrackType type; + + public int getCost() { + return cost; + } + + public int getSkill_id() { + return skill_id; + } + + public int getTrait_id() { + return trait_id; + } + + public TrackType getType() { + return type; + } + + @Override + public String toString() { + return "TrainingTrack{" + + "cost=" + cost + + ", skill_id=" + skill_id + + ", trait_id=" + trait_id + + ", type=" + type + + '}'; + } + } + + public class Weapon { + private int specialization; + private List skills; + private List flags; + + public int getSpecialization() { + return specialization; + } + + public List getSkills() { + return skills; + } + + public List getFlags() { + return flags; + } + + @Override + public String toString() { + return "Weapon{" + + "specialization=" + specialization + + ", skills=" + skills + + ", flags=" + flags + + '}'; + } + } + + public class Skill extends IdentifiableInt { + private WeaponSlot slot; + private Type offhand; + private Type type; + private Attunement attunement; + private Item.Restriction source; + + public WeaponSlot getSlot() { + return slot; + } + + public Type getOffhand() { + return offhand; + } + + public Attunement getAttunement() { + return attunement; + } + + public Item.Restriction getSource() { + return source; + } + + public Type getType() { + return type; + } + + @Override + public String toString() { + return "Skill{" + + "id=" + getId() + + ", slot=" + slot + + ", offhand=" + offhand + + ", type=" + type + + ", attunement=" + attunement + + ", source=" + source + + '}'; + } + } +} diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterTraining.java b/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterTraining.java index 2b966b0..4a95607 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterTraining.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterTraining.java @@ -7,8 +7,7 @@ /** * For more info on character training API go here
* Model class for character training - * TODO /v2/professions - * + * @see me.xhsun.guildwars2wrapper.model.Profession.Training * @author xhsun * @since 2017-06-07 */ diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/util/comm/Type.java b/src/main/java/me/xhsun/guildwars2wrapper/model/util/comm/Type.java index f2dc421..b6503ba 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/util/comm/Type.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/util/comm/Type.java @@ -38,5 +38,9 @@ public enum Type { //Guild recipes type GuildConsumable, GuildDecoration, GuildConsumableWvw, //Other recipes type - Backpack, Bag, Bulk, Consumable, Dye, Potion, UpgradeComponent + Backpack, Bag, Bulk, Consumable, Dye, Potion, UpgradeComponent, + //Other + Nothing, + //Skill Type + Profession, Heal, Elite } From a1b1a97db0d228538d73f08b48d81f29ccacaa19 Mon Sep 17 00:00:00 2001 From: xhsun Date: Thu, 15 Jun 2017 13:02:57 -0600 Subject: [PATCH 09/13] done pvp amulet API --- .../AsynchronousRequest.java | 30 ++++++++++++++ .../guildwars2wrapper/GuildWars2API.java | 3 +- .../guildwars2wrapper/SynchronousRequest.java | 41 +++++++++++++++++++ .../guildwars2wrapper/model/pvp/Amulet.java | 33 +++++++++++++++ .../model/util/itemDetail/ItemAttributes.java | 12 ++++++ 5 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 src/main/java/me/xhsun/guildwars2wrapper/model/pvp/Amulet.java diff --git a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java index aa5589d..4c8d79d 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java @@ -18,6 +18,7 @@ import me.xhsun.guildwars2wrapper.model.continent.ContinentMap; import me.xhsun.guildwars2wrapper.model.continent.ContinentRegion; import me.xhsun.guildwars2wrapper.model.guild.Upgrade; +import me.xhsun.guildwars2wrapper.model.pvp.Amulet; import me.xhsun.guildwars2wrapper.model.pvp.Hero; import me.xhsun.guildwars2wrapper.model.unlockable.Finisher; import me.xhsun.guildwars2wrapper.model.unlockable.Glider; @@ -1416,6 +1417,35 @@ public void getProfessionInfo(String[] ids, Callback> callback) gw2API.getProfessionInfo(processIds(ids)).enqueue(callback); } + //PvP Amulets + + /** + * For more info on pvp amulets API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws NullPointerException if given {@link Callback} is empty + * @see Amulet amulet info + */ + public void getAllPvPAmuletID(Callback> callback) throws NullPointerException { + gw2API.getAllPvPAmuletIDs().enqueue(callback); + } + + /** + * For more info on pvp amulets API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param ids list of amulet id + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws GuildWars2Exception empty ID list + * @throws NullPointerException if given {@link Callback} is empty + * @see Amulet amulet info + */ + public void getPvPAmuletInfo(int[] ids, Callback> callback) throws GuildWars2Exception, NullPointerException { + isParamValid(new ParamChecker(ids)); + gw2API.getPvPAmuletInfo(processIds(ids)).enqueue(callback); + } + //PvP Heroes /** diff --git a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java index 5938ff2..3af525c 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java @@ -17,6 +17,7 @@ import me.xhsun.guildwars2wrapper.model.continent.ContinentMap; import me.xhsun.guildwars2wrapper.model.continent.ContinentRegion; import me.xhsun.guildwars2wrapper.model.guild.Upgrade; +import me.xhsun.guildwars2wrapper.model.pvp.Amulet; import me.xhsun.guildwars2wrapper.model.pvp.Hero; import me.xhsun.guildwars2wrapper.model.unlockable.Finisher; import me.xhsun.guildwars2wrapper.model.unlockable.Glider; @@ -344,7 +345,7 @@ interface GuildWars2API { Call> getAllPvPAmuletIDs(); @GET("/v2/pvp/amulets") - Call> getPvPAmuletInfo(@Query("ids") String ids); + Call> getPvPAmuletInfo(@Query("ids") String ids); //PvP Heroes @GET("/v2/pvp/heroes") diff --git a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java index 25236a4..ca271a4 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java @@ -19,6 +19,7 @@ import me.xhsun.guildwars2wrapper.model.continent.ContinentMap; import me.xhsun.guildwars2wrapper.model.continent.ContinentRegion; import me.xhsun.guildwars2wrapper.model.guild.Upgrade; +import me.xhsun.guildwars2wrapper.model.pvp.Amulet; import me.xhsun.guildwars2wrapper.model.pvp.Hero; import me.xhsun.guildwars2wrapper.model.unlockable.Finisher; import me.xhsun.guildwars2wrapper.model.unlockable.Glider; @@ -1915,6 +1916,46 @@ public List getProfessionInfo(String[] ids) throws GuildWars2Excepti } } + //PvP Amulets + + /** + * For more info on pvp amulets API go here
+ * Get all amulet id(s) + * + * @return list of amulet id(s) + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Amulet amulet info + */ + public List getAllPvPAmuletID() throws GuildWars2Exception { + try { + Response> response = gw2API.getAllPvPAmuletIDs().execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on pvp amulets API go here
+ * Get amulet info for the given amulet id(s) + * + * @param ids list of amulet id(s) + * @return list of amulet info + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Amulet amulet info + */ + public List getPvPAmuletInfo(int[] ids) throws GuildWars2Exception { + isParamValid(new ParamChecker(ids)); + try { + Response> response = gw2API.getPvPAmuletInfo(processIds(ids)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + //PvP Heroes /** diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/pvp/Amulet.java b/src/main/java/me/xhsun/guildwars2wrapper/model/pvp/Amulet.java new file mode 100644 index 0000000..c6619c8 --- /dev/null +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/pvp/Amulet.java @@ -0,0 +1,33 @@ +package me.xhsun.guildwars2wrapper.model.pvp; + +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; +import me.xhsun.guildwars2wrapper.model.util.itemDetail.ItemAttributes; + +/** + * For more info on pvp amulets API go here
+ * Model class for pvp amulet + * + * @author xhsun + * @since 2017-06-15 + */ +public class Amulet extends NameableInt { + private String icon; + private ItemAttributes attributes; + + public String getIcon() { + return icon; + } + + public ItemAttributes getAttributes() { + return attributes; + } + + @Override + public String toString() { + return "Amulet{" + + super.toString() + + ", icon='" + icon + '\'' + + ", attributes=" + attributes + + '}'; + } +} diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/ItemAttributes.java b/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/ItemAttributes.java index b14cbad..fc0be5d 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/ItemAttributes.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/ItemAttributes.java @@ -20,6 +20,8 @@ public class ItemAttributes { private float cond_duration; private float Healing; private float BoonDuration; + private float CritDamage; + private float AgonyResistance; public float getPower() { return Power; @@ -53,6 +55,14 @@ public float getBoonDuration() { return BoonDuration; } + public float getFerocity() { + return CritDamage; + } + + public float getAgonyResistance() { + return AgonyResistance; + } + @Override public String toString() { return "ItemAttributes{" + @@ -64,6 +74,8 @@ public String toString() { ", cond_duration=" + cond_duration + ", Healing=" + Healing + ", BoonDuration=" + BoonDuration + + ", CritDamage=" + CritDamage + + ", AgonyResistance=" + AgonyResistance + '}'; } } \ No newline at end of file From 539e7bcf75d15b5d1853c55fca0575811aadd4f8 Mon Sep 17 00:00:00 2001 From: xhsun Date: Thu, 15 Jun 2017 16:20:47 -0600 Subject: [PATCH 10/13] done skills API --- .../AsynchronousRequest.java | 29 ++++ .../guildwars2wrapper/GuildWars2API.java | 7 + .../guildwars2wrapper/SynchronousRequest.java | 40 +++++ .../guildwars2wrapper/model/Profession.java | 7 +- .../xhsun/guildwars2wrapper/model/Skill.java | 156 ++++++++++++++++++ .../model/character/Character.java | 1 - .../model/util/comm/Type.java | 4 +- .../model/util/itemDetail/ItemAttributes.java | 5 + .../model/util/itemDetail/ItemDetail.java | 5 - .../itemDetail/subobject/InfixAttribute.java | 6 +- .../model/util/skillFact/BooleanAdapter.java | 27 +++ .../model/util/skillFact/SkillFact.java | 128 ++++++++++++++ .../util/skillFact/SkillTraitedFact.java | 28 ++++ 13 files changed, 428 insertions(+), 15 deletions(-) create mode 100644 src/main/java/me/xhsun/guildwars2wrapper/model/Skill.java create mode 100644 src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/BooleanAdapter.java create mode 100644 src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/SkillFact.java create mode 100644 src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/SkillTraitedFact.java diff --git a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java index 4c8d79d..4b462f3 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java @@ -1548,6 +1548,35 @@ public void searchRecipes(boolean isInput, int id, Callback> callb else gw2API.searchOutputRecipes(Integer.toString(id)).enqueue(callback); } + //Skills + + /** + * For more info on Skills API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws NullPointerException if given {@link Callback} is empty + * @see Skill skill info + */ + public void getAllSkillID(Callback> callback) throws NullPointerException { + gw2API.getAllSkillIDs().enqueue(callback); + } + + /** + * For more info on Skills API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param ids list of skill id + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws GuildWars2Exception empty ID list + * @throws NullPointerException if given {@link Callback} is empty + * @see Skill skill info + */ + public void getSkillInfo(int[] ids, Callback> callback) throws GuildWars2Exception, NullPointerException { + isParamValid(new ParamChecker(ids)); + gw2API.getSkillInfo(processIds(ids)).enqueue(callback); + } + //Skins /** diff --git a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java index 3af525c..c77c467 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java @@ -375,6 +375,13 @@ interface GuildWars2API { @GET("/v2/recipes/search") Call> searchOutputRecipes(@Query("output") String id); + //Skills + @GET("/v2/skills") + Call> getAllSkillIDs(); + + @GET("/v2/skills") + Call> getSkillInfo(@Query("ids") String ids); + //skins @GET("/v2/skins") Call> getAllSkinIDs(); diff --git a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java index ca271a4..bbb5859 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java @@ -2098,6 +2098,46 @@ public List searchRecipes(boolean isInput, int id) throws GuildWars2Exc } } + //Skills + + /** + * For more info on Skills API go here
+ * Get list of all available skill ids + * + * @return list of skill ids + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Skill skill info + */ + public List getAllSkillID() throws GuildWars2Exception { + try { + Response> response = gw2API.getAllSkillIDs().execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on Skills API go here
+ * Get skill info for the given skill id(s) + * + * @param ids list of skill id + * @return list of skill info + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Skill skill info + */ + public List getSkillInfo(int[] ids) throws GuildWars2Exception { + isParamValid(new ParamChecker(ids)); + try { + Response> response = gw2API.getSkillInfo(processIds(ids)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + //Skins /** diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/Profession.java b/src/main/java/me/xhsun/guildwars2wrapper/model/Profession.java index 3edb3ed..6465a15 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/Profession.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/Profession.java @@ -1,5 +1,6 @@ package me.xhsun.guildwars2wrapper.model; +import me.xhsun.guildwars2wrapper.model.Skill.Slot; import me.xhsun.guildwars2wrapper.model.indentifiable.IdentifiableInt; import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; import me.xhsun.guildwars2wrapper.model.indentifiable.NameableStr; @@ -20,8 +21,6 @@ public enum TrainingCategory {Skills, Specializations, EliteSpecializations} private enum TrackType {Trait, Skill} - public enum WeaponSlot {Weapon_1, Weapon_2, Weapon_3, Weapon_4, Weapon_5, Profession_1, Profession_2, Profession_3, Profession_4, Profession_5, Utility, Heal, Elite} - public enum Attunement {Fire, Water, Air, Earth} public enum Flag {Mainhand, Offhand, TwoHand, Aquatic, NoRacialSkills, NoWeaponSwap} @@ -156,13 +155,13 @@ public String toString() { } public class Skill extends IdentifiableInt { - private WeaponSlot slot; + private Slot slot; private Type offhand; private Type type; private Attunement attunement; private Item.Restriction source; - public WeaponSlot getSlot() { + public Slot getSlot() { return slot; } diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/Skill.java b/src/main/java/me/xhsun/guildwars2wrapper/model/Skill.java new file mode 100644 index 0000000..4759268 --- /dev/null +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/Skill.java @@ -0,0 +1,156 @@ +package me.xhsun.guildwars2wrapper.model; + +import me.xhsun.guildwars2wrapper.model.indentifiable.Linkable; +import me.xhsun.guildwars2wrapper.model.util.comm.Type; +import me.xhsun.guildwars2wrapper.model.util.skillFact.SkillFact; +import me.xhsun.guildwars2wrapper.model.util.skillFact.SkillTraitedFact; + +import java.util.List; + +/** + * For more info on Skills API go here
+ * Model class for Skill + * + * @author xhsun + * @since 2017-06-15 + */ +public class Skill extends Linkable { + public enum Flag {GroundTargeted, NoUnderwater} + + public enum Category { + Physical, Glyph, Signet, Shout, Well, Consecration, Meditation, + SpiritWeapon, Symbol, Virtue, Ward, Legend, LegendaryAssassin, + LegendaryCentaur, LegendaryDemon, LegendaryDragon, LegendaryDwarf, + Banner, Burst, PrimalBurst, Rage, Stance, kit, Elixir, Gadget, Gyro, + Turret, CelestialAvatar, Pet, Spirit, Survival, Deception, DualWield, + StealthAttack, Trick, Venom, Arcane, Cantrip, Conjure, Overload, + Clone, Glamour, Manipulation, Mantra, Phantasm, Corruption, Mark, + Minion, Spectral, Transform + } + + public enum Slot { + Weapon_1, Weapon_2, Weapon_3, Weapon_4, Weapon_5, + Profession_1, Profession_2, Profession_3, Profession_4, Profession_5, + Downed_1, Downed_2, Downed_3, Downed_4, + Utility, Heal, Elite, Pet + } + + private String description, icon; + private Type type, weapon_type, dual_wield; + private List professions; + private Slot slot; + private List flags; + private List facts; + private List traited_facts; + private List categories; + private Profession.Attunement attunement; + private int cost, flip_skill, initiative, next_chain, prev_chain, toolbelt_skill; + private List transform_skills, bundle_skills;//list of skill id + + public String getDescription() { + return description; + } + + public String getIcon() { + return icon; + } + + public Type getType() { + return type; + } + + public Type getWeapon_type() { + return weapon_type; + } + + public Type getDual_wield() { + return dual_wield; + } + + public List getProfessions() { + return professions; + } + + public Slot getSlot() { + return slot; + } + + public List getFlags() { + return flags; + } + + public List getFacts() { + return facts; + } + + public List getTraited_facts() { + return traited_facts; + } + + public List getCategories() { + return categories; + } + + public Profession.Attunement getAttunement() { + return attunement; + } + + public int getCost() { + return cost; + } + + public int getFlip_skill() { + return flip_skill; + } + + public int getInitiative() { + return initiative; + } + + public int getNext_chain() { + return next_chain; + } + + public int getPrev_chain() { + return prev_chain; + } + + public int getToolbelt_skill() { + return toolbelt_skill; + } + + public List getTransform_skills() { + return transform_skills; + } + + public List getBundle_skills() { + return bundle_skills; + } + + @Override + public String toString() { + return "Skill{" + + super.toString() + + ", description='" + description + '\'' + + ", icon='" + icon + '\'' + + ", type=" + type + + ", weapon_type=" + weapon_type + + ", dual_wield=" + dual_wield + + ", professions=" + professions + + ", slot=" + slot + + ", flags=" + flags + + ", facts=" + facts + + ", traited_facts=" + traited_facts + + ", categories=" + categories + + ", attunement=" + attunement + + ", cost=" + cost + + ", flip_skill=" + flip_skill + + ", initiative=" + initiative + + ", next_chain=" + next_chain + + ", prev_chain=" + prev_chain + + ", toolbelt_skill=" + toolbelt_skill + + ", transform_skills=" + transform_skills + + ", bundle_skills=" + bundle_skills + + '}'; + } +} diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/character/Character.java b/src/main/java/me/xhsun/guildwars2wrapper/model/character/Character.java index d2cc2a1..86ce495 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/character/Character.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/character/Character.java @@ -9,7 +9,6 @@ * For more info on character overview API go here
* Model class for character overview * TODO /v2/wvw/abilities - * TODO /v2/pvp/amulets * * @author xhsun * @since 2017-06-07 diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/util/comm/Type.java b/src/main/java/me/xhsun/guildwars2wrapper/model/util/comm/Type.java index b6503ba..974654d 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/util/comm/Type.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/util/comm/Type.java @@ -40,7 +40,7 @@ public enum Type { //Other recipes type Backpack, Bag, Bulk, Consumable, Dye, Potion, UpgradeComponent, //Other - Nothing, + Nothing, None, //Skill Type - Profession, Heal, Elite + Profession, Heal, Elite, Bundle, Weapon } diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/ItemAttributes.java b/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/ItemAttributes.java index fc0be5d..248b4a5 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/ItemAttributes.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/ItemAttributes.java @@ -10,6 +10,11 @@ * @since 2017-02-07 */ public class ItemAttributes { + public enum Attribute { + Power, Precision, Toughness, Vitality, ConditionDamage, + ConditionDuration, Healing, BoonDuration, CritDamage, + AgonyResistance + } private float Power; private float Precision; private float Toughness; diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/ItemDetail.java b/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/ItemDetail.java index a31a484..dce2a1b 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/ItemDetail.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/ItemDetail.java @@ -26,11 +26,6 @@ public enum Unlock { GliderSkin, Champion } - public enum Attribute { - BoonDuration, ConditionDamage, ConditionDuration, CritDamage, Healing, - Power, Precision, Toughness, Vitality - } - public enum Flag { //Upgrade component flag Axe, Dagger, Mace, Pistol, Scepter, Sword, Focus, Shield, Torch, Warhorn, Greatsword, Hammer, diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/subobject/InfixAttribute.java b/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/subobject/InfixAttribute.java index 440f17e..c4b4a09 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/subobject/InfixAttribute.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/util/itemDetail/subobject/InfixAttribute.java @@ -1,6 +1,6 @@ package me.xhsun.guildwars2wrapper.model.util.itemDetail.subobject; -import me.xhsun.guildwars2wrapper.model.util.itemDetail.ItemDetail; +import me.xhsun.guildwars2wrapper.model.util.itemDetail.ItemAttributes; /** * Infix attribute model class @@ -11,10 +11,10 @@ */ public class InfixAttribute { - private ItemDetail.Attribute attribute; + private ItemAttributes.Attribute attribute; private int modifier; - public ItemDetail.Attribute getAttribute() { + public ItemAttributes.Attribute getAttribute() { return attribute; } diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/BooleanAdapter.java b/src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/BooleanAdapter.java new file mode 100644 index 0000000..a877987 --- /dev/null +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/BooleanAdapter.java @@ -0,0 +1,27 @@ +package me.xhsun.guildwars2wrapper.model.util.skillFact; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; + +import java.lang.reflect.Type; + +/** + * Use for {@link SkillFact} for when type is {@link me.xhsun.guildwars2wrapper.model.util.skillFact.SkillFact.Type#Unblockable} + * the value is boolean instead of int + * + * @author xhsun + * @since 2017-06-15 + */ +public class BooleanAdapter implements JsonDeserializer { + + @Override + public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + try { + return json.getAsInt(); + } catch (NumberFormatException e) { + return (json.getAsBoolean()) ? 1 : 0; + } + } +} \ No newline at end of file diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/SkillFact.java b/src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/SkillFact.java new file mode 100644 index 0000000..921f8d8 --- /dev/null +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/SkillFact.java @@ -0,0 +1,128 @@ +package me.xhsun.guildwars2wrapper.model.util.skillFact; + +import com.google.gson.annotations.JsonAdapter; +import me.xhsun.guildwars2wrapper.model.util.itemDetail.ItemAttributes; + +/** + * Skill fact class for {@link me.xhsun.guildwars2wrapper.model.Skill} + * + * @author xhsun + * @since 2017-06-17 + */ +public class SkillFact { + public enum Type { + AttributeAdjust, Buff, ComboField, ComboFinisher, + Damage, Distance, Duration, Heal, HealingAdjust, + NoData, Number, Percent, PrefixedBuff, Radius, + Range, Recharge, Time, Unblockable + } + + public enum Effect { + Aegis, Fury, Might, Protection, Quickness, Regeneration, Resistance, + Retaliation, Stability, Swiftness, Vigor, + Bleeding, Blind, Burning, Chilled, Confusion, Crippled, Fear, Immobile, Poison, Slow, Taunt, Torment, + Vulnerability, Weakness, + Daze, Float, Knockback, Knockdown, Launch, Pull, Sink, Stun, + Agony, Alacrity, Invulnerability, Revealed, Stealth, Superspeed + } + + public enum Field { + Air, Dark, Fire, Ice, Light, Lightning, Poison, Smoke, Ethereal, Water + } + + public enum Finisher {Blast, Leap, Projectile, Whirl} + + private String text, icon, description; + private Type type; + private int apply_count, duration, percent, hit_count, distance; + @JsonAdapter(BooleanAdapter.class) + private int value; + private float dmg_multiplier; + private ItemAttributes.Attribute target; + private Effect status; + private Field field_type; + private Finisher finisher_type; + private SkillFact prefix; + + public String getText() { + return text; + } + + public String getIcon() { + return icon; + } + + public String getDescription() { + return description; + } + + public Type getType() { + return type; + } + + public int getApply_count() { + return apply_count; + } + + public int getDuration() { + return duration; + } + + public int getPercent() { + return percent; + } + + public int getHit_count() { + return hit_count; + } + + public int getDistance() { + return distance; + } + + public float getDmg_multiplier() { + return dmg_multiplier; + } + + public ItemAttributes.Attribute getTarget() { + return target; + } + + public Effect getStatus() { + return status; + } + + public Field getField_type() { + return field_type; + } + + public Finisher getFinisher_type() { + return finisher_type; + } + + public SkillFact getPrefix() { + return prefix; + } + + @Override + public String toString() { + return "SkillFact{" + + "text='" + text + '\'' + + ", icon='" + icon + '\'' + + ", description='" + description + '\'' + + ", type=" + type + + ", apply_count=" + apply_count + + ", duration=" + duration + + ", percent=" + percent + + ", hit_count=" + hit_count + + ", distance=" + distance + + ", value=" + value + + ", dmg_multiplier=" + dmg_multiplier + + ", target=" + target + + ", status=" + status + + ", field_type=" + field_type + + ", finisher_type=" + finisher_type + + ", prefix=" + prefix + + '}'; + } +} diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/SkillTraitedFact.java b/src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/SkillTraitedFact.java new file mode 100644 index 0000000..9ec427e --- /dev/null +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/SkillTraitedFact.java @@ -0,0 +1,28 @@ +package me.xhsun.guildwars2wrapper.model.util.skillFact; + +/** + * Skill traited fact class for {@link me.xhsun.guildwars2wrapper.model.Skill} + * + * @author xhsun + * @since 2017-06-17 + */ +public class SkillTraitedFact extends SkillFact { + private int requires_trait, overrides; + + public int getRequires_trait() { + return requires_trait; + } + + public int getOverrides() { + return overrides; + } + + @Override + public String toString() { + return "SkillTraitedFact{" + + super.toString() + + ", requires_trait=" + requires_trait + + ", overrides=" + overrides + + '}'; + } +} From f74e7dc6176fccc78e9d3291fb277741c8cfc549 Mon Sep 17 00:00:00 2001 From: xhsun Date: Thu, 15 Jun 2017 16:34:41 -0600 Subject: [PATCH 11/13] done specialization API --- .../AsynchronousRequest.java | 29 ++++++++++ .../guildwars2wrapper/GuildWars2API.java | 7 +++ .../guildwars2wrapper/SynchronousRequest.java | 40 +++++++++++++ .../model/Specialization.java | 56 +++++++++++++++++++ .../model/character/CharacterSkills.java | 2 +- .../character/CharacterSpecialization.java | 1 - 6 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 src/main/java/me/xhsun/guildwars2wrapper/model/Specialization.java diff --git a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java index 4b462f3..7660bde 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java @@ -1606,6 +1606,35 @@ public void getSkinInfo(int[] ids, Callback> callback) throws GuildWa gw2API.getSkinInfo(processIds(ids)).enqueue(callback); } + //Specializations + + /** + * For more info on specializations API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws NullPointerException if given {@link Callback} is empty + * @see Specialization specialization info + */ + public void getAllSpecializationID(Callback> callback) throws NullPointerException { + gw2API.getAllSpecializationIDs().enqueue(callback); + } + + /** + * For more info on specializations API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param ids list of specialization id + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws GuildWars2Exception empty ID list + * @throws NullPointerException if given {@link Callback} is empty + * @see Specialization specialization info + */ + public void getSpecializationInfo(int[] ids, Callback> callback) throws GuildWars2Exception, NullPointerException { + isParamValid(new ParamChecker(ids)); + gw2API.getSpecializationInfo(processIds(ids)).enqueue(callback); + } + //Titles /** diff --git a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java index c77c467..e1c55d4 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java @@ -389,6 +389,13 @@ interface GuildWars2API { @GET("/v2/skins") Call> getSkinInfo(@Query("ids") String ids); + //Specializations + @GET("/v2/specializations") + Call> getAllSpecializationIDs(); + + @GET("/v2/specializations") + Call> getSpecializationInfo(@Query("ids") String ids); + //Titles @GET("/v2/titles") Call> getAllTitleIDs(); diff --git a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java index bbb5859..68ab6de 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java @@ -2178,6 +2178,46 @@ public List getSkinInfo(int[] ids) throws GuildWars2Exception { } } + //Specializations + + /** + * For more info on specializations API go here
+ * Get all specialization id(s) + * + * @return list of specialization id(s) + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Specialization specialization info + */ + public List getAllSpecializationID() throws GuildWars2Exception { + try { + Response> response = gw2API.getAllSpecializationIDs().execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on specializations API go here
+ * Get specialization info for the specialization title id(s) + * + * @param ids list of specialization id(s) + * @return list of specialization info + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Specialization specialization info + */ + public List getSpecializationInfo(int[] ids) throws GuildWars2Exception { + isParamValid(new ParamChecker(ids)); + try { + Response> response = gw2API.getSpecializationInfo(processIds(ids)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + //Titles /** diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/Specialization.java b/src/main/java/me/xhsun/guildwars2wrapper/model/Specialization.java new file mode 100644 index 0000000..ee6795c --- /dev/null +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/Specialization.java @@ -0,0 +1,56 @@ +package me.xhsun.guildwars2wrapper.model; + +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; + +import java.util.List; + +/** + * For more info on specializations API go here
+ * Model class for specialization + * + * @author xhsun + * @since 2017-06-15 + */ +public class Specialization extends NameableInt { + private Item.Restriction profession; + private boolean elite; + private String background, icon; + private List minor_traits, major_traits; + + public Item.Restriction getProfession() { + return profession; + } + + public boolean isElite() { + return elite; + } + + public String getIcon() { + return icon; + } + + public String getBackground() { + return background; + } + + public List getMinor_traits() { + return minor_traits; + } + + public List getMajor_traits() { + return major_traits; + } + + @Override + public String toString() { + return "Specialization{" + + super.toString() + + ", profession=" + profession + + ", elite=" + elite + + ", icon='" + icon + '\'' + + ", background='" + background + '\'' + + ", minor_traits=" + minor_traits + + ", major_traits=" + major_traits + + '}'; + } +} diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSkills.java b/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSkills.java index 37fdac4..6746219 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSkills.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSkills.java @@ -5,8 +5,8 @@ /** * For more info on character skills API go here
* Model class for character skills level - * TODO /v2/skills * + * @see me.xhsun.guildwars2wrapper.model.Skill * @author xhsun * @since 2017-06-07 */ diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSpecialization.java b/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSpecialization.java index a7ca313..e4affaf 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSpecialization.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSpecialization.java @@ -7,7 +7,6 @@ /** * For more info on character specializations API go here
* Model class for character specialization - * TODO /v2/specializations * TODO /v2/traits * * @author xhsun From 20e1ac343e11b1b7edd3c42ea4bd43068333c32f Mon Sep 17 00:00:00 2001 From: xhsun Date: Thu, 15 Jun 2017 16:57:54 -0600 Subject: [PATCH 12/13] done trait API --- .../AsynchronousRequest.java | 29 +++++ .../guildwars2wrapper/GuildWars2API.java | 7 ++ .../guildwars2wrapper/SynchronousRequest.java | 40 +++++++ .../xhsun/guildwars2wrapper/model/Trait.java | 110 ++++++++++++++++++ .../character/CharacterSpecialization.java | 1 - .../model/util/skillFact/SkillFact.java | 21 +++- 6 files changed, 201 insertions(+), 7 deletions(-) create mode 100644 src/main/java/me/xhsun/guildwars2wrapper/model/Trait.java diff --git a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java index 7660bde..7dbec14 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java @@ -1664,6 +1664,35 @@ public void getTitleInfo(int[] ids, Callback> callback) throws Guild gw2API.getTitleInfo(processIds(ids)).enqueue(callback); } + //Traits + + /** + * For more info on traits API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws NullPointerException if given {@link Callback} is empty + * @see Trait trait info + */ + public void getAllTraitID(Callback> callback) throws NullPointerException { + gw2API.getAllTraitIDs().enqueue(callback); + } + + /** + * For more info on traits API go here
+ * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param ids list of trait id + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws GuildWars2Exception empty ID list + * @throws NullPointerException if given {@link Callback} is empty + * @see Trait trait info + */ + public void getTraitInfo(int[] ids, Callback> callback) throws GuildWars2Exception, NullPointerException { + isParamValid(new ParamChecker(ids)); + gw2API.getTraitInfo(processIds(ids)).enqueue(callback); + } + //Worlds /** diff --git a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java index e1c55d4..973b3fc 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java @@ -403,6 +403,13 @@ interface GuildWars2API { @GET("/v2/titles") Call> getTitleInfo(@Query("ids") String ids); + //Traits + @GET("/v2/traits") + Call> getAllTraitIDs(); + + @GET("/v2/traits") + Call> getTraitInfo(@Query("ids") String ids); + //worlds @GET("/v2/worlds") Call> getAllWorldsIDs(); diff --git a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java index 68ab6de..d074f2e 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java @@ -2258,6 +2258,46 @@ public List getTitleInfo(int[] ids) throws GuildWars2Exception { } } + //Trait + + /** + * For more info on traits API go <a href="https://wiki.guildwars2.com/wiki/API:2/traits">here</a><br/> + * Get list of all available trait id(s) + * + * @return list of trait id + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Trait trait info + */ + public List<Integer> getAllTraitID() throws GuildWars2Exception { + try { + Response<List<Integer>> response = gw2API.getAllTraitIDs().execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on traits API go <a href="https://wiki.guildwars2.com/wiki/API:2/traits">here</a><br/> + * Get trait info for the given trait id(s) + * + * @param ids list of trait id + * @return list of trait info + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Trait trait info + */ + public List<Trait> getTraitInfo(int[] ids) throws GuildWars2Exception { + isParamValid(new ParamChecker(ids)); + try { + Response<List<Trait>> response = gw2API.getTraitInfo(processIds(ids)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + //Worlds /** diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/Trait.java b/src/main/java/me/xhsun/guildwars2wrapper/model/Trait.java new file mode 100644 index 0000000..c4ed9e6 --- /dev/null +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/Trait.java @@ -0,0 +1,110 @@ +package me.xhsun.guildwars2wrapper.model; + +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; +import me.xhsun.guildwars2wrapper.model.util.skillFact.SkillFact; +import me.xhsun.guildwars2wrapper.model.util.skillFact.SkillTraitedFact; + +import java.util.List; + +/** + * For more info on traits API go <a href="https://wiki.guildwars2.com/wiki/API:2/traits">here</a><br/> + * Model class for traits + * + * @author xhsun + * @since 2017-06-05 + */ +public class Trait extends NameableInt { + public enum Slot {Major, Minor} + + private String icon, description; + private Slot slot; + private int specialization, tier, order; + private List<SkillFact> facts; + private List<SkillTraitedFact> traited_facts; + private List<Skill> skills; + + public String getIcon() { + return icon; + } + + public String getDescription() { + return description; + } + + public Slot getSlot() { + return slot; + } + + public int getSpecialization() { + return specialization; + } + + public int getTier() { + return tier; + } + + public int getOrder() { + return order; + } + + public List<SkillFact> getFacts() { + return facts; + } + + public List<SkillTraitedFact> getTraited_facts() { + return traited_facts; + } + + public List<Skill> getSkills() { + return skills; + } + + @Override + public String toString() { + return "Trait{" + + super.toString() + + ", icon='" + icon + '\'' + + ", description='" + description + '\'' + + ", slot=" + slot + + ", specialization=" + specialization + + ", order=" + order + + ", tier=" + tier + + ", facts=" + facts + + ", traited_facts=" + traited_facts + + ", skills=" + skills + + '}'; + } + + public class Skill extends NameableInt { + private String description, icon; + private List<SkillFact> facts; + private List<SkillTraitedFact> traited_facts; + + public String getDescription() { + return description; + } + + public String getIcon() { + return icon; + } + + public List<SkillFact> getFacts() { + return facts; + } + + public List<SkillTraitedFact> getTraited_facts() { + return traited_facts; + } + + @Override + public String toString() { + return "Skill{" + + super.toString() + + ", description='" + description + '\'' + + ", icon='" + icon + '\'' + + ", facts=" + facts + + ", traited_facts=" + traited_facts + + '}'; + } + } +} diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSpecialization.java b/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSpecialization.java index e4affaf..baf934e 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSpecialization.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/character/CharacterSpecialization.java @@ -7,7 +7,6 @@ /** * For more info on character specializations API go <a href="https://wiki.guildwars2.com/wiki/API:2/characters#Specialization">here</a><br/> * Model class for character specialization - * TODO /v2/traits * * @author xhsun * @since 2017-06-07 diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/SkillFact.java b/src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/SkillFact.java index 921f8d8..79f9aae 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/SkillFact.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/util/skillFact/SkillFact.java @@ -38,7 +38,7 @@ public enum Finisher {Blast, Leap, Projectile, Whirl} @JsonAdapter(BooleanAdapter.class) private int value; private float dmg_multiplier; - private ItemAttributes.Attribute target; + private ItemAttributes.Attribute target, source; private Effect status; private Field field_type; private Finisher finisher_type; @@ -60,7 +60,7 @@ public Type getType() { return type; } - public int getApply_count() { + public int getApplyCount() { return apply_count; } @@ -72,7 +72,7 @@ public int getPercent() { return percent; } - public int getHit_count() { + public int getHitCount() { return hit_count; } @@ -80,7 +80,7 @@ public int getDistance() { return distance; } - public float getDmg_multiplier() { + public float getDamageMultiplier() { return dmg_multiplier; } @@ -88,15 +88,23 @@ public ItemAttributes.Attribute getTarget() { return target; } + public int getValue() { + return value; + } + + public ItemAttributes.Attribute getSource() { + return source; + } + public Effect getStatus() { return status; } - public Field getField_type() { + public Field getFieldType() { return field_type; } - public Finisher getFinisher_type() { + public Finisher getFinisherType() { return finisher_type; } @@ -119,6 +127,7 @@ public String toString() { ", value=" + value + ", dmg_multiplier=" + dmg_multiplier + ", target=" + target + + ", source=" + source + ", status=" + status + ", field_type=" + field_type + ", finisher_type=" + finisher_type + From 439a1758ed268210a759f3d45553f6f3ac361419 Mon Sep 17 00:00:00 2001 From: xhsun <xhsun@ucalgary.ca> Date: Thu, 15 Jun 2017 17:06:49 -0600 Subject: [PATCH 13/13] done wvw abilities API --- .../AsynchronousRequest.java | 31 ++++++++++ .../guildwars2wrapper/GuildWars2API.java | 8 +++ .../guildwars2wrapper/SynchronousRequest.java | 41 +++++++++++++ .../model/character/Character.java | 1 - .../guildwars2wrapper/model/wvw/Ability.java | 60 +++++++++++++++++++ 5 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 src/main/java/me/xhsun/guildwars2wrapper/model/wvw/Ability.java diff --git a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java index 7dbec14..69bb712 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java @@ -24,6 +24,7 @@ import me.xhsun.guildwars2wrapper.model.unlockable.Glider; import me.xhsun.guildwars2wrapper.model.unlockable.MailCarrier; import me.xhsun.guildwars2wrapper.model.unlockable.Outfit; +import me.xhsun.guildwars2wrapper.model.wvw.Ability; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; @@ -1721,4 +1722,34 @@ public void getWorldInfo(int[] ids, Callback<List<World>> callback) throws Guild isParamValid(new ParamChecker(ids)); gw2API.getWorldsInfo(processIds(ids)).enqueue(callback); } + + //WvW Abilities + + /** + * For more info on WvW abilities API go <a href="https://wiki.guildwars2.com/wiki/API:2/wvw/abilities">here</a><br/> + * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws NullPointerException if given {@link Callback} is empty + * @see Ability WvW abilities info + */ + public void getAllWvWAbilityID(Callback<List<Integer>> callback) throws NullPointerException { + gw2API.getAllWvWAbilityIDs().enqueue(callback); + } + + /** + * For more info on WvW abilities API go <a href="https://wiki.guildwars2.com/wiki/API:2/wvw/abilities">here</a><br/> + * Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions + * + * @param ids list of WvW abilities id + * @param callback callback that is going to be used for {@link Call#enqueue(Callback)} + * @throws GuildWars2Exception empty ID list + * @throws NullPointerException if given {@link Callback} is empty + * @see Ability WvW abilities info + */ + public void getWvWAbilityInfo(int[] ids, Callback<List<Ability>> callback) throws GuildWars2Exception, NullPointerException { + isParamValid(new ParamChecker(ids)); + gw2API.getWvWAbilityInfo(processIds(ids)).enqueue(callback); + } + } diff --git a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java index 973b3fc..f1d0016 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java @@ -23,6 +23,7 @@ import me.xhsun.guildwars2wrapper.model.unlockable.Glider; import me.xhsun.guildwars2wrapper.model.unlockable.MailCarrier; import me.xhsun.guildwars2wrapper.model.unlockable.Outfit; +import me.xhsun.guildwars2wrapper.model.wvw.Ability; import retrofit2.Call; import retrofit2.http.GET; import retrofit2.http.Path; @@ -416,4 +417,11 @@ interface GuildWars2API { @GET("/v2/worlds") Call<List<World>> getWorldsInfo(@Query("ids") String ids); + + //WvW Abilities + @GET("/v2/wvw/abilities") + Call<List<Integer>> getAllWvWAbilityIDs(); + + @GET("/v2/wvw/abilities") + Call<List<Ability>> getWvWAbilityInfo(@Query("ids") String ids); } diff --git a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java index d074f2e..18488d0 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java @@ -25,6 +25,7 @@ import me.xhsun.guildwars2wrapper.model.unlockable.Glider; import me.xhsun.guildwars2wrapper.model.unlockable.MailCarrier; import me.xhsun.guildwars2wrapper.model.unlockable.Outfit; +import me.xhsun.guildwars2wrapper.model.wvw.Ability; import retrofit2.Response; import java.io.IOException; @@ -2337,4 +2338,44 @@ public List<World> getWorldInfo(int[] ids) throws GuildWars2Exception { throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); } } + + //WvW Abilities + + /** + * For more info on WvW abilities API go <a href="https://wiki.guildwars2.com/wiki/API:2/wvw/abilities">here</a><br/> + * Get list of all available wvw ability id(s) + * + * @return list of wvw ability id + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Ability wvw ability info + */ + public List<Integer> getAllWvWAbilityID() throws GuildWars2Exception { + try { + Response<List<Integer>> response = gw2API.getAllWvWAbilityIDs().execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } + + /** + * For more info on WvW abilities API go <a href="https://wiki.guildwars2.com/wiki/API:2/wvw/abilities">here</a><br/> + * Get wvw ability info for the given world id(s) + * + * @param ids list of wvw ability id + * @return list of wvw ability info + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Ability wvw ability info + */ + public List<Ability> getWvWAbilityInfo(int[] ids) throws GuildWars2Exception { + isParamValid(new ParamChecker(ids)); + try { + Response<List<Ability>> response = gw2API.getWvWAbilityInfo(processIds(ids)).execute(); + if (!response.isSuccessful()) throwError(response.code(), response.errorBody()); + return response.body(); + } catch (IOException e) { + throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage()); + } + } } diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/character/Character.java b/src/main/java/me/xhsun/guildwars2wrapper/model/character/Character.java index 86ce495..5258b24 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/character/Character.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/character/Character.java @@ -8,7 +8,6 @@ /** * For more info on character overview API go <a href="https://wiki.guildwars2.com/wiki/API:2/characters">here</a><br/> * Model class for character overview - * TODO /v2/wvw/abilities * * @author xhsun * @since 2017-06-07 diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/wvw/Ability.java b/src/main/java/me/xhsun/guildwars2wrapper/model/wvw/Ability.java new file mode 100644 index 0000000..bbf578d --- /dev/null +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/wvw/Ability.java @@ -0,0 +1,60 @@ +package me.xhsun.guildwars2wrapper.model.wvw; + +import me.xhsun.guildwars2wrapper.model.indentifiable.NameableInt; + +import java.util.List; + +/** + * For more info on WvW abilities API go <a href="https://wiki.guildwars2.com/wiki/API:2/wvw/abilities">here</a><br/> + * Model class for WvW abilities + * + * @author xhsun + * @since 2017-06-15 + */ +public class Ability extends NameableInt { + private String icon, description; + private List<Rank> ranks; + + public String getIcon() { + return icon; + } + + public String getDescription() { + return description; + } + + public List<Rank> getRanks() { + return ranks; + } + + @Override + public String toString() { + return "Ability{" + + super.toString() + + ", icon='" + icon + '\'' + + ", description='" + description + '\'' + + ", ranks=" + ranks + + '}'; + } + + public class Rank { + private int cost; + private String effect; + + public int getCost() { + return cost; + } + + public String getEffect() { + return effect; + } + + @Override + public String toString() { + return "Rank{" + + "cost=" + cost + + ", effect='" + effect + '\'' + + '}'; + } + } +}