Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
2cade7ce07 | |||
|
b6ad36a075 | ||
|
e4b27db043 | ||
|
5bf4a64d59 | ||
|
8288d8f246 | ||
|
05abb58875 |
3 changed files with 25 additions and 18 deletions
19
README.md
19
README.md
|
@ -1,4 +1,13 @@
|
|||
# This repository has moved to [https://github.com/holidayapi/node-holidayapi](https://github.com/holidayapi/node-holidayapi)
|
||||
|
||||
**The NPM package has also been renamed from `node-holidayapi` to simply `holidayapi`**
|
||||
|
||||
**This repository has been archived.**
|
||||
|
||||
---
|
||||
|
||||
# node-holidayapi
|
||||
|
||||
Official Node.js library for [Holiday API](https://holidayapi.com)
|
||||
|
||||
## Installation
|
||||
|
@ -10,8 +19,8 @@ npm install --save node-holidayapi
|
|||
## Usage
|
||||
|
||||
```javascript
|
||||
var hapi = require('node-holidayapi');
|
||||
var Hapi = new HolidayAPI('_YOUR_API_KEY').v1;
|
||||
var HolidayAPI = require('node-holidayapi');
|
||||
var hapi = new HolidayAPI('_YOUR_API_KEY_').v1;
|
||||
|
||||
var parameters = {
|
||||
// Required
|
||||
|
@ -20,13 +29,13 @@ var parameters = {
|
|||
// Optional
|
||||
// month: 7,
|
||||
// day: 4,
|
||||
// previous true,
|
||||
// upcoming true,
|
||||
// previous: true,
|
||||
// upcoming: true,
|
||||
// public: true,
|
||||
// pretty: true,
|
||||
};
|
||||
|
||||
var Hapi.holidays(parameters, function (err, data) {
|
||||
hapi.holidays(parameters, function (err, data) {
|
||||
// Insert awesome code here...
|
||||
});
|
||||
```
|
||||
|
|
20
index.js
20
index.js
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
var https = require('https');
|
||||
const https = require('https');
|
||||
const qs = require('querystring');
|
||||
|
||||
var HolidayAPI = function (key) {
|
||||
if ('undefined' !== typeof key) {
|
||||
|
@ -11,16 +12,13 @@ var HolidayAPI = function (key) {
|
|||
HolidayAPI.prototype.v1 = {};
|
||||
|
||||
HolidayAPI.prototype.v1.holidays = function (parameters, callback) {
|
||||
var url = 'https://holidayapi.com/v1/holidays';
|
||||
var querystring = '?key=' + HolidayAPI.prototype.key;
|
||||
|
||||
if ('object' === typeof parameters) {
|
||||
for (var parameter in parameters) {
|
||||
querystring += '&' + parameter + '=' + parameters[parameter];
|
||||
}
|
||||
}
|
||||
|
||||
url += querystring;
|
||||
const querystringObject = Object.assign(
|
||||
{},
|
||||
{key: HolidayAPI.prototype.key},
|
||||
parameters,
|
||||
)
|
||||
const querystring = qs.stringify(querystringObject);
|
||||
const url = `https://holidayapi.com/v1/holidays?${querystring}`;
|
||||
|
||||
https.get(url, function (res) {
|
||||
res.on('data', function (data) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "node-holidayapi",
|
||||
"version": "1.0.0",
|
||||
"description": "Official Node.js library for Holiday API",
|
||||
"version": "1.0.3",
|
||||
"description": "DEPRECATED -- Official Node.js library for Holiday API",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
|
Reference in a new issue