Read Me
ERROR! The markdown supplied could not be parsed correctly. Did you forget to surround a code snippet with "~~~~"?
## Notification Enabler ### Read me #### 1. Prerequisite In order to run this enabler code on your local machine you should have installed Docker. #### 2. Instalation Make sure the docker is installed on the system environment. ##### 2.1. Clone the code repository: `git clone https://<username>@opensourceprojects.eu/git/p/vfos/assets/enablers/nen/code vfos-assets-enablers-nen-code` ##### 2.2. Instalation Docker: `1 - Permission for run.sh file (chmod 777 run.sh) 2 - Run script: ./run.sh` ##### 2.3. Run multi-container Docker application `This multi-container Docker application is composed by two services: `enabler` and `MySQL`.` #### 2.4. Usage `Whenever it's needed to have this enabler runnig, please execute `docker-compose up`.` `On the browser please navigate to `localhost:5000` to reach the frontend module.` For this enabler execute will need the following Environment Variables: `PORT USEREMAIL USERPWD DBUSER DBPASSWORD DATABASE` `This Environment Variables will be in data.env file.` #### 3. API ## vf-OS Enablers ### Enabler 2 - Get Rules ```http GET /api/vf-os-enabler/v0/getRules/myawesomeappid Accept: */* ``` ```http HTTP/1.1 200 OK Content-type: application/json X-Powered-By: Express Date: Tue, 29 Aug 2017 11:04:31 GMT Connection: keep-alive Transfer-Encondig: chunked { "success": true, "data": [ { "rulesID": 11, "description": "New Rule", "parameters": "slumptest,corrigir", "parameter": "slumptest", "conditionValue": ">", "controlValue": "5", "notificationType": 5, "token": "fgTJAyuX0M4tpn1P2WXAJmRbDH7hwbVhZsL26Ca1Ecm" } ] } ``` Use this API call whenever is needed to retrieve all rules related to app. #### Request `GET /api/vf-os-enabler/<api_version>/getRules/<app_id>` #### URL Parameters Resource Parameter | Description ---- | ---- api_version | Identifies the API version that will be used for the request app_id | Identifies the APP #### Query Parameters Name | Required | Type | Description ---- | ---- | ---- | ---- appID | Yes | String | appID for identify which app will show the rules. #### Return Payload The API response will contain a JSON document with the property `success`: **true**, **false** and the `data` with the rules of app (if found). In the following Example it's queried all rules related to specific appID: ```json { "success": true, "data": [ { "rulesID": 11, "description": "New Rule", "parameters": "slumptest,corrigir", "parameter": "slumptest", "conditionValue": ">", "controlValue": "5", "notificationType": 5, "token": "fgTJAyuX0M4tpn1P2WXAJmRbDH7hwbVhZsL26Ca1Ecm" } ] } ``` #### Return Codes Code | Description --- | --- 200 | Data found 500 | Internal Server Error - There was an unexpected error at some point during the processing of the request. ### Enabler 2 - Get Notifications ```http GET /api/vf-os-enabler/v0/getNotifications/myawesomeappid Accept: */* ``` ```http HTTP/1.1 200 OK Content-type: application/json X-Powered-By: Express Date: Tue, 29 Aug 2017 11:04:31 GMT Connection: keep-alive Transfer-Encondig: chunked { "success": true, "data": [ { "emailTo": "raquel.melo@knowledgebiz.pt", "subject": "slumptest>10", "date": "2018-04-27 12:06:02", "token": "fgTJAyuX0M4tpn1P2WXAJmRbDH7hwbVhZsL26Ca1Ecm" } ] } ``` Use this API call whenever is needed to retrieve all notifications of app. #### Request `GET /api/vf-os-enabler/<api_version>/getNotifications/<app_id>` #### URL Parameters Resource Parameter | Description ---- | ---- api_version | Identifies the API version that will be used for the request app_id | Identifies the APP to show the notifications #### Query Parameters Name | Required | Type | Description ---- | ---- | ---- | ---- appID | Yes | String | appID for identify which app will show the rules. #### Return Payload The API response will contain a JSON document with the property `success`: **true**, **false** and the `data` with the notifications of app (if found). In the following Example it's queried the all notifications of specific appID: ```json { "success": true, "data": [ { "emailTo": "miguel.rodrigues@knowledgebiz.pt", "subject": "slumptest=40", "date": "2018-04-27 15:39:51", "token": "fgTJAyuX0M4tpn1P2WXAJmRbDH7hwbVhZsL26Ca1Ecm" }, { "emailTo": "miguel.rodrigues@knowledgebiz.pt", "subject": "slumptest=40", "date": "2018-04-27 16:06:00", "token": "fgTJAyuX0M4tpn1P2WXAJmRbDH7hwbVhZsL26Ca1Ecm" }, { "emailTo": "miguel.rodrigues@knowledgebiz.pt", "subject": "slumptest=40", "date": "2018-04-27 16:06:09", "token": "fgTJAyuX0M4tpn1P2WXAJmRbDH7hwbVhZsL26Ca1Ecm" }, { "emailTo": "miguel.rodrigues@knowledgebiz.pt", "subject": "slumptest=40", "date": "2018-04-27 16:08:30", "token": "fgTJAyuX0M4tpn1P2WXAJmRbDH7hwbVhZsL26Ca1Ecm" }, { "emailTo": "miguel.rodrigues@knowledgebiz.pt", "subject": "slumptest=40", "date": "2018-04-27 16:09:51", "token": "fgTJAyuX0M4tpn1P2WXAJmRbDH7hwbVhZsL26Ca1Ecm" } ] } ``` #### Return Codes Code | Description ---- | ---- 200 | Configuration Found 500 | Internal Server Error - There was an unexpected error at some point during the processing of the request. ### Enabler 2 - Get Apps ```http GET /api/vf-os-enabler/v0/getApps/david.aleixo@knowledgebiz.pt Accept: */* ``` ```http HTTP/1.1 200 OK Content-type: application/json X-Powered-By: Express Date: Tue, 29 Aug 2017 13:00:00 GMT Connection: keep-alive Transfer-Encondig: chunked { "success": true, "data": [ { "token": "Es5zfsco57fieoQcDJZuIZxFZWv4HQbBYgUXRgqodQp", "appID": "MiguelID", "developerID": "miguel.rodrigues@knowledgebiz.pt" } ] } ``` Use this API call whenever is needed to retrieve all apps of developerid. #### Request `GET /api/vf-os-enabler/<api_version>/getApps/<developer_id>` #### URL Parameters Resource Parameter | Description ---- | ---- api_version | Identifies the API version that will be used for the request developer_id | Identifies the Developer #### Query Parameters Name | Required | Type | Description ---- | ---- | ---- | ---- developerID | Yes | String | developerID for identify which developer will show the apps. #### Return Payload The API response will contain a JSON document with the property `success`: **true**, **false** and the `data` with the notifications of app (if found). In the following Example it's queried the all Apps of specific developerID: ```json { "success": true, "data": [ { "token": "Es5zfsco57fieoQcDJZuIZxFZWv4HQbBYgUXRgqodQp", "appID": "MiguelID", "developerID": "painatal_vodka@hotmail.com" } ] } ``` #### Return Codes Code | Description --- | --- 200 | Configuration Activated 500 | Internal Server Error - There was an unexpected error at some point during the processing of the request. ### Enabler 2 - Create Notifications ```http POST http://localhost:8000/api/vf-os-enabler/v0/notifications Accept: */* Content-Type: application/json; charset=utf-8 {"body":[{"my_key":"my_value"},{"my_key":"my_value"},{"my_key":"my_value"}]} ``` ```http HTTP/1.1 200 OK Content-type: application/json X-Powered-By: Express Date: Tue, 29 Aug 2017 15:00:00 GMT Connection: keep-alive Transfer-Encondig: chunked {"success": true} ``` Use this API call whenever is needed to create a new configuration version for one enabler. #### Request `POST /api/vf-os-enabler/<api_version>/enabler/notifications` #### URL Parameters Resource Parameter | Description ---- | ---- api_version | Identifies the API version that will be used for the request #### JSON Body Payload Name | Required | Type | Description ---- | ---- | ---- | --- body | Yes | JSON | JSON document where the custom notification parameters are. Example: [{"emailTo" : "miguel.rodrigues@knowledgebiz.pt"},{"subject" : "slumptest=10"},{"token" : "fgTJAyuX0M4tpn1P2WXAJmRbDH7hwbVhZsL26Ca1Ecm"}] #### Return Payload The API response will contain a JSON document with the property `success`: **true**, **false** and the `reason` if the `success` became **false**. Example: ```json { "success": true } ``` #### Return Codes Code | Description ---- | ---- 200 | Configuration created successfully 500 | Internal Server Error - There was an unexpected error at some point during the processing of the request. ### Enabler 2 - Create App ```http POST http://localhost:8000/api/vf-os-enabler/v0/register Accept: */* Content-Type: application/json; charset=utf-8 {"body":[{"my_key":"my_value"},{"my_key":"my_value"}]} ``` ```http HTTP/1.1 200 OK Content-type: application/json X-Powered-By: Express Date: Tue, 29 Aug 2017 15:00:00 GMT Connection: keep-alive Transfer-Encondig: chunked "success": true, "data": { "token": "Z58oqMmXJJzC1KHAaPurgohg00xgklomu5DVXgcZwj4" } ``` Use this API call whenever is needed to create a new configuration version for one enabler. #### Request `POST /api/vf-os-enabler/<api_version>/enabler/register` #### URL Parameters Resource Parameter | Description ---- | ---- api_version | Identifies the API version that will be used for the request #### JSON Body Payload Name | Required | Type | Description ---- | ---- | ---- | --- body | Yes | JSON | JSON document where the custom notification parameters are. Example: [{"appID" : "KBZ"},{"developerID" : "miguel.rodrigues@knowledgebiz.pt"}] #### Return Payload The API response will contain a JSON document with the property `success`: **true**, **false** and the `data` if the `success` became **false**. Example: ```json { "success": true, "data": { "token": "Z58oqMmXJJzC1KHAaPurgohg00xgklomu5DVXgcZwj4" } } ``` #### Return Codes Code | Description ---- | ---- 200 | Configuration created successfully 500 | Internal Server Error - There was an unexpected error at some point during the processing of the request. ### Enabler 2 - Create Rules ```http POST http://localhost:8000/api/vf-os-enabler/v0/notifications/rules Accept: */* Content-Type: application/json; charset=utf-8 {"body":[{"my_key":"my_value"},{"my_key":"my_value"},{"my_key":"my_value"},{"my_key":"my_value"},{"my_key":"my_value"},{"my_key":"my_value"},{"my_key":"my_value"]} ``` ```http HTTP/1.1 200 OK Content-type: application/json X-Powered-By: Express Date: Tue, 29 Aug 2017 15:00:00 GMT Connection: keep-alive Transfer-Encondig: chunked { "success": true } ``` Use this API call whenever is needed to create a new configuration version for one enabler. #### Request `POST /api/vf-os-enabler/<api_version>/enabler/rules` #### URL Parameters Resource Parameter | Description ---- | ---- api_version | Identifies the API version that will be used for the request #### JSON Body Payload Name | Required | Type | Description ---- | ---- | ---- | --- body | Yes | JSON | JSON document where the custom notification parameters are. Example: [{"appID" : "KBZ"},{"description" : "So many Tests"},{"parameters" : "Test,AnotherTest,Test3"},{"parameter" : "Test"},{"conditionValue" : ">"},{"controlValue" : "100"},{"notificationType" : "5"}] #### Return Payload The API response will contain a JSON document with the property `success`: **true**, **false** and the `reason` if the `success` became **false**. Example: ```json { "success": true } ``` #### Return Codes Code | Description ---- | ---- 200 | Configuration created successfully 500 | Internal Server Error - There was an unexpected error at some point during the processing of the request. ### Powered by: ![alt text](https://static.wixstatic.com/media/d65bd8_d460ab5a6ff54207a8ac3e7497af18c4~mv2_d_4201_2594_s_4_2.png "Notification Enabler")