Coder Social home page Coder Social logo

hugojosefson / openmeal-api Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 1.77 MB

API module for skolmaten.se via Open Meal Information API

Home Page: https://npmjs.com/package/@hugojosefson/openmeal-api

JavaScript 100.00%
lunch api unofficial skolmaten skolmat skola skollunch openmeal meal

openmeal-api's Introduction

API for Open Meal Information

Build Status npm page License ISC SemVer 2.0.0 JavaScript Style Guide

Introduction

This is an unofficial API module for accessing Swedish school lunch menus from skolmaten.se via Open Meal Information as specified at https://orebrokommun.github.io/Open-Meal-Information/.

Prerequisite

Node.js, at least v10.13.0.

Recommended to install latest via nvm:

nvm install stable

Installation in a project

yarn add @hugojosefson/openmeal-api
 # or
npm install --save @hugojosefson/openmeal-api

Programmatic access

It is recommended to import or require the module, and use its exported functions programmatically.

API

Table of Contents

getDataProviders

Returns data providers.

Parameters

Returns Promise A Promise of the data property of the response from the server.

getDataProviderSkolmaten

Returns the data provider with name === 'Skolmaten'.

Parameters

Returns Promise A Promise of the data property of the response from the server.

getDistributors

Returns distributors from a data provider.

Parameters
  • dataprovider object data provider object to fetch distributors from.
    • dataprovider.baseUrl string baseUrl of the data provider.

Returns Promise A Promise of the data property of the response from the server.

filterDistributors

Filters distributors based on partial name and/or partial address.

Parameters
  • options object
    • options.distributors Array current distributors to filter, for example from getDistributors or the result of previous call to this function.
    • options.name (string | undefined) if specified, only include distributors in result which contain this string in their name, case insensitively.
    • options.address (string | undefined) if specified, only include distributors in result which contain this string in their addressRegion or addressLocality, case insensitively.

Returns Promise<Array> A Promise of an array of distributors matching the criteria.

getMeals

Fetches meals for a distributor.

Parameters
  • options object
    • options.dataprovider object data provider object to fetch distributors from.
      • options.dataprovider.baseUrl string baseUrl of the data provider.
    • options.distributor object distributor whose meals to fetch.
      • options.distributor.distributorID string the distributor's ID.
    • options.startDate (string | undefined) start date on the form YYYY-MM-DD.
    • options.endDate (string | undefined) end date on the form YYYY-MM-DD.

Returns Promise A Promise of the data property of the response from the server.

extractOnlyMeals

Extracts an array of only meals objects from a response from getMeals().

Parameters
  • response object response from calling getMeals().

Returns Promise<Array> A Promise of an array containing all meal objects from the supplied response.

Usage on CLI

You can also try it from the command-line.

./node_modules/.bin/openmeal-api

Prints usage information for the CLI.

openmeal-api's People

Contributors

dependabot[bot] avatar hugojosefson avatar

Stargazers

 avatar

Watchers

 avatar  avatar

openmeal-api's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.