use of org.magic.api.beans.MagicRuling in project MtgDesktopCompanion by nicho92.
the class ScryFallProvider method generateRules.
private void generateRules(MagicCard mc) throws IOException {
String url = "https://api.scryfall.com/cards/" + mc.getId() + "/rulings";
HttpURLConnection con = (HttpURLConnection) getConnection(url);
JsonElement el = parser.parse(new JsonReader(new InputStreamReader(con.getInputStream(), encoding)));
JsonArray arr = el.getAsJsonObject().get("data").getAsJsonArray();
for (int i = 0; i < arr.size(); i++) {
JsonObject obr = arr.get(i).getAsJsonObject();
MagicRuling rul = new MagicRuling();
rul.setDate(obr.get("published_at").getAsString());
rul.setText(obr.get("comment").getAsString());
mc.getRulings().add(rul);
}
}
Aggregations