From da7fa8ddc88771924a12b920721740c2c35c4998 Mon Sep 17 00:00:00 2001 From: Benson Maruchu Date: Thu, 21 Nov 2019 18:17:58 +0300 Subject: [PATCH 1/5] chore(env): add EventGroup on .env example --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 3bed4cf..2feb15c 100644 --- a/.env.example +++ b/.env.example @@ -123,5 +123,5 @@ PUSH_FCM_TEST_REGISTRATION_TOKEN= # PREDEFINES -PREDEFINE_NAMESPACES=EventAction,EventFunction,EventType,EventCertainty,EventSeverity,EventStatus,EventUrgency +PREDEFINE_NAMESPACES=EventAction,EventFunction,EventType,EventCertainty,EventSeverity,EventStatus,EventUrgency,EventGroup PREDEFINE_RELATIONS='{"agency":{"ref":"Party"}}'; From 07838498bc16eb45830e98e65903848660b41c34 Mon Sep 17 00:00:00 2001 From: Benson Maruchu Date: Thu, 21 Nov 2019 18:19:34 +0300 Subject: [PATCH 2/5] feat(event-group): add event group seed data --- seeds/predefines/eventgroups.js | 64 +++++++++++++++++++++++++++++++++ seeds/predefines/index.js | 2 ++ 2 files changed, 66 insertions(+) create mode 100644 seeds/predefines/eventgroups.js diff --git a/seeds/predefines/eventgroups.js b/seeds/predefines/eventgroups.js new file mode 100644 index 0000000..4a543a0 --- /dev/null +++ b/seeds/predefines/eventgroups.js @@ -0,0 +1,64 @@ +const groups = [ + { + namespace: 'EventGroup', + strings: { + name: { en: 'Geological' }, + }, + }, + { + namespace: 'EventGroup', + strings: { + name: { en: 'Meteorological' }, + }, + }, + { + namespace: 'EventGroup', + strings: { + name: { en: 'Safety' }, + }, + }, + { + namespace: 'EventGroup', + strings: { + name: { en: 'Security' }, + }, + }, + { + namespace: 'EventGroup', + strings: { + name: { en: 'Rescue' }, + }, + }, + { + namespace: 'EventGroup', + strings: { + name: { en: 'Health' }, + }, + }, + { + namespace: 'EventGroup', + strings: { + name: { en: 'Enviromental' }, + }, + }, + { + namespace: 'EventGroup', + strings: { + name: { en: 'Transport' }, + }, + }, + { + namespace: 'EventGroup', + strings: { + name: { en: 'Infrastructure' }, + }, + }, + { + namespace: 'EventGroup', + strings: { + name: { en: 'CBRNE' }, + }, + }, +]; + +module.exports = groups; diff --git a/seeds/predefines/index.js b/seeds/predefines/index.js index f35b988..f4ffd55 100644 --- a/seeds/predefines/index.js +++ b/seeds/predefines/index.js @@ -4,6 +4,7 @@ const severities = require('./eventseverities'); const urgencies = require('./eventurgencies'); const certainties = require('./eventcertainties'); const types = require('./eventtypes'); +const groups = require('./eventgroups'); const predefines = [ ...functions, @@ -12,6 +13,7 @@ const predefines = [ ...urgencies, ...certainties, ...types, + ...groups, ]; module.exports = predefines; From 7ae39d0db2ae27d0a7a0aef7c20421a42b1d517c Mon Sep 17 00:00:00 2001 From: Benson Maruchu Date: Thu, 21 Nov 2019 21:49:53 +0300 Subject: [PATCH 3/5] style(api.md): format file --- docs/api.md | 271 +++++++++++++++++++++++++++++----------------------- 1 file changed, 149 insertions(+), 122 deletions(-) diff --git a/docs/api.md b/docs/api.md index 4ebf139..bceb83f 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,11 +1,12 @@ # Overview ## Introduction + This API is organized around [REST](http://en.wikipedia.org/wiki/Representational_State_Transfer). The API has predictable resource-oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs. > Base URL -```curl +```curl https://api.ewea.io/v1 ``` @@ -14,14 +15,15 @@ Throughout this document, some example API requests will be given using the `cur If you need access to the headers of a response through `curl`, you can pass the `-i` flag to display the header information along with the body. If you are only interested in the header, you can instead pass the `-I` flag, which will exclude the response body entirely. ## Requests + Requests should be made using the `HTTPS protocol` so that traffic is encrypted. Calls made over plain HTTP will fail. API requests without authentication will also fail. > Example Request ```curl -curl --request GET \ +curl --request GET \ --url https://api.ewea.io/v1/events \ ---header 'Accept: application/json' \ +--header 'Accept: application/json' \ --header 'Authorization: Bearer ' ``` @@ -40,11 +42,13 @@ Authorization: Bearer ``` ## Responses + When a request is successful, a response body will typically be sent back in the form of a JSON object. If you send a request to specific resource e.g `https://api.ewea.io/v1/events/:id` you will get back an object with its `keys` representing properties of that specific resource. > Example Single Object Response: + ```curl HTTP/1.1 200 Success { @@ -59,6 +63,7 @@ HTTP/1.1 200 Success If you send a request to general collection e.g `https://api.ewea.io/v1/events` you will get back an object with `data` key which represent set of found resources. > Example Object Collection Response: + ```curl HTTP/1.1 200 Success { @@ -89,38 +94,41 @@ HTTP/1.1 400 Bad Request ``` ## HTTP Statuses + This API uses conventional `HTTP status codes` to indicate the success or failure of an API request. In general: Codes in the `2xx` range indicate success. Codes in the `4xx` range indicate an error that failed given the information provided (e.g., a required parameter was omitted etc.). Codes in the `5xx` range indicate an error with API servers (these are rare).
-|Code|Description| -|:---:|:---:| -| 200 - OK | Everything worked as expected. | -| 201 - Created | The request was a success and resource have been created. | -| 400 - Bad Request | The request was unacceptable, often due to missing a required parameter. | -| 401 - Unauthorized | No valid API key provided or missing. | -| 403 - Forbidden | API key provided doesn’t have permission to access specified resource. | -| 404 - Not Found | The requested resource doesn't exist. | -| 405 - Method Not Allowed | The requested resource does not support the HTTP method used. | -| 409 - Conflict | The request conflicts with another request. | -| 429 - Too Many Requests | Too many requests hit the API too quickly. We recommend an exponential backoff of your requests. | -| 500 - Internal Server Error | Something went wrong on API Server end. (These are rare.) | -| 502 - Bad Gateway | Upstream payment processor(gateway) returned an error. | -| 503 - Service Unavailable | Server maintenance. | -| 504 - Gateway Timeout | Upstream payment processor(gateway) fail to respond in time. | +| Code | Description | +| :-------------------------: | :----------------------------------------------------------------------------------------------: | +| 200 - OK | Everything worked as expected. | +| 201 - Created | The request was a success and resource have been created. | +| 400 - Bad Request | The request was unacceptable, often due to missing a required parameter. | +| 401 - Unauthorized | No valid API key provided or missing. | +| 403 - Forbidden | API key provided doesn’t have permission to access specified resource. | +| 404 - Not Found | The requested resource doesn't exist. | +| 405 - Method Not Allowed | The requested resource does not support the HTTP method used. | +| 409 - Conflict | The request conflicts with another request. | +| 429 - Too Many Requests | Too many requests hit the API too quickly. We recommend an exponential backoff of your requests. | +| 500 - Internal Server Error | Something went wrong on API Server end. (These are rare.) | +| 502 - Bad Gateway | Upstream payment processor(gateway) returned an error. | +| 503 - Service Unavailable | Server maintenance. | +| 504 - Gateway Timeout | Upstream payment processor(gateway) fail to respond in time. | ## HTTP Methods + This API uses appropriate HTTP verbs for every action. -|Method|Description| -|:---:|:---:| -| GET | Used for retrieving resources.| -| POST | Used for creating resources and performing resource actions.| -| PUT | Used for updating resources.| -| PATCH | Used for updating resources.| -| DELETE | Used for deleting resources.| +| Method | Description | +| :----: | :----------------------------------------------------------: | +| GET | Used for retrieving resources. | +| POST | Used for creating resources and performing resource actions. | +| PUT | Used for updating resources. | +| PATCH | Used for updating resources. | +| DELETE | Used for deleting resources. | ## Authentication + This API uses API keys to authenticate requests. Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth. Authentication to the API is performed via `HTTP Bearer Auth`. @@ -128,11 +136,11 @@ Authentication to the API is performed via `HTTP Bearer Auth`. > Example Request ```curl -curl --request POST \ ---url https://api.ewea.io/v1/events \ ---header 'Accept: application/json' \ ---header 'Content-Type: application/json' \ ---header 'Authorization: Bearer ' \ +curl --request POST \ +--url https://api.ewea.io/v1/events \ +--header 'Accept: application/json' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer ' \ --data '{ "type": "Strong Winds", "area":"Tandale, Kigogo" @@ -140,70 +148,72 @@ curl --request POST \ ``` ## Sorting -All top-level API resources have support `sort` on `list` API methods. To sort + +All top-level API resources have support `sort` on `list` API methods. To sort the the result of `list` send request with `sort` query parameter. > Example Sorting Request ```curl -curl --request GET \ ---url https://api.ewea.io/v1/events?sort=type \ +curl --request GET \ +--url https://api.ewea.io/v1/events?sort=type \ --header 'Accept: application/json' \ --header 'Authorization: Bearer ' -``` +``` The sort order for each `sort` field is `ascending order` unless it is prefixed with a `minus ("-"")`, in which case it will be `descending order`. - > Example Sorting Order Request ```curl -curl --request GET \ ---url https://api.ewea.io/v1/events?sort=-createdAt,type \ +curl --request GET \ +--url https://api.ewea.io/v1/events?sort=-createdAt,type \ --header 'Accept: application/json' \ --header 'Authorization: Bearer ' ``` ## Pagination + All top-level API resources have support for bulk fetches via `list` API methods. These list API methods share a common structure, taking at least these three parameters: `limit`, `skip`, and `page`. > Example Request: ```curl -curl --request GET \ ---url https://api.ewea.io/v1/events?page=1&skip=0&limit=10 \ ---header 'Accept: application/json' \ ---header 'Content-Type: application/json' \ +curl --request GET \ +--url https://api.ewea.io/v1/events?page=1&skip=0&limit=10 \ +--header 'Accept: application/json' \ +--header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' ``` ## Filtering -All top-level API resources have support `filter` on `list` API methods. The `filter` query parameter is reserved for filtering data. + +All top-level API resources have support `filter` on `list` API methods. The `filter` query parameter is reserved for filtering data. To filter the the result of `list` send request with `filter` query parameter. > Example Filter Request ```curl -curl --request GET \ ---url https://api.ewea.io/v1/events?filter[type]=Strong Winds \ +curl --request GET \ +--url https://api.ewea.io/v1/events?filter[type]=Strong Winds \ --header 'Accept: application/json' \ --header 'Authorization: Bearer ' -``` +``` The `filter` support common [MongoDB](https://docs.mongodb.com/manual/reference/operator/query/index.html) query operators. - > Example Filter Query Request ```curl -curl --request GET \ ---url https://api.ewea.io/v1/events?filter[type][$eq]=["Strong Winds"] \ +curl --request GET \ +--url https://api.ewea.io/v1/events?filter[type][$eq]=["Strong Winds"] \ --header 'Accept: application/json' \ --header 'Authorization: Bearer ' ``` ## CORS + In order to make requests to the API from other domains, the API implements `Cross Origin Resource Sharing (CORS)` support. You should not need to be concerned with the details of these headers, because the `browser` or `http library` will typically do all of the work for you. @@ -211,18 +221,19 @@ You should not need to be concerned with the details of these headers, because t > Example Preflight Request ```curl -curl -I --request OPTIONS \ ---url https://api.ewea.io/v1/events \ +curl -I --request OPTIONS \ +--url https://api.ewea.io/v1/events \ --header 'Origin: https://example.com' ``` ## Rate Limit + The number of requests that can be made through the API are currently limited to `5,000 per hour per API token`. -The rate limiting information contained within the response headers are: +The rate limiting information contained within the response headers are: -`RateLimit-Limit:` Number of requests that can be made per hour. -`RateLimit-Remaining:` Number of requests remain before hit request limit. +`RateLimit-Limit:` Number of requests that can be made per hour. +`RateLimit-Remaining:` Number of requests remain before hit request limit. `RateLimit-Reset:` Time when the oldest request will expire. > Example Rate Limit Response Headers @@ -248,8 +259,8 @@ HTTP/1.1 429 Too Many Request } ``` - ## Versioning + When backwards-incompatible changes applied to the API, new version is released. The current version is `v1`. To set the API version on a specific request, append version on request url. As a precaution, use API versioning to test a new API version before committing to an upgrade. @@ -257,55 +268,58 @@ To set the API version on a specific request, append version on request url. As > Example Request: ```curl -curl --request GET \ ---url https://api.ewea.io/v1/events \ ---header 'Accept: application/json' \ ---header 'Content-Type: application/json' \ +curl --request GET \ +--url https://api.ewea.io/v1/events \ +--header 'Accept: application/json' \ +--header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' ``` - # Core Resources ## EventGroup + > TODO ## EventType + `EventType` classify emergency events from the most generalised(nature and family) to the most specific (main event and peril). ### EventType Schema + `EventType` have the following attributes:
-|Name|Type|Description| -|:---:|:---:|:---:| -| _id | String | Unique universal identifier of this event type. | -| code | String | Unique Human-readable given code of this event type. | -| name | Object | Human-translatable-readable name for the event type. | -| color | String | A color code(in hexadecimal format) used to differentiate event types visually. | +| Name | Type | Description | +| :-------: | :----: | :----------------------------------------------------------------------------------------------------------: | +| \_id | String | Unique universal identifier of this event type. | +| code | String | Unique Human-readable given code of this event type. | +| name | Object | Human-translatable-readable name for the event type. | +| color | String | A color code(in hexadecimal format) used to differentiate event types visually. | | createdAt | String | A time value given in ISO8601 combined date and time format that represents when the event type was created. | | updatedAt | String | A time value given in ISO8601 combined date and time format that represents when the event type was updated. | ### Create EventType + To create a new event type, send a `POST` request to `https://api.ewea.io/v1/predefines/eventtypes`. The following attributes are supported:
-|Name|Type|Description|Required| -|:---:|:---:|:---:|:---:| -| code | String | Unique Human-readable given code of this event type. | false | -| name | Object | Human-translatable-readable name for the event type. | true | -| color |String | A color code(in hexadecimal format) used to differentiate event types visually. | false | +| Name | Type | Description | Required | +| :---: | :----: | :-----------------------------------------------------------------------------: | :------: | +| code | String | Unique Human-readable given code of this event type. | false | +| name | Object | Human-translatable-readable name for the event type. | true | +| color | String | A color code(in hexadecimal format) used to differentiate event types visually. | false | > Example Request ```curl -curl --request POST \ ---url https://api.ewea.io/v1/predefines/eventtypes \ ---header 'Accept: application/json' \ ---header 'Content-Type: application/json' \ ---header 'Authorization: Bearer ' \ +curl --request POST \ +--url https://api.ewea.io/v1/predefines/eventtypes \ +--header 'Accept: application/json' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer ' \ --data '{ "code": "SW", "name": { "en": "Strong Winds" }, @@ -317,12 +331,12 @@ The response will be a `JSON object` with the standard event type attributes:
-|Name|Type|Description| -|:---:|:---:|:---:| -| _id | String | Unique universal identifier of this event type. | -| code | String | Unique Human-readable given code of this event type. | -| name | Object | Human-translatable-readable name for the event type. | -| color | String | A color code(in hexadecimal format) used to differentiate event types visually. | +| Name | Type | Description | +| :-------: | :----: | :----------------------------------------------------------------------------------------------------------: | +| \_id | String | Unique universal identifier of this event type. | +| code | String | Unique Human-readable given code of this event type. | +| name | Object | Human-translatable-readable name for the event type. | +| color | String | A color code(in hexadecimal format) used to differentiate event types visually. | | createdAt | String | A time value given in ISO8601 combined date and time format that represents when the event type was created. | | updatedAt | String | A time value given in ISO8601 combined date and time format that represents when the event type was updated. | @@ -341,14 +355,15 @@ HTTP/1.1 201 Success ``` ### Retrieve EventType -To get a eventtype, send a `GET` request to `https://api.ewea.io/v1/predefines/eventtypes/:id`. + +To get a eventtype, send a `GET` request to `https://api.ewea.io/v1/predefines/eventtypes/:id`. > Example Request ```curl -curl --request GET \ ---url https://api.ewea.io/v1/predefines/eventtypes/5c6ea7dae1dc700018aac95a \ ---header 'Accept: application/json' \ +curl --request GET \ +--url https://api.ewea.io/v1/predefines/eventtypes/5c6ea7dae1dc700018aac95a \ +--header 'Accept: application/json' \ --header 'Authorization: Bearer ' ``` @@ -356,12 +371,12 @@ The response will be a `JSON object` with the standard event type attributes:
-|Name|Type|Description| -|:---:|:---:|:---:| -| _id | String | Unique universal identifier of this event type. | -| code | String | Unique Human-readable given code of this event type. | -| name | Object | Human-translatable-readable name for the event type. | -| color | String | A color code(in hexadecimal format) used to differentiate event types visually. | +| Name | Type | Description | +| :-------: | :----: | :----------------------------------------------------------------------------------------------------------: | +| \_id | String | Unique universal identifier of this event type. | +| code | String | Unique Human-readable given code of this event type. | +| name | Object | Human-translatable-readable name for the event type. | +| color | String | A color code(in hexadecimal format) used to differentiate event types visually. | | createdAt | String | A time value given in ISO8601 combined date and time format that represents when the event type was created. | | updatedAt | String | A time value given in ISO8601 combined date and time format that represents when the event type was updated. | @@ -380,22 +395,23 @@ HTTP/1.1 200 Success ``` ### Update EventType + To update existing event type, send a `PATCH` request to `https://api.ewea.io/v1/predefines/eventtypes/:id`. The following attributes are supported:
-|Name|Type|Description|Required| -|:---:|:---:|:---:|:---:| +| Name | Type | Description | Required | +| :--: | :----: | :--------------------------------------------------: | :------: | | name | Object | Human-translatable-readable name for the event type. | > Example Request ```curl -curl --request PATCH \ ---url https://api.ewea.io/v1/predefines/eventtypes/5c6ea7dae1dc700018aac95a \ ---header 'Accept: application/json' \ ---header 'Content-Type: application/json' \ ---header 'Authorization: Bearer ' \ +curl --request PATCH \ +--url https://api.ewea.io/v1/predefines/eventtypes/5c6ea7dae1dc700018aac95a \ +--header 'Accept: application/json' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer ' \ --data '{ "name": { "en": "Strong Winds" }, }' @@ -405,12 +421,12 @@ The response will be a `JSON object` with the standard event type attributes:
-|Name|Type|Description| -|:---:|:---:|:---:| -| _id | String | Unique universal identifier of this event type. | -| code | String | Unique Human-readable given code of this event type. | -| name | Object | Human-translatable-readable name for the event type. | -| color | String | A color code(in hexadecimal format) used to differentiate event types visually. | +| Name | Type | Description | +| :-------: | :----: | :----------------------------------------------------------------------------------------------------------: | +| \_id | String | Unique universal identifier of this event type. | +| code | String | Unique Human-readable given code of this event type. | +| name | Object | Human-translatable-readable name for the event type. | +| color | String | A color code(in hexadecimal format) used to differentiate event types visually. | | createdAt | String | A time value given in ISO8601 combined date and time format that represents when the event type was created. | | updatedAt | String | A time value given in ISO8601 combined date and time format that represents when the event type was updated. | @@ -429,14 +445,15 @@ HTTP/1.1 200 Success ``` ### Delete EventType + To delete existing event type, send a `DELETE` request to `https://api.ewea.io/v1/predefines/eventtypes/:id`. > Example Request ```curl -curl --request DELETE \ ---url https://api.ewea.io/v1/predefines/eventtypes/5c6ea7dae1dc700018aac95a \ ---header 'Accept: application/json' \ +curl --request DELETE \ +--url https://api.ewea.io/v1/predefines/eventtypes/5c6ea7dae1dc700018aac95a \ +--header 'Accept: application/json' \ --header 'Authorization: Bearer ' ``` @@ -444,12 +461,12 @@ The response will be a `JSON object` with the standard event type attributes:
-|Name|Type|Description| -|:---:|:---:|:---:| -| _id | String | Unique universal identifier of this event type. | -| code | String | Unique Human-readable given code of this event type. | -| name | Object | Human-translatable-readable name for the event type. | -| color | String | A color code(in hexadecimal format) used to differentiate event types visually. | +| Name | Type | Description | +| :-------: | :----: | :----------------------------------------------------------------------------------------------------------: | +| \_id | String | Unique universal identifier of this event type. | +| code | String | Unique Human-readable given code of this event type. | +| name | Object | Human-translatable-readable name for the event type. | +| color | String | A color code(in hexadecimal format) used to differentiate event types visually. | | createdAt | String | A time value given in ISO8601 combined date and time format that represents when the event type was created. | | updatedAt | String | A time value given in ISO8601 combined date and time format that represents when the event type was updated. | @@ -468,14 +485,15 @@ HTTP/1.1 200 Success ``` ### List All EventType + To list all event types, send a `GET` request to `https://api.ewea.io/v1/predefines/eventtypes`. > Example Request ```curl -curl --request GET \ ---url https://api.ewea.io/v1/predefines/eventtypes \ ---header 'Accept: application/json' \ +curl --request GET \ +--url https://api.ewea.io/v1/predefines/eventtypes \ +--header 'Accept: application/json' \ --header 'Authorization: Bearer ' ``` @@ -483,16 +501,17 @@ The response will be a `JSON object` with a `data key`. The values in the `data
-|Name|Type|Description| -|:---:|:---:|:---:| -| _id | String | Unique universal identifier of this event type. | -| code | String | Unique Human-readable given code of this event type. | -| name | Object | Human-translatable-readable name for the event type. | -| color | String | A color code(in hexadecimal format) used to differentiate event types visually. | +| Name | Type | Description | +| :-------: | :----: | :----------------------------------------------------------------------------------------------------------: | +| \_id | String | Unique universal identifier of this event type. | +| code | String | Unique Human-readable given code of this event type. | +| name | Object | Human-translatable-readable name for the event type. | +| color | String | A color code(in hexadecimal format) used to differentiate event types visually. | | createdAt | String | A time value given in ISO8601 combined date and time format that represents when the event type was created. | | updatedAt | String | A time value given in ISO8601 combined date and time format that represents when the event type was updated. | > Example Response: + ```curl HTTP/1.1 200 Success { @@ -515,27 +534,35 @@ HTTP/1.1 200 Success ``` ## EventSeverity + > TODO ## EventCertainty + > TODO ## EventFunction + > TODO ## EventAction + > TODO ## EventCatalogue + > TODO ## Event + > TODO ## EventNotification + > TODO ## EventChangeLog + > TODO # Acknowledgements From c71cb0b4d5b746e53ca49cd7b0f4d36bea7abd6f Mon Sep 17 00:00:00 2001 From: Benson Maruchu Date: Thu, 21 Nov 2019 22:32:09 +0300 Subject: [PATCH 4/5] docs(api.md): add initial event group documentation --- docs/api.md | 257 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 253 insertions(+), 4 deletions(-) diff --git a/docs/api.md b/docs/api.md index bceb83f..ab875e4 100644 --- a/docs/api.md +++ b/docs/api.md @@ -279,7 +279,256 @@ curl --request GET \ ## EventGroup -> TODO +`EventGroup` group emergency events based on the nature they fall into. i.e +Meteorological, Hydrological, Biological e.t.c + +### EventGroup Schema + +`EventGroup` have the following attributes: + +
+ +| Name | Type | Description | +| :-------: | :----: | :-----------------------------------------------------------------------------------------------------------: | +| \_id | String | Unique universal identifier of this event group. | +| code | String | Unique Human-readable given code of this event group. | +| name | Object | Human-translatable-readable name for the event group. | +| color | String | A color code(in hexadecimal format) used to differentiate event groups visually. | +| createdAt | String | A time value given in ISO8601 combined date and time format that represents when the event group was created. | +| updatedAt | String | A time value given in ISO8601 combined date and time format that represents when the event group was updated. | + +### Create EventGroup + +To create a new event group, send a `POST` request to `https://api.ewea.io/v1/predefines/eventgroups`. The following attributes are supported: + +
+ +| Name | Type | Description | Required | +| :---: | :----: | :-----------------------------------------------------------------------------: | :------: | +| code | String | Unique Human-readable given code of this event group. | false | +| name | Object | Human-translatable-readable name for the event group. | true | +| color | String | A color code(in hexadecimal format) used to differentiate event group visually. | false | + +> Example Request + +```curl +curl --request POST \ +--url https://api.ewea.io/v1/predefines/eventgroups \ +--header 'Accept: application/json' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer ' \ +--data '{ + "code": "H", + "name": { "en": "Hydrological" }, + "color": "#86C7E8" + }' +``` + +The response will be a `JSON object` with the standard event group attributes: + +
+ +| Name | Type | Description | +| :-------: | :----: | :-----------------------------------------------------------------------------------------------------------: | +| \_id | String | Unique universal identifier of this event group. | +| code | String | Unique Human-readable given code of this event group. | +| name | Object | Human-translatable-readable name for the event group. | +| color | String | A color code(in hexadecimal format) used to differentiate event groups visually. | +| createdAt | String | A time value given in ISO8601 combined date and time format that represents when the event group was created. | +| updatedAt | String | A time value given in ISO8601 combined date and time format that represents when the event group was updated. | + +> Example Response + +```curl +HTTP/1.1 201 Success +{ + "_id": "5c6ea7dae1dc700018aac95b", + "code": "H", + "name": { "en": "Hydrological" }, + "color": "#86C7EE" + "updatedAt": "2019-02-21T13:45:04.340Z", + "createdAt": "2019-02-21T13:45:04.340Z" +} +``` + +### Retrieve EventGroup + +To get a event group, send a `GET` request to `https://api.ewea.io/v1/predefines/eventgroups/:id`. + +> Example Request + +```curl +curl --request GET \ +--url https://api.ewea.io/v1/predefines/eventgroups/5c6ea7dae1dc700018aac95b \ +--header 'Accept: application/json' \ +--header 'Authorization: Bearer ' +``` + +The response will be a `JSON object` with the standard event group attributes: + +
+ +| Name | Type | Description | +| :-------: | :----: | :-----------------------------------------------------------------------------------------------------------: | +| \_id | String | Unique universal identifier of this event group. | +| code | String | Unique Human-readable given code of this event group. | +| name | Object | Human-translatable-readable name for the event group. | +| color | String | A color code(in hexadecimal format) used to differentiate event groups visually. | +| createdAt | String | A time value given in ISO8601 combined date and time format that represents when the event group was created. | +| updatedAt | String | A time value given in ISO8601 combined date and time format that represents when the event group was updated. | + +> Example Response + +```curl +HTTP/1.1 200 Success +{ + "_id": "5c6ea7dae1dc700018aac95b", + "code": "H", + "name": { "en": "Hydrological" }, + "color": "#86C7EE" + "updatedAt": "2019-02-21T13:45:04.340Z", + "createdAt": "2019-02-21T13:45:04.340Z" +} +``` + +### Update EventGroup + +To update existing event group, send a `PATCH` request to `https://api.ewea.io/v1/predefines/eventgroups/:id`. The following attributes are supported: + +
+ +| Name | Type | Description | Required | +| :---: | :----: | :---------------------------------------------------: | :------: | +| name | Object | Human-translatable-readable name for the event group. | + +> Example Request + +```curl +curl --request PATCH \ +--url https://api.ewea.io/v1/predefines/eventgroups/5c6ea7dae1dc700018aac95b \ +--header 'Accept: application/json' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer ' \ +--data '{ + "name": { "en": "Hydrological" }, + }' +``` + +The response will be a `JSON object` with the standard event group attributes: + +
+ +| Name | Type | Description | +| :-------: | :----: | :-----------------------------------------------------------------------------------------------------------: | +| \_id | String | Unique universal identifier of this event group. | +| code | String | Unique Human-readable given code of this event group. | +| name | Object | Human-translatable-readable name for the event group. | +| color | String | A color code(in hexadecimal format) used to differentiate event groups visually. | +| createdAt | String | A time value given in ISO8601 combined date and time format that represents when the event group was created. | +| updatedAt | String | A time value given in ISO8601 combined date and time format that represents when the event group was updated. | + +> Example Response + +```curl +HTTP/1.1 200 Success +{ + "_id": "5c6ea7dae1dc700018aac95b", + "code": "H", + "name": { "en": "Hydrological" }, + "color": "#86C7EE" + "updatedAt": "2019-02-21T13:30:04.340Z", + "createdAt": "2019-02-21T13:30:04.340Z" +} +``` + +### Delete EventGroup + +To delete existing event group, send a `DELETE` request to `https://api.ewea.io/v1/predefines/eventgroups/:id`. + +> Example Request + +```curl +curl --request DELETE \ +--url https://api.ewea.io/v1/predefines/eventgroups/5c6ea7dae1dc700018aac95b \ +--header 'Accept: application/json' \ +--header 'Authorization: Bearer ' +``` + +The response will be a `JSON object` with the standard event group attributes: + +
+ +| Name | Type | Description | +| :-------: | :----: | :-----------------------------------------------------------------------------------------------------------: | +| \_id | String | Unique universal identifier of this event group. | +| code | String | Unique Human-readable given code of this event group. | +| name | Object | Human-translatable-readable name for the event group. | +| color | String | A color code(in hexadecimal format) used to differentiate event groups visually. | +| createdAt | String | A time value given in ISO8601 combined date and time format that represents when the event group was created. | +| updatedAt | String | A time value given in ISO8601 combined date and time format that represents when the event group was updated. | + +> Example Response + +```curl +HTTP/1.1 200 Success +{ + "_id": "5c6ea7dae1dc700018aac95b", + "code": "H", + "name": { "en": "Hydrological" }, + "color": "#86C7EE" + "updatedAt": "2019-02-21T13:30:04.340Z", + "createdAt": "2019-02-21T13:30:04.340Z" +} +``` + +### List All EventGroup + +To list all event groups, send a `GET` request to `https://api.ewea.io/v1/predefines/eventgroups`. + +> Example Request + +```curl +curl --request GET \ +--url https://api.ewea.io/v1/predefines/eventgroups \ +--header 'Accept: application/json' \ +--header 'Authorization: Bearer ' +``` + +The response will be a `JSON object` with a `data key`. The values in the `data key` are set of event group with the standard event group attributes: + +
+ +| Name | Type | Description | +| :-------: | :----: | :-----------------------------------------------------------------------------------------------------------: | +| \_id | String | Unique universal identifier of this event group. | +| code | String | Unique Human-readable given code of this event group. | +| name | Object | Human-translatable-readable name for the event group. | +| color | String | A color code(in hexadecimal format) used to differentiate event groups visually. | +| createdAt | String | A time value given in ISO8601 combined date and time format that represents when the event group was created. | +| updatedAt | String | A time value given in ISO8601 combined date and time format that represents when the event group was updated. | + +> Example Response: + +```curl +HTTP/1.1 200 Success +{ + "data": [{ + "_id": "5c6ea7dae1dc700018aac95b", + "code": "H", + "name": { "en": "Hydrological" }, + "color": "#86C7EE" + "updatedAt": "2019-02-21T13:30:04.340Z", + "createdAt": "2019-02-21T13:30:04.340Z" + }], + "total": 26, + "size": 10, + "limit": 10, + "skip": 0, + "page": 1, + "pages": 3, + "lastModified": "2019-02-21T13:30:04.340Z" +} +``` ## EventType @@ -400,9 +649,9 @@ To update existing event type, send a `PATCH` request to `https://api.ewea.io/v1
-| Name | Type | Description | Required | -| :--: | :----: | :--------------------------------------------------: | :------: | -| name | Object | Human-translatable-readable name for the event type. | +| Name | Type | Description | Required | +| :---: | :----: | :--------------------------------------------------: | :------: | +| name | Object | Human-translatable-readable name for the event type. | > Example Request From 259d03badf028164b99a7a0366196bea5ca3e9fc Mon Sep 17 00:00:00 2001 From: Benson Maruchu Date: Thu, 21 Nov 2019 22:33:03 +0300 Subject: [PATCH 5/5] feat(event-group): add more event group seed data --- seeds/predefines/eventgroups.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/seeds/predefines/eventgroups.js b/seeds/predefines/eventgroups.js index 4a543a0..3b10d4c 100644 --- a/seeds/predefines/eventgroups.js +++ b/seeds/predefines/eventgroups.js @@ -11,6 +11,18 @@ const groups = [ name: { en: 'Meteorological' }, }, }, + { + namespace: 'EventGroup', + strings: { + name: { en: 'Hydrological' }, + }, + }, + { + namespace: 'EventGroup', + strings: { + name: { en: 'Biological' }, + }, + }, { namespace: 'EventGroup', strings: { @@ -38,7 +50,7 @@ const groups = [ { namespace: 'EventGroup', strings: { - name: { en: 'Enviromental' }, + name: { en: 'Environmental' }, }, }, {