Compare commits
No commits in common. "master" and "v.1.0.1" have entirely different histories.
3 changed files with 17 additions and 24 deletions
17
README.md
17
README.md
|
@ -1,13 +1,4 @@
|
|||
# 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
|
||||
|
@ -20,7 +11,7 @@ npm install --save node-holidayapi
|
|||
|
||||
```javascript
|
||||
var HolidayAPI = require('node-holidayapi');
|
||||
var hapi = new HolidayAPI('_YOUR_API_KEY_').v1;
|
||||
var hapi = new HolidayAPI('_YOUR_API_KEY').v1;
|
||||
|
||||
var parameters = {
|
||||
// Required
|
||||
|
@ -29,13 +20,13 @@ var parameters = {
|
|||
// Optional
|
||||
// month: 7,
|
||||
// day: 4,
|
||||
// previous: true,
|
||||
// upcoming: true,
|
||||
// previous true,
|
||||
// upcoming true,
|
||||
// public: true,
|
||||
// pretty: true,
|
||||
};
|
||||
|
||||
hapi.holidays(parameters, function (err, data) {
|
||||
var hapi.holidays(parameters, function (err, data) {
|
||||
// Insert awesome code here...
|
||||
});
|
||||
```
|
||||
|
|
20
index.js
20
index.js
|
@ -1,7 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const https = require('https');
|
||||
const qs = require('querystring');
|
||||
var https = require('https');
|
||||
|
||||
var HolidayAPI = function (key) {
|
||||
if ('undefined' !== typeof key) {
|
||||
|
@ -12,13 +11,16 @@ var HolidayAPI = function (key) {
|
|||
HolidayAPI.prototype.v1 = {};
|
||||
|
||||
HolidayAPI.prototype.v1.holidays = function (parameters, callback) {
|
||||
const querystringObject = Object.assign(
|
||||
{},
|
||||
{key: HolidayAPI.prototype.key},
|
||||
parameters,
|
||||
)
|
||||
const querystring = qs.stringify(querystringObject);
|
||||
const url = `https://holidayapi.com/v1/holidays?${querystring}`;
|
||||
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;
|
||||
|
||||
https.get(url, function (res) {
|
||||
res.on('data', function (data) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "node-holidayapi",
|
||||
"version": "1.0.3",
|
||||
"description": "DEPRECATED -- Official Node.js library for Holiday API",
|
||||
"version": "1.0.1",
|
||||
"description": "Official Node.js library for Holiday API",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
|
Reference in a new issue