Skip to content

Webservice under development for the Smartbee project. Its function is to provide the applications developed for the project (Mobile application, site, etc ...), an option to make available as information collected by the sensors located in the hives.

Notifications You must be signed in to change notification settings

alissonlimasilva/smartbee-webservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

smartbee-webservice

Webservice under development for the Smartbee project.

Its function is to provide the applications developed for the project (Mobile application, site, etc ...), an option to make available as information collected by the sensors located in the hives.

Important links

Github principal do projeto

Github da aplicação móvel

End Points

The webservice provides the following URIs:

URIs GET

  • /colmeia: Lists all monitored hives and returns an ArrayJson like the one shown below.
[  
  {  
    "idColmeia":"string",
    "latitude":"string",
    "longitude":"string",
    "datacriacao":"string",
    "numerocoletas":int
  },
  {  
    "idColmeia":"string",
    "latitude":"string",
    "longitude":"string",
    "datacriacao":"string",
    "numerocoletas":int
  }
]
  • /colmeia/{ID COLMEIA}/info: Returns importants information about the monitored hive in focus. Get hive ID through pathParam(ID COLMEIA) and returns the json below.
{  
  "idColmeia":"string",
  "latitude":"string",
  "longitude":"string",
  "datacriacao":"string",
  "numerocoletas":int
}
  • /apiarios: Returns to ArrayJson with list of all apiaries registered in the system.
[  
   {  
      "idApiario":int,
      "descricao":"string",
      "latitude":"string",
      "longitude":"string"
   },
   {  
      "idApiario":int,
      "descricao":"string",
      "latitude":"string",
      "longitude":"string"
   }
]
  • /colmeia/{ID COLMEIA}: Returns a JSON with the last data collected by the sensors in the hive indicated by the parameter.
{  
   "amostra":int,
   "idColmeia":"string",
   "datahora":{  
      "year":2017,
      "month":7,
      "dayOfMonth":20,
      "hourOfDay":21,
      "minute":29,
      "second":40
   },
   "som":double,
   "temperatura":double,
   "umidade":double,
   "dioxido":double,
   "tensaocolmeia":double,
   "tensaorepetidor":double,
   "tensaogateway":double
}

OBS: The datetime attribute is of type java.util.Calendar.

  • /colmeia/{id da colmeia}/{medida} Receives the hive ID and the metric per parameter by PathParam and returns a JSON containing average, current value, lowest value and highest value collected from metric received.
{  
   "media":valor,
   "minimo":valor,
   "maximo":valor,
   "atual":valor
}
  • /colmeias/{id da colmeia}/historico/{tempo em horas}/hour
    Or
    /colmeias/{id da colmeia}/historico/{tempo em minutos 1 a 59}/min

The server receives the PathParam hive ID and time, which can be in hours or minutes depending on the URI. After processing is returned an ArrayJson containing all the collections in the time interval.

[  
  {  
    "amostra":int,
    "idColmeia":"string",
    "datahora":{  
      "year":2017,
      "month":7,
      "dayOfMonth":22,
      "hourOfDay":11,
      "minute":32,
      "second":34
    },
    "som":double,
    "temperatura":double,
    "umidade":double,
    "dioxido":double,
    "tensaocolmeia":double,
    "tensaorepetidor":double
  }

OBS: The datetime attribute is of type java.util.Calendar.

URIs POST

  • /add/coleta : Adds a new collection. Expect to receive the Json shown below and return Status Code 200 if the store was successfully held or Status Code 500 for error.

If the datahora key is not included in Json, the server stores the time of receipt.

{  
  "idColmeia":"string",
  "datahora":{  
    "year":valor,
    "month":valor,
    "dayOfMonth":valor,
    "hourOfDay":valor,
    "minute":valor,
    "second":valor
  },
  "som":double,
  "temperatura":double,
  "umidade":double,
  "dioxido":double,
  "tensaocolmeia":double,
  "tensaorepetidor":double,
  "tensaogateway":double
}
]
  • /cadastro The server receives a serialized object in Json as shown below and saved to the database. The system uses the SHA-256 algorithm to generate a password hash code.

This end point returns 3 possible Status Code's as a response:

Successful registration: Status Code 200.

Email already used by another user: Status Code 409 (Conflict).

Internal server error: Status Code 500

{
  "name":"string",
  "email":"string",
  "address":"string",
  "phone":"string",
  "cellphone":"string",
  "password":"string"
}
  • /login

This end point receives a Json containing login and password as shown below.

{  
  "login":"string",
  "senha":"string"
}

After processing returns Status codes indicating the error in authentication or a Json containing the token needed to access the URIs of the server.

Login does not exist = Status code 400

User Profile is not activated = Status code 403

Incorrect password = Status code 401

If login occurs successfully returns Status code 200 and Json shown below with login, password and token generated.

{  
  "login":"string",
  "senha":"string",
  "token":"string",
}

Features

Authentication

To authenticate to the system it is necessary to have a token that the system makes available, it is possible to obtain this token following the steps indicated in the previous section. After purchased token, each request that is made to the system is required to send a header with Authorization key and value "Bearer + <value of token>" . Below is an example of how the request should be made.

Header 
    key = Authorization 
    value = Bearer eyJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE1MDUzMjI0ODEsImlzcyI6Im

About

Webservice under development for the Smartbee project. Its function is to provide the applications developed for the project (Mobile application, site, etc ...), an option to make available as information collected by the sensors located in the hives.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages