public class GoogleCalendarAPI 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.GoogleCalendarAPI of Google.
This class is immutable and thread-safe.
| Constructor and Description |
|---|
GoogleCalendarAPI(String token_path)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
activateLogResponse()
Sets the response logging to true.
|
GoogleCalendarAPI |
applyPredicate(java.util.function.Predicate<? super com.google.api.services.calendar.model.Event> predicate)
Apply the {@code Predicate
|
List<java.time.LocalDate> |
searchHolidaysFor(String countryCode)
Returns a list of
LocalDate objects representing the holidays for a specific country. |
public GoogleCalendarAPI(String token_path)
In order to create the json file with the Google Calendar Api service token you have to create credentials from Google Developer Console (https://console.developers.google.com). Just have to create a project, click on Create Credentials and select the Account Service Key type; finally select the service and the json type and you will get the json file downloaded.
token_path - the token path of json filepublic GoogleCalendarAPI applyPredicate(java.util.function.Predicate<? super com.google.api.services.calendar.model.Event> predicate)
Predicate<? super Event 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 - to apply in order to filter the holidays given as response from the Google Calendar Apipublic List<java.time.LocalDate> searchHolidaysFor(String countryCode) throws IOException, GeneralSecurityException
LocalDate objects representing the holidays for a specific country.
You can find a list of county code in the format 'language.country' under /resources/GoogleCalendarAPI_CountryCodeList.txt. You can change the language part as you prefer. By default is english.
searchHolidaysFor in interface HolidaySearchercountryCode - for which return holidaysIOExceptionGeneralSecurityExceptionpublic void activateLogResponse()
Copyright © 2020. All rights reserved.