![JAR search and dependency download from the Maven repository](/logo.png)
com.sportdataapi.client.LeaguesClient 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.ArrayList;
import java.util.List;
import java.util.Map;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.GenericType;
import com.sportdataapi.data.League;
import com.sportdataapi.util.AbstractClient;
import com.sportdataapi.util.Response;
/**
* The leagues client.
* Attention! You shall never create this client directly but use {@link SoccerClient#leagues()} instead.
* @author ralph
*
*/
public class LeaguesClient extends AbstractClient {
/**
* Constructor.
* @param target - the target to request
*/
public LeaguesClient(WebTarget target) {
super(target.path("leagues"));
}
/**
* Request and return the list of all leagues.
* Same as {@code list(false);}
* @return list of leagues
*/
public List list() {
return list(false);
}
/**
* Request and return the list of all leagues.
* @param subscribedOnly - limit result to subscribed leagues only
* @return list of leagues
*/
public List list(boolean subscribedOnly) {
WebTarget target = getTarget();
if (subscribedOnly) target = target.queryParam("subscribed", subscribedOnly);
Response> response = registerRequest(target).request().get(new GenericType>>() {});
return response.getData();
}
/**
* Request and return the list of leagues in a country.
* @param countryId - list leagues of this country only
* @return list of leagues
*/
public List list(int countryId) {
if (countryId <= 0) throw new RuntimeException("countryId must be a positive number");
WebTarget target = getTarget().queryParam("country_id", countryId);
Response
© 2015 - 2025 Weber Informatics LLC | Privacy Policy