Compare commits

...

6 commits

Author SHA1 Message Date
2cade7ce07
Added deprecation notices. 2019-09-10 10:14:01 -05:00
Yaw Etse
b6ad36a075 allow for the key to be passed as a parameter
this will also use the property `key` on the prototype if it's defined.
2019-06-01 13:54:16 -05:00
Josh Sherman
e4b27db043 Bumped version 2016-08-30 23:56:39 -05:00
Josh Sherman
5bf4a64d59 Fixed up README 2016-08-30 23:55:58 -05:00
Josh Sherman
8288d8f246 Bumped version 2016-08-20 14:04:28 -05:00
Josh Sherman
05abb58875 Fixed README 2016-08-20 14:04:03 -05:00
3 changed files with 25 additions and 18 deletions

View file

@ -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 # node-holidayapi
Official Node.js library for [Holiday API](https://holidayapi.com) Official Node.js library for [Holiday API](https://holidayapi.com)
## Installation ## Installation
@ -10,8 +19,8 @@ npm install --save node-holidayapi
## Usage ## Usage
```javascript ```javascript
var hapi = require('node-holidayapi'); var HolidayAPI = require('node-holidayapi');
var Hapi = new HolidayAPI('_YOUR_API_KEY').v1; var hapi = new HolidayAPI('_YOUR_API_KEY_').v1;
var parameters = { var parameters = {
// Required // Required
@ -20,13 +29,13 @@ var parameters = {
// Optional // Optional
// month: 7, // month: 7,
// day: 4, // day: 4,
// previous true, // previous: true,
// upcoming true, // upcoming: true,
// public: true, // public: true,
// pretty: true, // pretty: true,
}; };
var Hapi.holidays(parameters, function (err, data) { hapi.holidays(parameters, function (err, data) {
// Insert awesome code here... // Insert awesome code here...
}); });
``` ```

View file

@ -1,6 +1,7 @@
'use strict'; 'use strict';
var https = require('https'); const https = require('https');
const qs = require('querystring');
var HolidayAPI = function (key) { var HolidayAPI = function (key) {
if ('undefined' !== typeof key) { if ('undefined' !== typeof key) {
@ -11,16 +12,13 @@ var HolidayAPI = function (key) {
HolidayAPI.prototype.v1 = {}; HolidayAPI.prototype.v1 = {};
HolidayAPI.prototype.v1.holidays = function (parameters, callback) { HolidayAPI.prototype.v1.holidays = function (parameters, callback) {
var url = 'https://holidayapi.com/v1/holidays'; const querystringObject = Object.assign(
var querystring = '?key=' + HolidayAPI.prototype.key; {},
{key: HolidayAPI.prototype.key},
if ('object' === typeof parameters) { parameters,
for (var parameter in parameters) { )
querystring += '&' + parameter + '=' + parameters[parameter]; const querystring = qs.stringify(querystringObject);
} const url = `https://holidayapi.com/v1/holidays?${querystring}`;
}
url += querystring;
https.get(url, function (res) { https.get(url, function (res) {
res.on('data', function (data) { res.on('data', function (data) {

View file

@ -1,7 +1,7 @@
{ {
"name": "node-holidayapi", "name": "node-holidayapi",
"version": "1.0.0", "version": "1.0.3",
"description": "Official Node.js library for Holiday API", "description": "DEPRECATED -- Official Node.js library for Holiday API",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"