![JAR search and dependency download from the Maven repository](/logo.png)
com.sportdataapi.client.VenuesClient 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.Venue;
import com.sportdataapi.util.AbstractClient;
import com.sportdataapi.util.Response;
/**
* The venues client.
* Attention! You shall never create this client directly but use {@link SoccerClient#venues()} instead.
* @author ralph
*
*/
public class VenuesClient extends AbstractClient {
/**
* Constructor.
* @param target - the target to request
*/
public VenuesClient(WebTarget target) {
super(target.path("venues"));
}
/**
* Request and return the list of venues for a country.
* @param countryId - the ID of the country to query
* @return list of venues for the country
*/
public List list(int countryId) {
if (countryId <= 0) throw new RuntimeException("countryId must be a positive number");
Response> response = registerRequest(getTarget().queryParam("country_id", ""+countryId)).request().get(new GenericType>>() {});
return response.getData();
}
/**
* Request and returns a specific venue.
* @param id - id of venue
* @return the venue requested or {@code null}
*/
public Venue 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