FSE - Emergency social network API doc

Documentation for clients connecting to the FSE social network application API
Announcement
POST /api/announcements
GET /api/announcements
Create Announcement
POST /api/announcements

Request body

Object
message
string
user_id
string
Get Announcements
GET /api/announcements

Retrieves the list of anouncements made in the past by a coordinator. This list can be searched and X number of results can be skipped. The list is sorted by

Request parameters

q
string optional

allows us to search the DB of announcements

limit
number optional

number of results to retrieve

Responses

200 OK
Body
Array of string
Private Chat

Has all the operations available that involve private chat messages and the private chatroom

POST /api/private-chat-messages
GET /api/private-chat-messages
GET /api/private-chat-messages
Create chat message for specific user
POST /api/private-chat-messages

Request headers

Authorization
string required

JWT token

Request body

Object
user_sender_id
string
user_receiver_id
string
message
string

Responses

201 Created
Body
Object
success
boolean
Example:
true
Get old chat messages with specific user
GET /api/private-chat-messages

Request parameters

user_id1
string optional
user_id2
string optional

Responses

200 OK
Body
Array
Object
message
string
Example:
Hello world 21313131313
Search chat messages with query word
GET /api/private-chat-messages

Authentication

JWT

Request parameters

user_id1
string optional
user_id2
string optional
q
string optional

Keyword to search for

page
string optional

Responses

200 OK
Body
Array
Object
message
string

how are you??

sender_name
string

Bond

timestamp
string

2012-12-12

status
string

OK

Public Chat

Has all the operations available that involve public chat messages and the public chatroom

POST /api/chat-messages/
GET /api/chat-messages
Create chat message
POST /api/chat-messages/

Authentication

Open

Receives and stores a public chat message from loggedin users.

Request headers

Authorization
string required

JWT token

Request body

Object
user_id
string
message
string

Responses

201 Created
Body
Object
success
boolean
Example:
true
Get chat messages
GET /api/chat-messages

Request parameters

q
string optional

keyword to search for

page
integer optional

page #

Responses

200 OK
Body
Array
Object
id
string
Example:
5e4b7a46b055c47cf0e7e930
user_id
string
Example:
5e4a10a1ca457757992d95a7
message
string
Example:
Hello world 21313131313
created_at
string
Example:
2020-02-18T05:46:46.869Z
user
Object
username
string
Example:
jplozano
status
string
Example:
status 1
Token and Authentication

Has a list of operations used to managed JWT token life cycle.

POST /api/token/
Authorization
string required

JWT token

Refresh or create new token
POST /api/token/

This creates a new token when a JWT token is expired.

Request headers

Refresh token
string required
Example:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiNWU0MWMxOGNjYTIyNjUyZjZiMTRkYjljIiwiaWF0IjoxNTgxMzY3NjkyLCJleHAiOjE1ODEzNzA2OTJ9.3Zqv7m8JxcRrgitOWM7iu5g2SWi2DeJUnNIKeURQnRo

Responses

201 Created
Body
Object
token
string
Example:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiNWU0MWMxOGNjYTIyNjUyZjZiMTRkYjljIiwiaWF0IjoxNTgxMzY3NjkyLCJleHAiOjE1ODE0MDM2OTJ9.MWvVKbYtlOQNSMCL9zdCAkKbYtYsbbkOI6tP2z09YAU
ex_token
string
Example:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiNWU0MWMxOGNjYTIyNjUyZjZiMTRkYjljIiwiaWF0IjoxNTgxMzY3NjkyLCJleHAiOjE1ODEzNzA2OTJ9.3Zqv7m8JxcRrgitOWM7iu5g2SWi2DeJUnNIKeURQnRo
403 Forbidden
User

Has the list of operations available to the User entity.

POST /api/user/
PUT /api/user/:id/
PUT /api/user/:id/logout
GET /api/user/{id}
GET /api/users/
GET /users/{id}/personal-message
Create User
POST /api/user/

Authentication

JWT

Creates a user during the signup process and identifies existing users to log them in if username and password are correct. This operations validates the structure of the username, password, validates for unique users, validates for prohibited usernames and registers the user. It returns the information of the user (id, name, username, acknowledgement) and the tokens associated to the user.

Request body

Object
username
string
Example:
affiliate222234423234234234_121
password
string
Example:
sdfdfsdfsdfsdfsdf12345555

Responses

201 Created
Body
Object
user
Object
userId
string
Example:
5e41beeb642c182d87a13aec
username
string
Example:
affiliate222234423234234234_121
acknowledgement
boolean
tokens
Object
token
string
Example:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiNWU0MWJlZWI2NDJjMTgyZDg3YTEzYWVjIiwiaWF0IjoxNTgxMzY3MDg5LCJleHAiOjE1ODE0MDMwODl9.p_HBx4bZTlwqJ2rkq4J6kquBeb3_Pd2TLyMqXw7-xl4
ex_token
string
Example:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiNWU0MWJlZWI2NDJjMTgyZDg3YTEzYWVjIiwiaWF0IjoxNTgxMzY3MDg5LCJleHAiOjE1ODEzNzAwODl9.N3e-rF2fj0fKWEzmphZTq7zRBhgU0GLvZWhqYHwrBa0
422 Unprocessable Entity
Update user
PUT /api/user/:id/

Authentication

JWT

Updates the user’s information (acknowledgement, status, online/offline). It requires a valid JWT token .

Request headers

Authorization
string required

JWT token

Request body

Object
acknowledgement
boolean

User acknowledgement of initial instructions

Example:
true
status
string
Example:
Emergency
online
boolean
Example:
true
name
string

First name

last_name
string

Last name

address
string

Users addres

phone_number
string

User’s phone number

birth_date
string
Example:
1970/03/25
city
string

Users current city

emergency_contact
Object
name
string
Example:
sadasdasd
address
string
Example:
sadasdasd
phone_number
string
Example:
4081111111
step
number

Indicates the step that will be saved

username
string

for username update only by admin

password
string

for username update only by admin

role
string

for username update only by admin

active
boolean

is the acount active ? //for username update only by admin

Responses

200 OK
Body
Object
name
string
Example:
Lau
last_name
string
Example:
lozano
address
string
Example:
lozano 234234234 234234234234
city
string
Example:
Sunnyvale
birth_date
string
Example:
12/15/1984
phone_number
integer
Example:
4645464
privacy_terms_data_accepted
integer
Example:
1
acknowledgement
integer
Example:
1
onLine
integer
Example:
1
status
string
Example:
OK
medical_information
Object
blood_type
string
Example:
AB+
allergies
string
prescribed_drugs
string
privacy_terms_medical_accepted
integer
Example:
1
emergency_contact
Object
name
string
Example:
Nati
phone_number
string
address
string
500 Internal Server Error
Logout user
PUT /api/user/:id/logout

Logs out a user. Invalidates his token.

Get user
GET /api/user/{id}

Path variables

id
string required

Request parameters

User name
string optional
Example:
James
Status
string optional
Example:
EMERGENCY

Responses

200 OK
Body
Array
Object
online status
boolean
status
string
Example:
HELP
timestamp
string
Example:
11:43:23
username
string
Example:
Juan
Get All Users
GET /api/users/

Authentication

JWT

Get a list of all the users, username, status and online attributes.

Responses

200 OK
Body
Array
Object
username
string

User name

Example:
james
onLine
boolean

Online or Offline status

Example:
true
status
string

User status

Example:
HELP
Search users by username/status
GET /api/users/

Authentication

JWT

Request parameters

username
string optional

username to search

Example:
James
status
string optional

user status

Example:
OK

Responses

200 OK
Body
Array
Object
username
string

username

Example:
JamesBond
online
boolean

online status

Example:
true
status
string

user status

Example:
OK
Get User personal message
GET /users/{id}/personal-message

Path variables

id
string required

Request parameters

security_question_answer
string optional

Security question answer

User List
Update user lists (Socket IO)
GET /api/userList

Authentication

JWT

Emit a socket IO event to update the users list of all the users connected

Responses

200 OK

Updating Users Lists

Spam Report
POST /api/spam-report
Create Spam Report
POST /api/spam-report

Authentication

JWT

create a spam report

Request body

Object
level
string

message or user

type
string

False/Harassing/AD/Others

description
string

any info

current_user_id
string
reported_user_id
string
message_id
string

Responses

201 Created
Body
Object
level
string
type
string
description
string
Resources
GET /api/resources
GET /api/resources/{id}
POST /api/resources
Get All Resources
GET /api/resources

Authentication

JWT

Get all resources registered

Responses

200 OK
Body
Object
name
string

Resource Name

description
string

Resource Description

Get Resource
GET /api/resources/{id}

Path variables

id
string required

Responses

200 Resource Model
Register a Resource
POST /api/resources

Authentication

JWT

Request body

Object
user_id
string

User that register the resource

resourceType
string

Resource Type

name
string

Resource Name

location
string

Resource Location

description
string

Resource Description

questionOne
string

Answer to question One

questionTwo
string

Answer to question Two

questionThree
string

Answer to question three

resourceImage
string

Imge to upload

Responses

200 Resource Model
200 Resource Model
Body
Object
user_id
string

User who register the resource

resourceType
string

Type of Resource

Example:
SUPPLIES,MEDICAL,SHELTER
name
string

Resource Name

location
string

Resource descriiption location

description
string

Resource description

questionOne
boolean

Answer of question two

questionTwo
boolean

Answer of question two

questionThree
boolean

Answer of question Three

image
Object

Resource uploaded image

data
unknown

Image

contentType
string

Image Content Type

Emergency Status Detail
GET /api/emergencyStatusDetail/:userId
PUT /api/emergencyStatusDetail/:userId
POST /api/emergencyStatusDetail/:userId
GET /api/emergencyStatusDetail/picture/:userId
PUT /api/emergencyStatusDetail/picture/:pictureId
DELETE /api/emergencyStatusDetail/picture/:pictureId
Get Status and Location Detail
GET /api/emergencyStatusDetail/:userId

Authentication

JWT

Responses

200 OK
Body
Object
user_id
string

User ID

Example:
3243kjfjd883k
status_description
string

Brief description of user situation

Example:
I am hurt
share_location
string

Brief description of user location

Example:
I am inside a big cave
Update Status and Location Detail
PUT /api/emergencyStatusDetail/:userId

Authentication

JWT

Request body

Object
description
string

new description for brief or location

Example:
I am hurt
detailType
string

detail type that is being updated

Example:
situation
Add New Pictures and Description
POST /api/emergencyStatusDetail/:userId

Request body

Object
pictureDescription
string

Description of the newly upload picture

Example:
This is a picture of a dog

Responses

201 Created
Body
Object
picture_description
string

Description of picture

Example:
This is a picture of a dog
picture_path
string

Path of the picture

Example:
path/to/picture
picture_name
string

Name of the picture

Example:
dog.jpeg
user_id
string

user id

Example:
hn41iluh8cor
Get All Picture and Description
GET /api/emergencyStatusDetail/picture/:userId

Authentication

JWT

Responses

200 OK
Body
Array
Object
user_id
string

user id

Example:
jner7ownlkdfa
picture_description
string

Description of a picture

Example:
This is a picture of a dog
picture_path
string

Path of the picture

Example:
path/to/picture
picture_name
string

Name of the picture

Example:
dogy.jpeg
Update Description of a Picture
PUT /api/emergencyStatusDetail/picture/:pictureId

Request body

Object
pictureDescription
string

New description

Example:
This is actually a picture of a cat

Responses

200 OK
Body
Object
user_id
string

user id

Example:
hnekrch13o4i7r
picture_description
string

New description

Example:
This is actually a picture of a cat
picture_path
string

Path of the picture

Example:
path/to/picture
picture_name
string

Name of picture

Example:
dogy.jpeg
Delete a Picture with Description
DELETE /api/emergencyStatusDetail/picture/:pictureId

Authentication

JWT

Responses

204 No Content
Body
Object
user_id
string

user id

Example:
hj1nkjrcjcjlkf
picture_description
string

Description of the deleted picture

Example:
This is a dog
picture_path
string

The path to the deleted picture

Example:
path/to/picture
picuture_name
string

Name of the deleted picture

Example:
dogy.jpeg