diff --git a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java index 69bb712..8dcf8b8 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java @@ -542,6 +542,35 @@ public void getCurrentGameBuild(Callback callback) throws NullPointer gw2API.getCurrentGameBuild().enqueue(callback); } + //Cats + + /** + * For more info on cats 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 Cat cat info + */ + public void getAllCatID(Callback> callback) throws NullPointerException { + gw2API.getAllCatIDs().enqueue(callback); + } + + /** + * For more info on cats 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 cat 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 Cat cat info + */ + public void getCatInfo(int[] ids, Callback> callback) throws GuildWars2Exception, NullPointerException { + isParamValid(new ParamChecker(ids)); + gw2API.getCatInfo(processIds(ids)).enqueue(callback); + } + //Characters /** * For more info on Character API go here
diff --git a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java index f1d0016..3be073d 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java @@ -148,7 +148,12 @@ interface GuildWars2API { @GET("/v2/build") Call getCurrentGameBuild(); - //TODO /v2/cats + //Cats + @GET("/v2/cats") + Call> getAllCatIDs(); + + @GET("/v2/cats") + Call> getCatInfo(@Query("ids") String ids); //characters @GET("/v2/characters") diff --git a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java index 18488d0..657c5c7 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java @@ -724,6 +724,46 @@ public GameBuild getCurrentGameBuild() throws GuildWars2Exception { } } + //Cats + + /** + * For more info on cats API go here
+ * Get list of all available cat id(s) + * + * @return list of cat id(s) + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Color cat info + */ + public List getAllCatID() throws GuildWars2Exception { + try { + Response> response = gw2API.getAllCatIDs().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 cats API go here
+ * Get cat info for the given cat id(s) + * + * @param ids array of cat id + * @return list of cat info + * @throws GuildWars2Exception see {@link ErrorCode} for detail + * @see Cat cat info + */ + public List getCatInfo(int[] ids) throws GuildWars2Exception { + isParamValid(new ParamChecker(ids)); + try { + Response> response = gw2API.getCatInfo(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()); + } + } + //Characters /** * For more info on Character API go here
diff --git a/src/main/java/me/xhsun/guildwars2wrapper/model/account/Cat.java b/src/main/java/me/xhsun/guildwars2wrapper/model/Cat.java similarity index 68% rename from src/main/java/me/xhsun/guildwars2wrapper/model/account/Cat.java rename to src/main/java/me/xhsun/guildwars2wrapper/model/Cat.java index d8af293..92ee646 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/model/account/Cat.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/model/Cat.java @@ -1,9 +1,10 @@ -package me.xhsun.guildwars2wrapper.model.account; +package me.xhsun.guildwars2wrapper.model; import me.xhsun.guildwars2wrapper.model.indentifiable.IdentifiableInt; /** - * Cat + * For more info on cats API go here
+ * Model class for cats * * @author xhsun * @since 2017-06-05