anonimo
Restful API
USERS
JSON EXAMPLE:
{
"email":"",
"id":1,
"name":"",
"password":""
}
ALL FIELDS ARE OPTIONAL
GET ALL USERS
GET http://localhost:8080/Anonimo/users
Response:
[
{
"email":"email@address.com",
"id":1,
"name":"nume",
"password":"parola"
},
{
"email":"",
"id":2,
"name":"Silviu",
"password":"Silviu"
}
]
GET USER HAVING ID 1
GET http://localhost:8080/Anonimo/users/1
Response:
{
"email":"email@address.com",
"id":1,
"name":"nume",
"password":"parola"
}
CREATE USER
POST http://localhost:8080/Anonimo/users
BODY:
{
"email":"email@address.com",
"name":"nume",
"password":"parola"
}
UPDATE USER HAVING ID 1
PUT http://localhost:8080/Anonimo/users/1
OR
POST /users/1/updateInfo
BODY:
{
"email":"another address",
"name":"another name",
"password":"another password"
}
DELETE USER HAVING ID 1
DELETE http://localhost:8080/Anonimo/users/1
CUSTOM ACTIONS
GET /users/y/messages returns messages of user "y" Response:
[
{
"date": 1366230231,
"id": 4,
"latitude": "44.435519",
"longitude": "26.102527",
"text": "Si ce mai face fetilii? Ie bini di tat?",
"userId": 7
}
]
POST /users/1/updateInfo
(Update user through POST)
GET /users/32/events returns events joined by User having ID 32
[
{
"eventId": 9,
"id": 4,
"text": "joined event",
"userId": 32
}
]
MESSAGES
JSON EXAMPLE:
{
"date":12,
"id":1,
"latitude":"",
"longitude":"",
"text":"First message",
"userId":1
}
"date" type long = milliseconds since 1970
"userId" type long
All other fields types are strings
GET /messages (displays all messages)
Response (array of objects):
[
{
"date":12,
"id":1,
"latitude":"",
"longitude":"",
"text":"First message",
"userId":1
},
{
"date":12,
"id":2,
"latitude":"",
"longitude":"",
"text":"Second message",
"userId":1
}
]
POST /messages create
PUT /messages/1 update id="1"
DELETE /messages/1 delete id="1"
GET /messages/1 show id="1"
CUSTOM ACTIONS
GET /messages/7/comments returns comments of message #7 Response:
[
{
"date": 1366419985,
"id": 2,
"messageId": 7,
"text": "Da, foarte smecher!",
"userId": 31
}
]
GET /messages/{id}/photo (get photos for a message) Response:
[
{
"id": 1,
"messageId": 1,
"image": "base64_string"
}
]
COMMENTS
JSON:
{
"date": 0,
"id": 1,
"messageId": 0,
"text": "test",
"userId": 0
}
ACTIONS:
POST /comments create
PUT /comments/1 update id="1"
DELETE /comments/1 delete id="1"
GET /comments/1 show id="1"
EVENTS
JSON:
{
"date": 0,
"description": "First event",
"id": 1,
"latitude": "",
"longitude": "",
"userId": 1
}
ACTIONS:
POST /events create
PUT /events/1 update id="1"
DELETE /events/1 delete id="1"
GET /events/1 show id="1"
CUSTOM ACTIONS:
GET /events/{id}/participants (get participants for event)
Ex: GET /events/1/participants Result:
[
{
"eventId": 1,
"participants": 2
}
]
USER_EVENT
JSON:
{
"eventId": 1,
"id": 1,
"text": "joined event",
"userId": 2
}
ACTIONS:
POST /user_events create
PUT /user_events/1 update id="1"
DELETE /user_events/1 delete id="1"
GET /user_events/1 show id="1"
VOTES
JSON:
{
"id": 1,
"messageId": 1,
"userId": 7,
"value": "up"
}
CUSTOM ACTIONS:
GET /messages/{id}/votes (get votes for a message)
Ex: GET /messages/1/votes Result:
[
{
"downVotes": 2,
"upVotes": 1
}
]
DEFAULT ACTIONS:
POST /votes create
PUT /votes/1 update id="1"
DELETE /votes/1 delete id="1"
GET /votes/1 show id="1"
PHOTOS
JSON:
{
"id": 1,
"messageId": 1,
"image": "base64_string"
}
CUSTOM ACTIONS:
GET /messages/{id}/photo (get photos for a message)
DEFAULT ACTIONS:
POST /photos create
PUT /photos/1 update id="1"
DELETE /photos/1 delete id="1"
GET /photos/1 show id="1"