Official Perl 6 library for Holiday API https://holidayapi.com
Find a file
Josh Sherman 09d35305f3
Merge pull request #1 from tbrowder/v1
initial version, tested locally with my API key
2019-02-25 13:06:52 -06:00
.gitignore Initial commit 2018-12-10 18:06:15 -06:00
LICENSE Initial commit 2018-12-10 18:06:15 -06:00
README.md tabs to spaces for proper format 2018-12-12 05:37:43 -06:00

perl6-holidayapi

Official Perl 6 library for Holiday API

Installation

Required module

$ zef install HTTP::UserAgent

Usage

Retrieve holidays for a single year and country (result is a single JSON file):

use HTTP::UserAgent

my $ua = HTTP::UserAgent.new;
$ua.timeout = 10;

my $HOLAPI-KEY    = 'my-key';
my $data-location = 'https://holidayapi.com/v1/holidays';
my $options       = '&pretty';
my $year      = 2017;
my $country   = 'US';
my $json-data = "holiday-data-{$country}-{$year}.json";

my $query    = "key={$HOLAPI-KEY}{$options}&country={$country}&year={$year}";
my $api-uri  = "{$data-location}?{$query}";
my $response = $ua.get($api-uri);
if $response.is-success {
    say "Working year '$year'...";
    spurt $json-data, $response.content;
    say "See JSON data file '$json-data'.";
}
else {
    die $response.status-line;
}