Remove Gist
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package de.jeyp91.teamidmatcher;
|
||||
|
||||
import de.jeyp91.apifootball.APIFootballConnector;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class TeamIDMatcherTemplateCreator {
|
||||
APIFootballConnector con;
|
||||
JSONArray teams;
|
||||
|
||||
public TeamIDMatcherTemplateCreator(int season, int league) {
|
||||
this.con = APIFootballConnector.getAPIFootballConnectorInstance(season);
|
||||
JSONObject apiObject = con.getTeamsForLeague(league);
|
||||
JSONObject teamsObject = (JSONObject) apiObject.get("api");
|
||||
this.teams = (JSONArray) teamsObject.get("teams");
|
||||
}
|
||||
|
||||
public String getTeamsTemplate() {
|
||||
String teamsTemplate = "";
|
||||
for (Object team : this.teams) {
|
||||
JSONObject teamObject = (JSONObject) team;
|
||||
teamsTemplate += ",\n";
|
||||
teamsTemplate += " {\n";
|
||||
teamsTemplate += " \"teamname\": \"" + teamObject.get("name") + "\",\n";
|
||||
teamsTemplate += " \"tippligaID\": " + ",\n";
|
||||
teamsTemplate += " \"apiFootballID\": " + teamObject.get("team_id") + "\n";
|
||||
teamsTemplate += " }";
|
||||
}
|
||||
return teamsTemplate;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user