runelite-client: use new bulk item price api

This commit is contained in:
Adam
2018-06-09 20:09:16 -04:00
parent 3b17c3e892
commit a1ae397e11
12 changed files with 104 additions and 369 deletions

View File

@@ -169,4 +169,35 @@ public class ItemClient
throw new IOException(ex);
}
}
public ItemPrice[] getPrices() throws IOException
{
HttpUrl.Builder urlBuilder = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("item")
.addPathSegment("prices");
HttpUrl url = urlBuilder.build();
logger.debug("Built URI: {}", url);
Request request = new Request.Builder()
.url(url)
.build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
{
if (!response.isSuccessful())
{
logger.warn("Error looking up prices: {}", response.message());
return null;
}
InputStream in = response.body().byteStream();
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), ItemPrice[].class);
}
catch (JsonParseException ex)
{
throw new IOException(ex);
}
}
}