public class PublicHolidayAPI extends Object implements HolidaySearcher
app.pickmaven.businessdays.api.HolidaySearcher interface for getting a list of LocalDate objects representing
the holidays for specific countries using the app.pickmaven.businessdays.api.PublicHolidayAPI of RapidAPI.
This class is immutable and thread-safe.
| Modifier and Type | Field and Description |
|---|---|
static String |
PUBLIC_HOLIDAY_P_RAPIDAPI_COM
Base endpoint for calling the Rapid Api of Public app.pickmaven.businessdays.Holiday.
|
| Constructor and Description |
|---|
PublicHolidayAPI(String api_key)
Constructor
In order to get an api key from RapidApi you have to log in to your Developer Dashboard
and create a new App; then just grab the api key and pass it in the constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
activateLogResponse()
Sets logging response to true.
|
PublicHolidayAPI |
applyPredicate(java.util.function.Predicate<? super com.google.gson.JsonObject> predicate)
Call this method for apply a {@code Predicate
|
List<java.time.LocalDate> |
searchHolidaysFor(String countryCode)
Returns a list of
LocalDate representing the holidays for a specific country. |
List<java.time.LocalDate> |
searchHolidaysFor(String countryCode,
int year)
Returns a list of
LocalDate representing the holidays for a specific country and for specific year. |
public static final String PUBLIC_HOLIDAY_P_RAPIDAPI_COM
public PublicHolidayAPI(String api_key)
In order to get an api key from RapidApi you have to log in to your Developer Dashboard and create a new App; then just grab the api key and pass it in the constructor.
api_key - personal api-key, not nullpublic PublicHolidayAPI applyPredicate(java.util.function.Predicate<? super com.google.gson.JsonObject> predicate)
Predicate<? super JsonObject> in order to filter the holidays.
In order to know the fields that Api will give you in response you must call the activateLogResponse method, this way you will see the system.out outputs of the response.
predicate - for filtering holidays from the responsepublic List<java.time.LocalDate> searchHolidaysFor(String countryCode) throws IOException
LocalDate representing the holidays for a specific country.
This method assumes you are searching holidays for current year.
searchHolidaysFor in interface HolidaySearchercountryCode - the code of country you are searching forIOException - If connection to the api failedpublic List<java.time.LocalDate> searchHolidaysFor(String countryCode, int year) throws IOException
LocalDate representing the holidays for a specific country and for specific year.countryCode - for which search holidaysyear - for which you are searching holidaysIOException - If connection to the api failedpublic void activateLogResponse()
Copyright © 2020. All rights reserved.