- Seyed AmirHussein Rahnamafard
- Mohammad Maheri
- Navid Mahdian
-
Request:
Post
/api/forms
{ "title": "First Form", "fields": [ { "name": "First_Name" , "title": "First Name" , "type": "Text", "required": true }, { "name": "Your_Location" , "title": "Your Location" , "type": "Location", "required": false }, { "name": "Request_Type" , "title": "Request Type" , "type": "Text" , "options": [ {"label" : "Help" , "value" : "Help"}, {"label" : "Info" , "value" : "Information"} ] }, { "name": "Base_Location", "title": "Base Location", "type": "Location", "options": [ {"label" : "Base1" , "value" : {"lat" : "1.2" , "long": "3.2"}}, {"label" : "Base2" , "value" : {"lat" : "2.3" , "long" : "1.434" }} ] } ] }
-
Response if form inserted:
{ "status": "ok", "message": "'First Form' inserted successfuly.", }
-
Response if form NOT inserted:
{ "status": "error", "message": "Error message", }
-
Request:
GET
/api/forms
-
Response:
{ "forms": [ { "title":"First Form" , "form_id": "1" , "url": "/api/forms/1" }, { "title":"Second Form" , "form_id": "2" , "url": "/api/forms/2" }, . . . ] }
-
Request:
GET
/api/forms/<FORM_ID>
-
Response:
{ "title":"First Form" , "form_id": 1, "fields": [ { "name":"First_Name" , "title": "First Name" , "type": "Text", "required": true }, { "name": "Your_Location" , "title": "Your Location" , "type": "Location", "required": false }, { "name": "Request_Type" , "title": "Request Type" , "type": "Text" , "options": [ {"label" : "Help" , "value" : "Help"}, {"label" : "Info" , "value" : "Information"} ] } , { "name":"Base_Location" , "title" : "Base Location" , "type" : "Location" , "options": [ {"label" : "Base1" , "value" : {"lat" : "1.2" , "long": "3.2"}}, {"label" : "Base2" , "value" : {"lat" : "2.3" , "long" : "1.434" }} ] } ] }
-
Request:
POST
/api/forms/submit
{ "form_id": "1", "response": { "First_Name": "...", "Your_Location": { "lat": "...", "long": "...", }, "Request_Type": "Information", "Base_Location": { "lat" : "1.2" , "long": "3.2" }, . . . } }
-
Response if any error occuers:
400 Bad Request
{ "status": "error", "errors": [ { "message": "Loc field is required." }, { "message": "Date field must be a date" }, . . . ] }
-
Response if form submitted:
{ "status": "ok", "message": "'First Form' submitted successfuly.", }
-
Request:
GET
/api/forms/<FORM_ID>/responses
-
Response:
{ "title": "First Form", "form_id": 1, "form_fields": [ { "name": "Home", "title": "Home", "type": "Location", "label": "Location Label" }, . . . ], "responses": [ { "response_id": 1, "fields": [ { "name": "Home", "title": "Home", "type": "Location", "label": "Location Label", "value": { "lat": "1.2", "long": "3.2", }, }, . . . ], }, . . . ] }
-
Request:
GET
/api/forms/<FORM_ID>/responses/<RESPONSE_ID>
-
Response:
{ "form_id": 1, "response_id": 1, "fields": [ { "name": "Home", "title": "Home", "type": "Location", "value": { "label": "Location Label", "lat": "1.2", "long": "3.2", }, }, . . . ], }
-
Request:
POST
/api/polygons/
{ "type": "Feature", "properties": { "name": "Tehran" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 53.514404296875, 34.59704151614417 ], [ 51.416015625, 34.854382885097905 ], [ 51.6851806640625, 33.82023008524739 ], [ 53.514404296875, 34.59704151614417 ] ] ] } }
-
Response if polygon inserted:
{ "status": "ok", "message": "'Tehran' inserted successfuly.", }
-
Response if polygon NOT inserted:
{ "status": "error", "message": "Error message", }
-
Request:
GET
/api/polygons/filter/?lat=<LATITUDE>&long=<LONGITUDE>
-
Response for filtered request:
{ "polygons": [ { "polygon_id": 1, "name": "Tehran", }, . . . ] }
-
Request:
GET
/api/polygons/
-
Response:
{ "polygons": [ { "polygon_id": 1, "name": "Tehran", }, . . . ] }
-
Request:
GET
/api/forms/<FORM_ID>/responses/filter/?field=<FIELD_NAME>&polygon_id=<POLYGON_ID>
-
Response for filtered request:
{ "title": "First Form", "form_id": 1, "responses": [ { "response_id": 1, "fields": [ { "name": "Request_Type" , "title": "Request Type" , "type": "Text" , "value": "Submitted value by user", }, . . . ] }, . . . ] }
-
Request:
GET
/api/forms/<FORM_ID>/responses/customFilter/?field=<FIELD_NAME><=<LOWER_BOUND>>=<UPPER_BOUND>&eq=<EXACT_VALUE>
-
Numeric:
/api/forms/1/responses/customFilter/?field=Age&eq=25 /api/forms/1/responses/customFilter/?field=Age>=18 /api/forms/1/responses/customFilter/?field=Age<=30 /api/forms/1/responses/customFilter/?field=Age<=30>=18
-
Date:
/api/forms/1/responses/customFilter/?field=Submit_Date&eq=2020-01-01 /api/forms/1/responses/customFilter/?field=Submit_Date<=2020-02-30 /api/forms/1/responses/customFilter/?field=Submit_Date>=2020-01-01 /api/forms/1/responses/customFilter/?field=Submit_Date<=2020-02-30>=2020-01-01
-
String:
/api/forms/1/responses/customFilter/?field=First_Name&eq=Ali
-
Response for filtered request:
{ "title": "First Form", "form_id": 1, "responses": [ { "response_id": 1, "fields": [ { "name": "Age" , "title": "Age" , "type": "Number" , "value": 23, }, . . . ] }, . . . ] }