0.0.2 • Published 5 years ago

@warsawlo/edu-establishments v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

edu-establishments

Tiny API wrapper for educational layer of Warsaw Map Service (https://mapa.um.warszawa.pl)

Installation

yarn add @warsawlo/edu-establishments

or

npm i -S @warsawlo/edu-establishments

Getting started

import Establishments  from  '@warsawlo/edu-establishments'

const establishments = new Establishments()

establishments.findAll().then(res => {})

establishments.findByDistrict(district).then(res => {})

establishments.findByName(name).then(res => {})

establishments.findByNameAndType(name, type).then(res => {})

establishments.findByStreetAndNumber(street, number).then(res => {})

establishments.responseType = 'stream' // default: json

establishments.useTransformer(transformer)
// transformer is a function invoked under the hood by axios` transformResponse

Quite important!

Before using API resources of The City of Warsaw check this reuse terms (PL only) You can find all (not only educational) API spec here (PL only)

API Reference

All functions (except setTranformer) provide data in GeoJSON format

new Establishments(reference)

ParamTypeDefault valueDescription
referencestringpl2000Sets coordinate system. It can be pl2000 or wgs84.

Returns Establishments instance.

.findAll()

Get all educational establishments in Warsaw.

Returns promise from the axios call

.findByName(name)

Find educational establishments by establishment's name.

ParamTypeDescription
nameStringEstablishment name

Returns promise from the axios call

.findByNameAndType(name, type)

Find educational establishments by establishment's name and type.

ParamTypeDescription
nameStringEstablishment's name
typeStringEstablishment's type See list of types

Returns promise from the axios call

.findByDistrict(district)

Find educational establishments by establishment's name and type.

ParamTypeDescription
districtStringDistrict which given establishments is located in (List of districts of Warsaw)

Returns promise from the axios call

.findByStreetAndNumber(street, number)

Find educational establishments by establishment's address.

ParamTypeDescription
streetStringStreet where establishment is located
numberStringHouse number where the school is located

Returns promise from the axios call

.useTransformer(transformer)

Set axios' transformResponse function

ParamTypeDescription
transformerFunctionStreet where establishment is located
    const removeTranformer = instance.useTransformer(data => {
        return `Data object keys: ${Object.keys(data).join(', ')}`
    })

    removeTransformer()

Returns a function that removes current transformer

.responseType

Set response type (arraybuffer, document, json, text, stream).

Default: json

List of types

Type
przedszkole
szkoła podstawowa
gimnazjum
liceum
liceum ogólnokształcące
liceum dla dorosłych
technikum
szkoła branżowa I stopnia
szkoła policealna
bursa internat
młodzieżowy dom kultury
poradnia psychologiczno-pedagogiczna
specjalistyczna poradnia psychologiczno-pedagogiczna