Skip to content

Repository files navigation

UFPI Eventos

This is a project that aims to manage upgoing events at Universidade Federal do Píaui.

How To Setup

  • Install Ruby
  • Install Rails
  • Run on Terminal

Bundle Install

  • Run the Server

Rails s

  • To run the tests

Rails -s

Dependencies

  • Shrine
  • Autonumeric-rails
  • Devise
  • Omniauth-Facebook

Endpoints Usage

PathMethodPurpose
/eventGET / POSTIt returns all events that are register in database. It can pass some ordering params, right now you can order by 'Date' and 'Value'. You can pass this values in the url, or the body of request. For a decrescent ordering, you must pass the attribute name followed by 'desc' like "?date=desc". The otherway you can do by "?date=asc". In this endpoint it will only return events that are published, and will happen in a future date.
/event/idGETIt return the event specified by the id in url parameter
/event/addPOSTIn this endpoint you can add new events to your database. For default the event will get status "Pendent". An example of the json that you need to pass to server is provide below.
/event/:event_id/publishGETIn this endpoint you set the published flag of the event to true, and update his status to "Approved"
/event/:event_id/rejectGETIn this endpoint you set the published flag of the event to false, and update his status to "Reject"
/event/searchGETIn this endpoint you can pass specific parameters that will act as filters. Right now you can pass "name", and "user_id", "date" and "published".
/users/idGETIt return the information about a specific user by its id
/academicGETIt return all the academic events registered in database
/CulturalGETIt return all the cultural events registered in database, that will happen in a future date. Right now it will return also the Unpublished ones.
/users/:idGETIt will return the information about a specific user by its ID.
/eventPOSTEvent registration. you need to sendo to server, date, name, description, image_url, value, address, contact, type in the message body
/authPOSTEmail registration. Requires email, password, and password_confirmation params.
auth/sign_inPOSTEmail authentication. Requires email and password as params. This route will return a JSON representation of the User model on successful login along with the access-token and client in the header of the response.

Examples Of Returned Data

  • /event
[{"event_id": 30,"name": "Makenna Reilly","description": "Amet porro esse quaerat aliquid.","value": "56.54","address": "Roberts Centers","contact": "owen@rippin.name","type": "Academic","date": "2017-10-02T00:00:00.000Z","images": ["http://lorempixel.com/300/300"],"status": "pending","user": 20,"published": true,"lat": "40.561791064605785","long": "14.530943974654548"},{"event_id": 31,"name": "Henry Collier","description": "Et cupiditate dolor vel.","value": "63.81","address": "Edythe Flat","contact": "jennie@ryan.info","type": "Academic","date": "2017-10-06T00:00:00.000Z","images": ["http://lorempixel.com/300/300"],"status": "pending","user": 21,"published": true,"lat": "13.390221663010323","long": "143.354924744708"},]
  • /users/:id
{"id": 20,"provider": "email","uid": "randi@murphy.co","name": "Mathew Wyman","nickname": null,"image": null,"email": "randi@murphy.co","events": [30]}

Examples Of Sending Data

  • /event/add
{"event":{"description": "DFASF","value": "12.3","name": "Event","address": "Rua 100","type": "Academic","contact": "Assf","user_id": "1","lat": "904.34","long": "459.6","date": "2017-08-30T19:47:12.403Z","images_attributes": [{"image_url":"Lorem.com.br"}]}}

Token Header Format

The authentication information should be included by the client in the headers of each request. The headers follow the RFC 6750 Bearer Token format:

Authentication headers example:

"access-token": "wwwww",
"token-type": "Bearer",
"client": "xxxxx",
"expiry": "yyyyy",
"uid": "zzzzz"

The authentication headers consists of the following params:

paramdescription
access-tokenThis serves as the user's password for each request. A hashed version of this value is stored in the database for later comparison. This value should be changed on each request.
clientThis enables the use of multiple simultaneous sessions on different clients. (For example, a user may want to be authenticated on both their phone and their laptop at the same time.)
expiryThe date at which the current session will expire. This can be used by clients to invalidate expired tokens without the need for an API request.
uidA unique value that is used to identify the user. This is necessary because searching the DB for users by their access token will make the API susceptible to timing attacks.

The authentication headers required for each request will be available in the response from the previous request. If you are using the ng-token-auth AngularJS module or the jToker jQuery plugin, this functionality is already provided.

About

Backend code for the UFPI Events application.

Topics

Resources

Stars

0 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages