Closed 21echoes closed 6 years ago
https://github.com/Patreon/patreon-java/pull/4 was super awesome, but needed some help getting over the finish line.
In total, this PR moves away from the sad world of:
JSONObject userResponse = apiClient.fetchUser(); JSONObject user = userResponse.getJSONObject("data"); JSONArray included = userResponse.getJSONArray("included"); JSONObject pledge = null; JSONObject campaign = null; if (included != null) { for (int i = 0; i < included.length(); i++) { JSONObject object = included.getJSONObject(i); if (object.getString("type").equals("pledge") && object.getJSONObject("relationships").getJSONObject("creator").getJSONObject("data").getString("id").equals(creatorID)) { pledge = object; break; } } for (int i = 0; i < included.length(); i++) { JSONObject object = included.getJSONObject(i); if (object.getString("type").equals("campaign") && object.getJSONObject("relationships").getJSONObject("creator").getJSONObject("data").getString("id").equals(creatorID)) { campaign = object; break; } } }
into the happy world of:
JSONAPIDocument<User> userResponse = apiClient.fetchUser(); User user = userResponse.get(); List<Pledge> pledges = user.getPledges() if (pledges != null && pledges.size() > 0) { Pledge pledge = pledges.get(0); }
https://github.com/Patreon/patreon-java/pull/4 was super awesome, but needed some help getting over the finish line.
In total, this PR moves away from the sad world of:
into the happy world of: