Skip to content
A java client library for https://holidayapi.com/
Branch: master
Clone or download
Latest commit f1ac0a4 May 23, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
log4j added logging May 22, 2018
src fixed sonar code smells, May 22, 2018
.gitignore API implementation pending unit tests May 21, 2018
.travis.yml added travis ci integration May 21, 2018
LICENSE Initial commit May 21, 2018
README.md Update README.md May 23, 2018
pom.xml [maven-release-plugin] prepare for next development iteration May 22, 2018

README.md

java-holiday-api

JDk8 Build Status

A java client library for https://holidayapi.com/

The API provider doesn't have a java client library, so I developed one and it is very simple to use. Lookup https://holidayapi.com/ for required and optional parameters


Logging


The application uses log4j to log events.

Provide the logging configuration by having the file log4j.xml in the classpath.

You can download the pre-configured configuration file from the directory <project_root>/log4j/log4j2.xml


Usage:


Maven dependency

<dependency>
    <groupId>com.github.agogs</groupId>
    <artifactId>java-holiday-api</artifactId>
    <version>1.0</version>
</dependency>

Sample java code

        //create a consumer
        APIConsumer consumer = new HolidayAPIConsumer("https://holidayapi.com/v1/holidays");

        //generate the wuery parameters
        QueryParams params = new QueryParams();
        params.key("your_api_key")
                .month(1)
                .country(QueryParams.Country.INDIA)
                .year(2018)
                //JSON is the default format
                .format(QueryParams.Format.XML)
                .pretty(true);

        try {
            //make the API call
            HolidayAPIResponse response = consumer.getHolidays(params);
            
            //check the status code of the API call
            int status = response.getStatus();
            if (status != 200) {

                //handle error scenario

            } else {

                //handle success scenario

                List<Holiday> holidays = response.getHolidays();
                for (Holiday h : holidays) {
                    //do your thing
                }
            }
        } catch (IOException e) {
            //handle exception
        }

LICENSE

GNU General Public License v3.0

Permissions of this strong copyleft license are conditioned on making available complete source code of licensed works and modifications, which include larger works using a licensed work, under the same license. Copyright and license notices must be preserved. Contributors provide an express grant of patent rights.

You can’t perform that action at this time.