Git Product home page Git Product logo

emis-api-client's Introduction

emis-api-client

Build Status Commitizen friendly Renovate enabled

http client for EMIS API.

Installation

npm install --save @codetanzania/emis-api-client

Usage

For React application and ES6 usage

import {
  getPlans,
  getPlan,
  postPlan,
  putPlan,
  patchPlan,
  deletePlan
} from '@codetanzania/emis-api-client';

getPlans().then(plans => { ... }).catch(error => { ... });

getPlan('5c1766243c9d520004e2b542').then(plan => { ... }).catch(error => { ... });

postPlan({ description: 'Voluptas' }).then(plan => { ... }).catch(error => { ... });

putPlan({ _id: '5c1766243c9d520004e2b542', description: 'Voluptas' })
  .then(plan => { ... }).catch(error => { ... });

patchPlan({ _id: '5c1766243c9d520004e2b542', description: 'Voluptas' })
  .then(plan => { ... }).catch(error => { ... });

deletePlan('5c1766243c9d520004e2b542').then(plan => { ... }).catch(error => { ... });

For Node application(commonjs)

const { getPlans } = require('@codetanzania/emis-api-client');
getPlans().then(plans => { ... }).catch(error => { ... });

To issue parallel request

const {
 getIncidentTypes,
 getPlans,
 all,
 spread
} = require('@codetanzania/emis-api-client');

const request = all(getIncidentTypes(), getPlans());
request.then(spread((incidentTypes, plans) => { ... })).catch(error => { ... });

Filtering results

For filtering or searching data from the API you need to pass param object into the get methods e.g

  • Limit returned results
getPlans({ limit: 5 })
  .then(results => {})
  .catch(error => {});
  • Search using a keyword
getAlerts({ q: 'Warning' })
  .then(results => {})
  .catch(error => {});
  • Filtering using properties

i.e Filtering plans which have incident type with ObjectID and are in specified boundary which object id(s) in array after $in operator.

getPlans({ filter: { incidentType: ObjectID, boundary: { $in: [] } } })
  .then(results => {
    // continue here
  })
  .catch(() => {
    // handle error here
  });

Param object supports all mongodb operators ($regex, $gt, $gte, $lt, $lte, $ne, $in, etc.)

Note API URL will be picked from environment variable. This client reads process.env.REACT_APP_EMIS_API_URL or process.env.EMIS_API_URL

Testing

If you want to test this library,

  • first clone this repo

  • Install all dependencies

    npm install
  • Run test

    npm test

How to contribute

It will be nice, if you open an issue first so that we can know what is going on, then, fork this repo and push in your ideas. Do not forget to add a bit of test(s) of what value you adding.

LICENSE

MIT License

Copyright (c) 2018 Code Tanzania & Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

emis-api-client's People

Contributors

benmaruchu avatar dependabot[bot] avatar lykmapipo avatar renovate-bot avatar rijkerd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

emis-api-client's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • fix(deps): update dependency inflection to v1.13.4
  • chore(deps): update dependency chai to v4.4.1
  • chore(deps): update dependency commitizen to v4.3.0
  • chore(deps): update dependency eslint to v7.32.0
  • chore(deps): update dependency chai to v5
  • chore(deps): update dependency eslint to v9
  • chore(deps): update dependency eslint-config-airbnb-base to v15
  • chore(deps): update dependency eslint-config-prettier to v9
  • chore(deps): update dependency eslint-plugin-mocha to v10
  • chore(deps): update dependency eslint-plugin-prettier to v5
  • chore(deps): update dependency husky to v9
  • chore(deps): update dependency lint-staged to v15
  • chore(deps): update dependency mocha to v10
  • chore(deps): update dependency prettier to v3
  • chore(deps): update dependency rimraf to v5
  • chore(deps): update dependency rollup to v4
  • fix(deps): update dependency inflection to v3
  • fix(deps): update dependency jwt-decode to v4
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • @lykmapipo/common 0.43.4
  • @lykmapipo/env 0.17.34
  • axios >=0.19.0
  • inflection >=1.12.0
  • jwt-decode ^3.0.0
  • lodash >=4.17.15
  • moment >=2.24.0
  • @babel/cli 7.14.5
  • @babel/core 7.14.6
  • @babel/node 7.14.5
  • @babel/preset-env 7.14.5
  • @babel/register 7.14.5
  • @commitlint/cli 9.1.2
  • @commitlint/config-conventional 9.1.2
  • @commitlint/travis-cli 9.1.2
  • chai 4.3.4
  • commitizen 4.2.4
  • cz-conventional-changelog 3.3.0
  • eslint 7.28.0
  • eslint-config-airbnb-base 14.2.1
  • eslint-config-prettier 7.2.0
  • eslint-plugin-import 2.22.1
  • eslint-plugin-mocha 8.2.0
  • eslint-plugin-prettier 3.4.0
  • generate-changelog 1.8.0
  • husky 4.3.8
  • lint-staged 10.5.4
  • mocha 8.4.0
  • nock 13.1.0
  • prettier 2.3.1
  • rimraf 3.0.2
  • rollup 2.51.2
travis
.travis.yml
  • node 10

  • Check this box to trigger a request for Renovate to run again on this repository

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.