Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sg-holidays-sdk

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sg-holidays-sdk

An SDK for Salling Group's Holidays API

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Salling Group Stores SDK

This SDK simplifies the process of querying Salling Group's Holidays API. Through this SDK you will be able to query Danish (as of now) holidays. The requests are made through the Salling Group API which can be found here.

You will need the module sg-base-sdk in order to authenticate. You can get your credentials through the developer portal.

Getting Started.

This prints a list of the holidays of 2017 and whether they are national holidays. You will need to get a JWT secret or Bearer token with access to the Stores API from the developer portal.

const { SallingGroupAPI } = require('sg-base-sdk');
const HolidaysSDK = require('./index');
const instance = new HolidaysSDK(SallingGroupAPI.bearer('my_token'));

instance.holidaysInBetween('2017-01-01', '2017-12-31').then((holidays) => {
  for (const holiday of holidays) {
    console.log(`${holiday.date} - ${holiday.name}${holiday.nationalHoliday ? ' (national)' : ''}`);
  }
});

This would output:

2017-01-01 - Nytårsdag (national)
2017-01-06 - Helligtrekongersdag
2017-02-14 - Valentinsdag
2017-02-26 - Fastelavn
2017-04-09 - Palmesøndag
2017-04-13 - Skærtorsdag (national)
2017-04-14 - Langfredag (national)
2017-04-16 - Påskedag (national)
2017-04-17 - 2. påskedag (national)
2017-05-12 - Store bededag (national)
2017-05-14 - Mors dag
2017-05-25 - Kristi Himmelfartsdag (national)
2017-06-04 - Pinsedag (national)
2017-06-05 - 2. pinsedag (national)
2017-06-05 - Grundlovsdag (national)
2017-06-05 - Fars dag
2017-06-23 - Sankt Hans aften
2017-06-24 - Sankt Hans dag
2017-10-31 - Allehelgensaften
2017-11-11 - Mortensdag
2017-11-24 - Black Friday
2017-12-24 - Juleaftensdag (national)
2017-12-25 - 1. juledag (national)
2017-12-26 - 2. juledag (national)
2017-12-31 - Nytårsaftensdag (national)

Holiday Entry

A holiday entry from the API is an object with the following properties:

NameTypeDescription
namestringThe name of the holiday.
datastringThe date of the holiday. (ISO-8601 string)
nationalHolidaybooleanWhether the holiday is a national holiday. This means that the holiday is publicly recognized by the government (i.e. people are off work).

An example of this could be:

{ 
  "date": "2018-10-31",
  "name": "Allehelgensaften",
  "nationalHoliday": false
}

Documentation

constructor(api)

This initializes a new Holidays SDK object. api must be an instance returned by sg-base-sdk.

Example:

const { SallingGroupAPI } = require('sg-base-sdk');
const HolidaysSDK = require('sg-holidays-sdk');
const instance = new HolidaysSDK(SallingGroupAPI.jwt('my_email', 'my_key'));

async isHoliday(date)

This checks whether the given date is a holiday.

Example:

const date = '2017-12-24';
if (await instance.isHoliday(date)) {
  console.log(`${date} is a holiday.`);
} else {
  console.log(`${date} is not a holiday.`);
}

async holidaysInBetween(startDate, endDate)

This gets a list of holidays in-between the two given dates.

Example:

for (const holiday of await instance.holidaysInBetween('2017-05-11', '2017-10-01')) {
    console.log(holiday.name);
}

async holidaysUntil(date)

This gets a list of holidays in-between today and the given date.

Example:

for (const holiday of await instance.holidaysUntil('2018-10-01')) {
    console.log(holiday.name);
}

async holidaysWithinUpcomingYear()

This gets a list of holidays within the upcoming year from today.

Example:

for (const holiday of await instance.holidaysWithinUpcomingYear()) {
    console.log(holiday.name);
}

async nextHoliday()

This gets the next upcoming holiday.

Example:

instance.nextHoliday().then((holiday) => {
  console.log(`The next holiday is ${holiday.name}.`);
  console.log(`The date of the holiday is ${holiday.date}.`);
  console.log(holiday.nationalHoliday ?
    'This is a national holiday.' : 'This is not a national holiday.'
  );
});

FAQs

Package last updated on 31 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc