{"id":20832497,"url":"https://github.com/codetanzania/ewea-api-client","last_synced_at":"2025-05-08T01:26:18.481Z","repository":{"id":35130659,"uuid":"210612071","full_name":"CodeTanzania/ewea-api-client","owner":"CodeTanzania","description":"Http client for Early Warning, Early Action Tool","archived":false,"fork":false,"pushed_at":"2025-03-24T23:12:53.000Z","size":1157,"stargazers_count":3,"open_issues_count":11,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-04-26T18:04:33.617Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CodeTanzania.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":"GOVERNANCE.md","roadmap":null,"authors":null,"dei":null}},"created_at":"2019-09-24T13:38:22.000Z","updated_at":"2021-06-05T16:05:45.000Z","dependencies_parsed_at":"2023-10-23T09:30:10.906Z","dependency_job_id":"9fc23428-3d40-47a4-8432-62fba2c35c01","html_url":"https://github.com/CodeTanzania/ewea-api-client","commit_stats":{"total_commits":650,"total_committers":4,"mean_commits":162.5,"dds":0.2584615384615384,"last_synced_commit":"0954c832e5c8ff33c1f714cc0149d75b251451d1"},"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeTanzania%2Fewea-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeTanzania%2Fewea-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeTanzania%2Fewea-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeTanzania%2Fewea-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodeTanzania","download_url":"https://codeload.github.com/CodeTanzania/ewea-api-client/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252980431,"owners_count":21835232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T00:12:03.109Z","updated_at":"2025-05-08T01:26:18.457Z","avatar_url":"https://github.com/CodeTanzania.png","language":"JavaScript","readme":"# ewea-api-client\n\n[![Build Status](https://travis-ci.com/CodeTanzania/ewea-api-client.svg?branch=develop)](https://travis-ci.org/CodeTanzania/ewea-api-client)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com/)\n\nhttp client for EMIS API.\n\n## Installation\n\n```sh\nnpm install --save @codetanzania/ewea-api-client\n```\n\n## Usage\n\nFor React application and ES6 usage\n\n```js\nimport {\n  getAlerts,\n  getAlert,\n  postAlert,\n  putAlert,\n  patchAlert,\n  deleteAlert\n} from '@codetanzania/ewea-api-client';\n\ngetAlerts().then(plans =\u003e { ... }).catch(error =\u003e { ... });\n\ngetAlert('5c1766243c9d520004e2b542').then(plan =\u003e { ... }).catch(error =\u003e { ... });\n\npostAlert({ description: 'Voluptas' }).then(plan =\u003e { ... }).catch(error =\u003e { ... });\n\nputAlert({ _id: '5c1766243c9d520004e2b542', description: 'Voluptas' })\n  .then(plan =\u003e { ... }).catch(error =\u003e { ... });\n\npatchAlert({ _id: '5c1766243c9d520004e2b542', description: 'Voluptas' })\n  .then(plan =\u003e { ... }).catch(error =\u003e { ... });\n\ndeleteAlert('5c1766243c9d520004e2b542').then(plan =\u003e { ... }).catch(error =\u003e { ... });\n```\n\nFor Node application(commonjs)\n\n```js\nconst { getAlerts } = require('@codetanzania/ewea-api-client');\ngetAlerts().then(plans =\u003e { ... }).catch(error =\u003e { ... });\n```\n\nTo issue parallel request\n\n```js\nconst {\n getIncidentTypes,\n getAlerts,\n all,\n spread\n} = require('@codetanzania/ewea-api-client');\n\nconst request = all(getIncidentTypes(), getAlerts());\nrequest.then(spread((incidentTypes, plans) =\u003e { ... })).catch(error =\u003e { ... });\n```\n\n### Filtering results\n\nFor filtering or searching data from the API you need to pass param object into the get methods e.g\n\n- Limit returned results\n\n```js\ngetAlerts({ limit: 5 })\n  .then((results) =\u003e {})\n  .catch((error) =\u003e {});\n```\n\n- Search using a keyword\n\n```js\ngetAlerts({ q: 'Warning' })\n  .then((results) =\u003e {})\n  .catch((error) =\u003e {});\n```\n\n- Filtering using properties\n\ni.e Filtering plans which have incident type with `ObjectID` and are in specified boundary which object id(s) in array after `$in` operator.\n\n```js\ngetAlerts({ filter: { incidentType: ObjectID, boundary: { $in: [] } } })\n  .then((results) =\u003e {\n    // continue here\n  })\n  .catch(() =\u003e {\n    // handle error here\n  });\n```\n\nParam object supports all [mongodb operators](https://docs.mongodb.com/manual/reference/operator/query/) ($regex, $gt, $gte, $lt, $lte, $ne, \\$in, etc.)\n\n\u003e 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\n\n## Testing\n\nIf you want to test this library,\n\n- first clone this repo\n- Install all dependencies\n\n  ```sh\n  npm install\n  ```\n\n- Run test\n  ```sh\n  npm test\n  ```\n\n## How to contribute\n\nIt 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.\n\n## LICENSE\n\nMIT License\n\nCopyright (c) 2019 - present Code Tanzania \u0026 Contributors\n\nPermission 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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE 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.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodetanzania%2Fewea-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodetanzania%2Fewea-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodetanzania%2Fewea-api-client/lists"}