![JAR search and dependency download from the Maven repository](/logo.png)
com.sportdataapi.client.SeasonsClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sportdata-api-client Show documentation
Show all versions of sportdata-api-client Show documentation
A simple sportdataapi.com client.
The newest version!
/**
*
*/
package com.sportdataapi.client;
import java.util.List;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.GenericType;
import com.sportdataapi.data.Season;
import com.sportdataapi.util.AbstractClient;
import com.sportdataapi.util.Response;
/**
* The seasons client.
* Attention! You shall never create this client directly but use {@link SoccerClient#seasons()} instead.
* @author ralph
*
*/
public class SeasonsClient extends AbstractClient {
/**
* Constructor.
* @param target - the target to request
*/
public SeasonsClient(WebTarget target) {
super(target.path("seasons"));
}
/**
* Request and return the list of seasons for a specific league.
* @param leagueId - the ID of the league to query
* @return list of seasons for the league
*/
public List list(int leagueId) {
if (leagueId <= 0) throw new RuntimeException("leagueId must be a positive number");
Response> response = registerRequest(getTarget().queryParam("league_id", ""+leagueId)).request().get(new GenericType>>() {});
return response.getData();
}
/**
* Request and returns a specific season.
* @param id - id of season
* @return the season requested or {@code null}
*/
public Season get(int id) {
try {
Response response = registerRequest(getTarget().path(""+id)).request().get(new GenericType>() {});
return response.getData();
} catch (NotFoundException e) {
return null;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy