Predicted endpoints - simaob/posso-ir-api GitHub Wiki
Endpoint - GET /stores?filter[location]=lat,long&filter[store-type]=store-type
Description - Retrieves the 100 closest stores to the location defined by (lat,long). Filter store-type
is optional, if passed it will filter the stores that have the selected type. The available types at the moment are: supermarket, pharmacy, restaurant, gas_station, bank, coffee, kiosk, other, atm, post_office, beach. If the type passed is others
(notice plural, and not the available type other
), the API will filter out supermarket, pharmacy, restaurant, coffee, beach
, and return stores of the remaining types.
Authorization Header - JWT
Response Data - Format: JSONAPI. Attributes: name, location (address + coordinates), timestamp
Example
{
"data": [
{
"id": "161",
"type": "stores",
"attributes": {
"name": "Continente Cedofeita",
"group": "Continente",
"address": "Rua de Cedofeita, 4000, Porto",
"coordinates": [2.2323, 1.2323],
"capacity": 150,
"details": "Aberto das 8 às 20, excepto aos fins-de-semana"
},
...
]
}
Endpoint - GET /random-stores?filter[location]=lat,long&filter[store-type]=store-type
Description - This endpoint works exactly like the /stores
one, but randomizes attributes of the stores. Filtering still works the same.
Authorization Header - JWT
Response Data - Format: JSONAPI. Attributes: name, location (address + coordinates), timestamp
Example
{
"data": [
{
"id": "161",
"type": "stores",
"attributes": {
"name": "Continente Cedofeita",
"group": "Continente",
"address": "Rua de Cedofeita, 4000, Porto",
"coordinates": [2.2323, 1.2323],
"capacity": 150,
"details": "Aberto das 8 às 20, excepto aos fins-de-semana"
},
...
]
}
Endpoint - GET /stores/:id
Description - Retrieves a single store
Response Data - Format: JSONAPI. Attributes: Same as before, but with only one element
Example
{
"data":
{
"id": "161",
"type": "stores",
"attributes": {
"name": "Continente Cedofeita",
"group": "Continente",
"address": "Rua de Cedofeita, 4000, Porto",
"coordinates": [2.2323, 1.2323],
"capacity": 150,
"details": "Aberto das 8 às 20, excepto aos fins-de-semana"
}
}
Endpoint - GET /status-crowdsources?filter[store_id]=1,2,3,4,5,6
Description - Retrieves a list of of status for the stores listed.
Response Data - Format: JSONAPI. Attributes: status, queue_status, updated_time, valid_until
Example
{
"data": [
{
"id": "161",
"type": "status-crowdsources",
"attributes": {
"status": 5,
"queue_status": 0,
"updated-time": "2020-03-18 11:00",
"valid-until": "2020-03-18 11:30"
},
...
]
}
Endpoint - POST /status-commitment-users
Description - Notifies the server that the user is planning on going to a specific store
Request Data - JSONAPI format. Timestamp, expected time to go, expected visit duration
Request Example
{
"data":
{
"type": "status-commitment-users",
"attributes": {
"store-id": 1,
"posted-at": "2020-03-18 10:30",
"start-at": "2020-03-18 11:00",
"duration": 20
}
}
Authorization Header - JWT
Response Data - Format: JSONAPI. Attributes: Store.
Endpoint - POST /status-crowdsource-users
Description - Notifies the server of the current status of the store
Request Data - JSONAPI format. Timestamp, value (0-10, 0: empty, 10: full)
Request Example
{
"data":
{
"type": "status-crowdsource-users",
"attributes": {
"store-id": 1,
"status": 5,
"queue": 0,
"posted-at": "2020-03-18 11:00"
}
}
Authorization Header - JWT
Response Data - Format: JSONAPI. Attributes: Store.
Endpoint - GET /stores
Key header- StoreOwnerCode
Description - Returns the stores the user manages
Response Example
{
"data": [
{
"id": "161",
"type": "stores",
"attributes": {
"name": "Continente Cedofeita",
"group": "Continente",
"address": "Rua de Cedofeita, 4000, Porto",
"coordinates": [2.2323, 1.2323],
"capacity": 150,
"details": "Aberto das 8 às 20, excepto aos fins-de-semana"
},
...
]
}
Endpoint - POST /status-store-owners
Key header- StoreOwnerCode
Description - Set the status for the store owner
Request Data - JSONAPI format. Timestamp, value (0-10, 0: empty, 10: full)
Request Example
{
"data":
{
"type": "status-store-owners",
"attributes": {
"store-id": 1,
"status": 5,
"queue": 0,
"posted-at": "2020-03-18 11:00"
}
}
Authorization Header - JWT
Response Data - Format: JSONAPI. Attributes: Store.
Auth
Endpoint - POST /register
Authorization header- JWT
Description - Registers a new user
Request Data - JSONAPI format.
Request Example
{
"data": {
"type":"register",
"attributes": {
"name": "derp",
"email":"[email protected]",
"password":"secret-password",
"checkbox-deco": true,
"checkbox-terms": true,
"checkbox-privacy": true
}
}
}
Response Data
{message: "User created successfully"} status: 201
Endpoint - POST /login
Authorization header- JWT
Description - Logs in a user
Request Data - JSONAPI format.
Request Example
{
"data": {
"type":"login",
"attributes": {
"email":"[email protected]",
"password":"secret-password"
}
}
}
Response Data - Format: JSONAPI. Attributes: Favorites.
{
"data": [
{
"id": "2",
"type": "favorites",
"attributes": {
"store-id": 126358,
"user-id": 24
}
}
]
}
Endpoint - POST /logout
Authorization header- JWT
Description - Logs out the user
Request Data - JSONAPI format.
Request Example
{
"data": {
"type":"login",
"attributes": {
"email":"[email protected]"
}
}
}
Response Data
{message: "user logged out"} status: 200
Favorites
Endpoint - GET /favorites
Authorization header- JWT
Description - Returns the list of favorites for the user that made the request
Request Data - JSONAPI format.
Response Data - Format: JSONAPI. Attributes: Favorites.
{
"data": [
{
"id": "1",
"type": "favorites",
"attributes": {
"store-id": 126368,
"created-at": "2020-06-29T10:19:57.971Z"
}
},
{
"id": "2",
"type": "favorites",
"attributes": {
"store-id": 126358,
"created-at": "2020-06-29T10:20:52.797Z"
}
}
]
}
Endpoint - POST /favorites
Authorization header- JWT
Description - Adds a new favorite to user's list of favorites
Request Data - JSONAPI format.
Request Example
{
"data": {
"type":"favorites",
"attributes": {
"store-id": 1
}
}
}
Response Data - Format: JSONAPI. Attributes: Favorite.
{
"data": {
"id": "1",
"type": "favorites",
"attributes": {
"store-id": 126368,
"user-id": 24
}
}
}
Endpoint - DELETE /favorites/:id
Authorization header- JWT
Description - Deletes the favorite with id :id of the requester.
Request Data - JSONAPI format.
Response Data - No content on the response.
External API
Endpoint - POST /status-phone
Authorization header- JWT
Description - Set the status for the store owner (sent through an external API)
Request Data - JSONAPI format. Timestamp, value (0-10, 0: empty, 10: full)
Request Example
{
"phone": "00351912345678",
"status": 0
}
Response Data
{message: "Added status for store: #{store.id}"}