This API was structured with the aim of being the back-end part of the OnTrip app, a front-end project made previously by some of the members of this group.
OnTrip is an accommodation booking platform focused on digital nomads. Therefore, the structure of this API is based on three main CRUD (Create-Read-Update-Delete):
- Users
- Accommodations
- Bookings
Some other routes and entities were needed, due to all the possible data and relationships of these three main entities.
These were the main technologies used in this project:
Base URL: https://ontrip.herokuapp.com/
- Letícia de Araújo Nunes - TL
- André Perregil - PO
- Bruno Passos - SM
- André Volcov - Dev
- Hítalo Santos - Dev
- Matheus Vieira - Dev
Clone the project on your machine and install dependencies with the command:
yarn
Then create a .env file, copying the .env.example file format:
cp .env.example .env
Set your environment variables with your Postgres credentials and a new database of your choice.
Run migrations with the command:
yarn typeorm migration:run -d src/data-source.ts
Some routes need authentication. The authentication used is the Bearer Token type.
The token is generated automatically at user login.
Thus, to access routes with authentication, it is necessary to have a user and be logged in with the user.
In addition, some routes require the user to be an administrator, or owner of the account, or of an accommodation, or the user who made the booking.
Please read each route's documentation to understand which authentications are required.
The User object is defined as:
Field | Type | Description |
---|---|---|
id | string | User's unique identifier |
username | string | User name |
string | User email | |
password | string | User password |
dateOfBirth | string | User's date of birth |
isAdm | boolean | Defines whether a user is an administrator or not |
isActive | boolean | Defines whether a user is active or not |
file | file | User's profile photo file sent in the request |
photo | string | User's profile photo url generated by cloudinary |
Method | Route | Description |
---|---|---|
POST | /users | Creates a user |
GET | /users | List all users |
GET | /users/:userId | Lists a user using its ID as a parameter |
PATCH | /users/:userId | Updates a user using its ID as a parameter |
DELETE | /users/:userId | Soft-deletes a user using its ID as a parameter |
- Host: https://ontrip.herokuapp.com/
- Authorization: None
- Content-type: multipart/form-data
Request body example
username: "Bob Spencer",
email: "bobspencer@email.com",
password: "874aS4A6F65i",
dateOfBirth: "14/03/1993",
isAdm?: true,
file?: file.jpg
Status 201 - Created
{
"message": "User created with success",
"user": {
"id": "f1719800-2e5a-4270-88de-64380f73dd3d",
"username": "Bob Spencer",
"email": "bobspencer@email.com",
"dateOfBirth": "14/03/1993",
"photo": "https://res.cloudinary.com/de8wdumps/image/upload/v1662750917/zdlf9ppnkqfjlbxejo8f.jpg",
"isAdm": true,
"isActive": true
}
}
Status 400 - Missing required field
{
"status": "Error",
"code": 400,
"message": "(any object key) is a required field"
}
Status 400 - Invalid data type or length
{
"status": "Error",
"code": 400,
"message": "yup error message"
}
Status 409 - Email already exists
{
"status": "Error",
"code": 409,
"message": "This email already exists"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Bearer Token
- User must be an admin
- Content-type: application/json
- Empty Body
Request headers
{
"authorization": "Bearer Token"
}
Status 200 - OK
{
"message": "Successful request",
"users": [
{
"id": "f1719800-2e5a-4270-88de-64380f73dd3d",
"username": "Bob Spencer",
"email": "bobspencer@email.com",
"dateOfBirth": "14/03/1993",
"photo": "https://res.cloudinary.com/de8wdumps/image/upload/v1662750917/zdlf9ppnkqfjlbxejo8f.jpg",
"isAdm": true,
"isActive": true
},
...
]
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin
{
"status": "Error",
"code": 401,
"message": "User is not an admin"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Bearer Token
- User must be an admin or the owner of the account
- Content-type: application/json
- Empty Body
Request headers
{
"authorization": "Bearer Token"
}
Status 200 - OK
{
"message": "Successful request",
"user": {
"id": "f1719800-2e5a-4270-88de-64380f73dd3d",
"username": "Bob Spencer",
"email": "bobspencer@email.com",
"dateOfBirth": "14/03/1993",
"photo": "https://res.cloudinary.com/de8wdumps/image/upload/v1662750917/zdlf9ppnkqfjlbxejo8f.jpg",
"isAdm": true,
"isActive": true
}
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin or the owner of the account
{
"status": "Error",
"code": 401,
"message": "User must be an admin or the owner of the account"
}
Status 404 - User not found
{
"status": "Error",
"code": 404,
"message": "User not found"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Bearer Token
- User must be an admin or the owner of the account
- Content-type: multipart/form-data
Request headers
{
"authorization": "Bearer Token"
}
Request body example
username?: "Bob Spencer",
email?: "bob_spencer@email.com",
password?: "874aS4A6F65i",
dateOfBirth?: "14/03/1993",
*isAdm?: true,
file?: file.jpg
- At least one field is required
- Only Adm users can update the isAdm field
Status 200 - OK
{
"message": "User updated with success",
"user": {
"id": "f1719800-2e5a-4270-88de-64380f73dd3d",
"username": "Bob Spencer",
"email?": "bob_spencer@email.com",
"dateOfBirth": "14/03/1993",
"photo": "https://res.cloudinary.com/de8wdumps/image/upload/v1662750917/zdlf9ppnkqfjlbxejo8f.jpg9",
"isAdm": true,
"isActive": true
}
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin or the owner of the account
{
"status": "Error",
"code": 401,
"message": "User must be an admin or the owner of the account"
}
Status 409 - Email already exists
{
"status": "Error",
"code": 409,
"message": "Email already exists"
}
Status 400 - Invalid data type or length
{
"status": "Error",
"code": 400,
"message": "yup error message"
}
Status 404 - User not found
{
"status": "Error",
"code": 404,
"message": "User not found"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Bearer Token
- User must be an admin or the owner of the account
- Content-type: application/json
- Empty Body
Request headers
{
"authorization": "Bearer Token"
}
Status 200 - OK
{
"message": "User deleted with success"
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin or the owner of the account
{
"status": "Error",
"code": 401,
"message": "User must be an admin or the owner of the account"
}
Status 404 - User not found
{
"status": "Error",
"code": 404,
"message": "User not found"
}
Status 400 - User already deleted
{
"status": "Error",
"code": 400,
"message": "User already deleted"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
The Login object is defined as:
Field | Type | Description |
---|---|---|
string | User email | |
password | string | User password |
Method | Route | Description |
---|---|---|
POST | /login | Login user |
- Host: https://ontrip.herokuapp.com/
- Authorization: None
- Content-type: application/json
Request body example
{
"email": "bobspencer@email.com",
"password": "874aS4A6F65i"
}
Status 200 - OK
{
"message": "Login successful",
"token": "yJhbGciOiJIUzI1NiJ9.eyJSb2xlIjoiQWRtaW4iLCJJc3N1ZXIiOiJJc3N1ZXIiLCJVc2VybmFtZSI6IkphdmFJblVzZSIsImV4cCI6MTY2MjY4ODU1OCwiaWF0IjoxNjYyNjg4NTU4fQ.OONsla408_ohD5XE9b3-qfWaniZC95pgyBetmJeKViA"
}
Status 400 - Missing required field
{
"status": "Error",
"code": 400,
"message": "(any object key) is a required field"
}
Status 401 - Invalid email or password
{
"status": "Error",
"code": 401,
"message": "Invalid email or password"
}
The Accommodation object is defined as:
Field | Type | Description |
---|---|---|
id | string | Accommodation's unique identifier |
name | string | Accommodation name |
description | string | Accommodation description |
dailyPrice | number | Daily price for accommodation |
isActive | boolean | Defines whether the accommodation is active or not |
verifiedByAdm | boolean | Defines whether the accommodation is verified by an administrator or not |
specialOffer | boolean | Defines whether the accommodation has a special offer or not |
owner | object | User who owns the accommodation |
type | object | Accommodation type |
capacity | object | Accommodation capacity |
category | object | Accommodation category |
Method | Route | Description |
---|---|---|
POST | /accommodations | Creates an accommodation |
GET | /accommodations | Lists all accommodations |
GET | /accommodations/:accommodationId | Lists an accommodation using its ID as a parameter |
PATCH | /accommodations/:accommodationId | Updates an accommodation using its ID as a parameter |
DELETE | /accommodations/:accommodationId | Soft-deletes an accommodation using its ID as a parameter |
- Host: https://ontrip.herokuapp.com/
- Authorization: Bearer Token
- Content-type: application/json
Request headers
{
"authorization": "Bearer Token"
}
Request body example
{
"name": "Complete apartment to work",
"description": "Ideal apartment to work remotely, quiet, comfortable, and with all the requirements for a perfect home office.",
"dailyPrice": 450,
"typeId": "6e79c2b7-c479-46e3-aeac-b9f62739799e",
"userId": "04506439-de18-4700-9175-1876e0ed8c34",
"capacityId": "0b327321-603d-45a7-b4cd-525c11c14b04",
"categoryId": "d3b5f8db-a292-46b4-ae69-7821c2789dcd"
}
Status 201 - Created
{
"message": "Accommodation created with success",
"accommodation": {
"id": "90ee8282-af60-4570-9847-fb99d5555355",
"name": "Complete apartment to work",
"description": "Ideal apartment to work remotely, quiet, comfortable, and with all the requirements for a perfect home office.",
"dailyPrice": 450,
"isActive": true,
"verifiedByAdm": false,
"specialOffer": false,
"type": {
"name": "A whole place"
},
"owner": {
"id": "f1719800-2e5a-4270-88de-64380f73dd3d",
"username": "Bob Spencer",
"email": "bobspencer@email.com",
"dateOfBirth": "14/03/1993",
"photo": "L2dvYWwgbW9yZJShu54j98vgSD79",
"isAdm": false,
"isActive": true
},
"capacity": {
"rooms": 2,
"beds": 2,
"totalGuests": 4,
"bathrooms": 2
},
"category": {
"name": "Apartment"
}
}
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 400 - Missing required field
{
"status": "Error",
"code": 400,
"message": "(any object key) is a required field"
}
Status 400 - Invalid data type or length
{
"status": "Error",
"code": 400,
"message": "yup error message"
}
Status 409 - Accommodation already registered
{
"status": "Error",
"code": 409,
"message": "This accommodation is already registered"
}
Status 404 - User not found
{
"status": "Error",
"code": 404,
"message": "User not found"
}
Status 404 - Type not found
{
"status": "Error",
"code": 404,
"message": "Type not found"
}
Status 404 - Capacity not found
{
"status": "Error",
"code": 404,
"message": "Capacity not found"
}
Status 404 - Category not found
{
"status": "Error",
"code": 404,
"message": "Category not found"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: None
- Content-type: application/json
- Empty body
Status 200 - OK
{
"message": "Successful request",
"accommodations": [
{
"id": "90ee8282-af60-4570-9847-fb99d5555355",
"name": "Complete apartment to work",
"description": "Ideal apartment to work remotely, quiet, comfortable, and with all the requirements for a perfect home office.",
"dailyPrice": 450,
"isActive": true,
"verifiedByAdm": false,
"specialOffer": false,
"type": {
"name": "A whole place"
},
"owner": {
"id": "f1719800-2e5a-4270-88de-64380f73dd3d",
"username": "Bob Spencer",
"email": "bobspencer@email.com",
"dateOfBirth": "14/03/1993",
"photo": "L2dvYWwgbW9yZJShu54j98vgSD79",
"isAdm": false,
"isActive": true
},
"capacity": {
"rooms": 2,
"beds": 2,
"totalGuests": 4,
"bathrooms": 2
},
"category": {
"name": "Apartment"
}
},
...
]
}
- No errors expected
- Host: https://ontrip.herokuapp.com/
- Authorization: None
- Content-type: application/json
- Empty body
Status 200 - OK
{
"message": "Successful request",
"accommodation": {
"id": "90ee8282-af60-4570-9847-fb99d5555355",
"name": "Complete apartment to work",
"description": "Ideal apartment to work remotely, quiet, comfortable, and with all the requirements for a perfect home office.",
"dailyPrice": 450,
"isActive": true,
"verifiedByAdm": false,
"specialOffer": false,
"type": {
"name": "A whole place"
},
"owner": {
"id": "f1719800-2e5a-4270-88de-64380f73dd3d",
"username": "Bob Spencer",
"email": "bobspencer@email.com",
"dateOfBirth": "14/03/1993",
"photo": "L2dvYWwgbW9yZJShu54j98vgSD79",
"isAdm": false,
"isActive": true
},
"capacity": {
"rooms": 2,
"beds": 2,
"totalGuests": 4,
"bathrooms": 2
},
"category": {
"name": "Apartment"
}
}
}
Status 404 - Accommodation not found
{
"status": "Error",
"code": 404,
"message": "Accommodation not found"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Bearer Token
- User must be the owner of the accommodation or an admin
- Content-type: application/json
Request headers
{
"authorization": "Bearer Token"
}
Request body example
{
"name?": "Complete apartment to work",
"description?": "Ideal apartment to work remotely, quiet, comfortable, and with all the requirements for a perfect home office.",
"dailyPrice?": 300,
"specialOffer?": true,
"*verifiedByAdm?": true,
"typeId?": "6e79c2b7-c479-46e3-aeac-b9f62739799e",
"capacityId?": "0b327321-603d-45a7-b4cd-525c11c14b04"
}
- At least one field is required
- The field verifiedByAdm can only be updated by an Adm
Status 200 - OK
{
"message": "Accommodation updated with success",
"accommodation": {
"id": "90ee8282-af60-4570-9847-fb99d5555355",
"name": "Complete apartment to work",
"description": "Ideal apartment to work remotely, quiet, comfortable, and with all the requirements for a perfect home office.",
"dailyPrice": 300,
"isActive": true,
"verifiedByAdm": false,
"specialOffer": true,
"type": {
"name": "A whole place"
},
"owner": {
"id": "f1719800-2e5a-4270-88de-64380f73dd3d",
"username": "Bob Spencer",
"email": "bobspencer@email.com",
"dateOfBirth": "14/03/1993",
"photo": "L2dvYWwgbW9yZJShu54j98vgSD79",
"isAdm": false,
"isActive": true
},
"capacity": {
"rooms": 2,
"beds": 2,
"totalGuests": 4,
"bathrooms": 2
},
"category": {
"name": "Apartment"
}
}
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin or the owner of the accommodation
{
"status": "Error",
"code": 401,
"message": "User must be an admin or the owner of the accommodation"
}
Status 400 - Invalid data type or length
{
"status": "Error",
"code": 400,
"message": "yup error message"
}
Status 400 - No changes in accommodation data
{
"status": "Error",
"code": 400,
"message": "Not possible to update an accommodation without having any changes in any field"
}
Status 404 - Accommodation not found
{
"status": "Error",
"code": 404,
"message": "Accommodation not found"
}
Status 404 - Type not found
{
"status": "Error",
"code": 404,
"message": "Type not found"
}
Status 404 - Capacity not found
{
"status": "Error",
"code": 404,
"message": "Capacity not found"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Bearer Token
- User must be the owner of the accommodation or an admin
- Content-type: application/json
- Empty body
Request headers
{
"authorization": "Bearer Token"
}
Status 200 - OK
{
"message": "Accommodation deleted with success"
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin or the owner of the accommodation
{
"status": "Error",
"code": 401,
"message": "User must be an admin or the owner of the accommodation"
}
Status 400 - Accommodation already deleted
{
"status": "Error",
"code": 400,
"message": "Accommodation already deleted"
}
Status 404 - Accommodation not found
{
"status": "Error",
"code": 404,
"message": "Accommodation not found"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
The Booking object is defined as:
Field | Type | Description |
---|---|---|
id | string | Booking's unique identifier |
checkIn | string | Defines the data and time for a chekin |
checkout | string | Defines the data and time for a checkout |
accommodationId | string | Accommodation's unique identifier |
status | string | Defines if the booking is "booked" or "canceled" |
userId | string | User's unique idetifier |
Method | Route | Description |
---|---|---|
POST | /bookings | Creates a new booking |
GET | /bookings | List all bookings |
GET | /bookings/:bookingId | Lists a booking using its ID as a parameter |
DELETE | /bookings/:bookingId | Soft-deletes a booking using its ID as a parameter |
- Host: https://ontrip.herokuapp.com/
- Authorization: Bearer Token
- Content-type: application/json
Request headers
{
"authorization": "Bearer Token"
}
Request body example
{
"checkIn": "2023/01/12",
"checkout": "2023/05/12",
"accommodationId": "402c85e9-46d9-4471-8e33-46954319261a",
"userId": "17851b8b-a8ea-48ad-98bb-0f2fc86a8459"
}
Status 201 - Created
{
"message": "Booking created with success",
"booking": {
"id": "f4939be7-3790-4f67-97d0-f2c17739d807",
"checkIn": "2023/01/12",
"checkout": "2023/05/12",
"accommodationId": "402c85e9-46d9-4471-8e33-46954319261a",
"status": "booked",
"userId": "17851b8b-a8ea-48ad-98bb-0f2fc86a8459"
}
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 400 - Missing required field
{
"status": "Error",
"code": 400,
"message": "(any object key) is a required field"
}
Status 400 - Invalid data type or length
{
"status": "Error",
"code": 400,
"message": "yup error message"
}
Status 400 - Unavailable booking dates
{
"status": "Error",
"code": 400,
"message": "These dates are unavailable"
}
Status 409 - Booking already registered
{
"status": "Error",
"code": 409,
"message": "This booking is already registered"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Bearer Token
- User must be an admin
- Content-type: application/json
- Empty body
Request headers
{
"authorization": "Bearer Token"
}
Status 200 - OK
{
"message": "Successful request",
"bookings": [
{
"id": "f4939be7-3790-4f67-97d0-f2c17739d807",
"checkIn": "2023/01/12",
"checkout": "2023/05/12",
"accommodationId": "402c85e9-46d9-4471-8e33-46954319261a",
"status": "booked",
"userId": "17851b8b-a8ea-48ad-98bb-0f2fc86a8459"
},
...
]
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin
{
"status": "Error",
"code": 401,
"message": "User is not an admin"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Bearer Token
- User must be the owner of the accommodation, the guest that booked the booking, or an admin
- Content-type: application/json
- Empty body
Request headers
{
"authorization": "Bearer Token"
}
Status 200 - OK
{
"message": "Successful request",
"booking": {
"id": "f4939be7-3790-4f67-97d0-f2c17739d807",
"checkIn": "2023/01/12",
"checkout": "2023/05/12",
"accommodationId": "402c85e9-46d9-4471-8e33-46954319261a",
"status": "booked",
"userId": "17851b8b-a8ea-48ad-98bb-0f2fc86a8459"
}
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not the owner of the accommodation, the guest that booked the booking, or an admin
{
"status": "Error",
"code": 401,
"message": "User must be the owner of the accommodation, the guest that booked the booking, or an admin"
}
Status 404 - Booking not found
{
"status": "Error",
"code": 404,
"message": "Booking not found"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Bearer Token
- User must be the owner of the accommodation, the guest that booked the booking, or an admin
- Content-type: application/json
- Empty body
Request headers
{
"authorization": "Bearer Token"
}
Status 200 - OK
{
"message": "Booking deleted with success"
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not the owner of the accommodation, the guest that booked the booking, or an admin
{
"status": "Error",
"code": 401,
"message": "User must be the owner of the accommodation, the guest that booked the booking, or an admin"
}
Status 400 - Booking already deleted
{
"status": "Error",
"code": 400,
"message": "Booking already deleted"
}
Status 404 - Booking not found
{
"status": "Error",
"code": 404,
"message": "Booking not found"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
The Address object is defined as:
Field | Type | Description |
---|---|---|
country | string | Defines the country of the address |
state | string | Defines the state of the address |
city | string | Defines the city of the address |
postalCode | string | Defines the postal Code of the address |
street | string | Defines the street of the address |
complement | string | Defines the complement of the address |
accommodationId | string | Accommodation's unique identifier of this address |
Method | Route | Description |
---|---|---|
POST | /addresses | Creates a new address |
PATCH | /addresses/:addressId | Updates an address using its ID as a parameter |
- Host: https://ontrip.herokuapp.com/
- Authorization: Bearer Token
- User must be the owner of the accommodation of the new address or an admin
- Content-type: application/json
Request headers
{
"authorization": "Bearer Token"
}
Request body example
{
"country": "Brazil",
"state": "Espirito Santo",
"city": "Serra",
"postalCode": "29163663",
"street": "Rosemberg",
"complement": "Quadra 45, Setor Ásia",
"accommodationId": "661dc120-4851-47ec-8a76-216e8380345e"
}
Status 201 - Created
{
"message": "Address created with success",
"address": {
"id": "4a944707-6c5e-4ea9-a2c8-882196d3904f",
"country": "Brazil",
"state": "Espirito Santo",
"city": "Serra",
"postalCode": "29163663",
"street": "Rosemberg",
"complement": "Quadra 45, Setor Ásia",
"accommodationId": "661dc120-4851-47ec-8a76-216e8380345e"
}
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not the owner of the accommodation set at this address or an admin
{
"status": "Error",
"code": 401,
"message": "User must be the owner of the accommodation set at this address or an admin"
}
Status 400 - Missing required field
{
"status": "Error",
"code": 400,
"message": "(any object key) is a required field"
}
Status 400 - Invalid data type or length
{
"status": "Error",
"code": 400,
"message": "yup error message"
}
Status 404 - Accommodation not found
{
"status": "Error",
"code": 404,
"message": "Accommodation not found"
}
Status 409 - Address already registered in this accommodation
{
"status": "Error",
"code": 409,
"message": "Address already registered in this accommodation"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Bearer Token
- User must be the owner of the accommodation set at this address or an admin
- Content-type: application/json
Request headers
{
"authorization": "Bearer Token"
}
Request body example
{
"postalCode?": "29163663",
"street?": "Rosemberg",
"complement?": "Quadra 45, Setor Ásia",
"accommodationId": "661dc120-4851-47ec-8a76-216e8380345e"
}
- accommodationId is a required field
- At least one of these fields is required:
- postalCode
- street
- complement
Status 200 - OK
{
"message": "Address updated with success",
"address": {
"id": "4a944707-6c5e-4ea9-a2c8-882196d3904f",
"country": "Brazil",
"state": "Espirito Santo",
"city": "Serra",
"postalCode": "29163663",
"street": "Rosemberg",
"complement": "Quadra 45, Setor Ásia",
"accommodationId": "661dc120-4851-47ec-8a76-216e8380345e"
}
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not the owner of the accommodation set at this address or an admin
{
"status": "Error",
"code": 401,
"message": "User must be the owner of the accommodation set at this address or an admin"
}
Status 400 - Invalid data type or length
{
"status": "Error",
"code": 400,
"message": "yup error message"
}
Status 400 - No changes in address data
{
"status": "Error",
"code": 400,
"message": "Not possible to update an address without having any changes in any field"
}
Status 404 - Address not found
{
"status": "Error",
"code": 404,
"message": "Address not found"
}
Status 404 - Accommodation not found
{
"status": "Error",
"code": 404,
"message": "Accommodation not found"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
The Category object is defined as:
Field | Type | Description |
---|---|---|
id | string | Category's unique identifier |
name | string | Category name |
isActive | boolean | Defines whether a category is active or not |
Method | Route | Description |
---|---|---|
POST | /categories | Creates a category |
GET | /categories | List all categories |
GET | /categories/:categoryId | Lists a category using its ID as a parameter |
PATCH | /categories/:categoryId | Updates a category using its ID as a parameter |
DELETE | /categories/:categoryId | Soft-deletes a category using its ID as a parameter |
- Host: https://ontrip.herokuapp.com/
- Authorization: Admin Bearer Token
- User must be an admin to create a category
- Content-type: application/json
Request headers
{
"authorization": "Bearer Token"
}
Request body example
{
"name": "Apartment"
}
Status 201 - Created
{
"message": "Category created with success",
"category": {
"id": "fc540668-a80c-4690-8889-1c89c5a51b5c",
"name": "Apartment",
"isActive": true
}
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin
{
"status": "Error",
"code": 401,
"message": "User is not an admin"
}
Status 400 - Missing required field
{
"status": "Error",
"code": 400,
"message": "(any object key) is a required field"
}
Status 400 - Invalid data type or length
{
"status": "Error",
"code": 400,
"message": "yup error message"
}
Status 409 - This category already exists
{
"status": "Error",
"code": 409,
"message": "This category already exists"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: None
- Content-type: application/json
- Empty body
Status 200 - OK
{
"message": "Successful request",
"categories":
[
{
"id": "fc540668-a80c-4690-8889-1c89c5a51b5c",
"name": "Apartment",
"isActive": true
},
...
]
}
- No errors expected
- Host: https://ontrip.herokuapp.com/
- Authorization: None
- Content-type: application/json
- Empty body
Status 200 - OK
{
"message": "Successful request",
"category": {
"id": "fc540668-a80c-4690-8889-1c89c5a51b5c",
"name": "Apartment",
"isActive": true
}
}
Status - 404 - Category not found
{
"status": "Error",
"code": 404,
"message": "Category not found"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Admin Bearer Token
- User must be an admin to update a category
- Content-type: application/json
Request headers
{
"authorization": "Bearer Token"
}
Request body example
{
"name": "Studio"
}
Status 200 - OK
{
"message": "Category updated with success",
"category": {
"id": "fc540668-a80c-4690-8889-1c89c5a51b5c",
"name": "Studio",
"isActive": true
}
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin
{
"status": "Error",
"code": 401,
"message": "User is not an admin"
}
Status 400 - Invalid data type or length
{
"status": "Error",
"code": 400,
"message": "yup error message"
}
Status 404 - Category not found
{
"status": "Error",
"code": 404,
"message": "Category not found"
}
Status 400 - No changes in category data
{
"status": "Error",
"code": 400,
"message": "Not possible to update a category without having any changes in any field"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Admin Bearer Token
- User must be an admin to delete a category
- Content-type: application/json
- Empty body
Request headers
{
"authorization": "Bearer Token"
}
Status 200 - OK
{
"message": "Category deleted with success"
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin
{
"status": "Error",
"code": 401,
"message": "User is not an admin"
}
Status 404 - Category not found
{
"status": "Error",
"code": 404,
"message": "Category not found"
}
Status 400 - Category already deleted
{
"status": "Error",
"code": 400,
"message": "Category already deleted"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
The Capacity object is defined as:
Field | Type | Description |
---|---|---|
id | string | Capacity's unique identifier |
rooms | number | Number of capacity rooms |
beds | number | Number of capacity beds |
totalGuests | number | Total number of guests that the capacity hosts |
bathrooms | number | Number of capacity bathrooms |
isActive | boolean | Defines whether a capacity is active or not |
Method | Route | Description |
---|---|---|
POST | /capacities | Creates a capacity |
GET | /capacities | List all capacities |
GET | /capacities/:capacityId | Lists a capacity using its ID as a parameter |
PATCH | /capacities/:capacityId | Updates a capacity using its ID as a parameter |
DELETE | /capacities/:capacityId | Soft-deletes a capacity using its ID as a parameter |
- Host: https://ontrip.herokuapp.com/
- Authorization: Admin Bearer Token
- User must be an admin to create a capacity
- Content-type: application/json
Request headers
{
"authorization": "Bearer Token"
}
Request body example
{
"rooms": 2,
"beds": 2,
"totalGuests": 4,
"bathrooms": 2
}
Status 201 - Created
{
"message": "Capacity created with success",
"capacity": {
"id": "3aa9018f-1415-4caf-a382-07aff5e0076a",
"rooms": 2,
"beds": 2,
"totalGuests": 4,
"bathrooms": 2,
"isActive": true
}
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin
{
"status": "Error",
"code": 401,
"message": "User is not an admin"
}
Status 400 - Missing required field
{
"status": "Error",
"code": 400,
"message": "(any object key) is a required field"
}
Status 400 - Invalid data type or length
{
"status": "Error",
"code": 400,
"message": "yup error message"
}
Status 409 - This capacity already exists
{
"status": "Error",
"code": 409,
"message": "This capacity already exists"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: None
- Content-type: application/json
- Empty body
Status 200 - OK
{
"message": "Successful request",
"capacities":
[
{
"id": "3aa9018f-1415-4caf-a382-07aff5e0076a",
"rooms": 2,
"beds": 2,
"totalGuests": 4,
"bathrooms": 2,
"isActive": true
},
...
]
}
- No errors expected
- Host: https://ontrip.herokuapp.com/
- Authorization: None
- Content-type: application/json
- Empty body
Status 200 - OK
{
"message": "Successful request",
"capacity": {
"id": "3aa9018f-1415-4caf-a382-07aff5e0076a",
"rooms": 2,
"beds": 2,
"totalGuests": 4,
"bathrooms": 2,
"isActive": true
}
}
Status 404 - Capacity not found
{
"status": "Error",
"code": 404,
"message": "Capacity not found"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Admin Bearer Token
- User must be an admin to update a capacity
- Content-type: application/json
Request headers
{
"authorization": "Bearer Token"
}
Request body example
{
"rooms?": 1,
"beds?": 1,
"totalGuests?": 2,
"bathrooms?": 1
}
- At least one field is required
Status 200 - OK
{
"message": "Capacity updated with success",
"capacity": {
"id": "3aa9018f-1415-4caf-a382-07aff5e0076a",
"rooms": 1,
"beds": 1,
"totalGuests": 2,
"bathrooms": 1,
"isActive": true
}
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin
{
"status": "Error",
"code": 401,
"message": "User is not an admin"
}
Status 400 - Invalid data type or length
{
"status": "Error",
"code": 400,
"message": "yup error message"
}
Status 404 - Capacity not found
{
"status": "Error",
"code": 404,
"message": "Capacity not found"
}
Status 400 - No changes in capacity data
{
"status": "Error",
"code": 400,
"message": "Not possible to update a capacity without having any changes in any field"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Admin Bearer Token
- User must be an admin to delete a capacity
- Content-type: application/json
- Empty body
Request headers
{
"authorization": "Bearer Token"
}
Status 200 - OK
{
"message": "Capacity deleted with success"
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin
{
"status": "Error",
"code": 401,
"message": "User is not an admin"
}
Status 404 - Capacity not found
{
"status": "Error",
"code": 404,
"message": "Capacity not found"
}
Status 400 - Capacity already deleted
{
"status": "Error",
"code": 400,
"message": "Capacity already deleted"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
The Type object is defined as:
Field | Type | Description |
---|---|---|
id | string | Type's unique identifier |
name | string | Type name |
isActive | boolean | Defines whether a type is active or not |
Method | Route | Description |
---|---|---|
POST | /types | Creates a type |
GET | /types | List all types |
GET | /types/:typeId | Lists a type using its ID as a parameter |
PATCH | /types/:typeId | Updates a type using its ID as a parameter |
DELETE | /types/:typeId | Soft-deletes a type using its ID as a parameter |
- Host: https://ontrip.herokuapp.com/
- Authorization: Admin Bearer Token
- User must be an admin to create a type
- Content-type: application/json
Request headers
{
"authorization": "Bearer Token"
}
Request body example
{
"name": "A whole place"
}
Status 201 - Created
{
"message": "Type created with success",
"type": {
"id": "d57d66cf-3feb-4849-9a86-b8b5654a74af",
"name": "A whole place",
"isActive": true
}
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin
{
"status": "Error",
"code": 401,
"message": "User is not an admin"
}
Status 400 - Missing required field
{
"status": "Error",
"code": 400,
"message": "(any object key) is a required field"
}
Status 400 - Invalid data type or length
{
"status": "Error",
"code": 400,
"message": "yup error message"
}
Status 409 - This type already exists
{
"status": "Error",
"code": 409,
"message": "This type already exists"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: None
- Content-type: application/json
- Empty body
Status 200 - OK
{
"message": "Successful request",
"types":
[
{
"id": "d57d66cf-3feb-4849-9a86-b8b5654a74af",
"name": "A whole place",
"isActive": true
},
...
]
}
- No errors expected
- Host: https://ontrip.herokuapp.com/
- Authorization: None
- Content-type: application/json
- Empty body
Status 200 - OK
{
"message": "Successful request",
"type": {
"id": "d57d66cf-3feb-4849-9a86-b8b5654a74af",
"name": "A whole place",
"isActive": true
}
}
Status 404 - Type not found
{
"status": "Error",
"code": 404,
"message": "Type not found"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Admin Bearer Token
- User must be an admin to update a type
- Content-type: application/json
Request headers
{
"authorization": "Bearer Token"
}
Request body example
{
"name": "A shared place"
}
Status 200 - OK
{
"message": "Type updated with success",
"type": {
"id": "d57d66cf-3feb-4849-9a86-b8b5654a74af",
"name": "A shared place",
"isActive": true
}
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin
{
"status": "Error",
"code": 401,
"message": "User is not an admin"
}
Status 400 - Invalid data type or length
{
"status": "Error",
"code": 400,
"message": "yup error message"
}
Status 404 - Type not found
{
"status": "Error",
"code": 404,
"message": "Type not found"
}
Status 400 - No changes in type data
{
"status": "Error",
"code": 400,
"message": "Not possible to update a type without having any changes in any field"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Admin Bearer Token
- User must be an admin to delete a type
- Content-type: application/json
- Empty body
Request headers
{
"authorization": "Bearer Token"
}
Status 200 - OK
{
"message": "Type deleted with success"
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin
{
"status": "Error",
"code": 401,
"message": "User is not an admin"
}
Status 404 - Type not found
{
"status": "Error",
"code": 404,
"message": "Type not found"
}
Status 400 - Type already deleted
{
"status": "Error",
"code": 400,
"message": "Type already deleted"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
The Photo object is defined as:
Field | Type | Description |
---|---|---|
id | string | Photo's unique identifier |
file | file | Photo file sent in the request |
accommodationId | string | Accommodation's unique identifier |
content | string | Photo url generated by cloudinary |
Method | Route | Description |
---|---|---|
POST | /photos/:accommodationId | Creates a new photo of an accommodation using the accommodation ID as a parameter |
GET | /photos/:accommodationId | Lists all photos of an accommodation using the accommodation ID as a parameter |
GET | /photos/:photoId | Lists a photo of an accommodation using the accommodation ID and photo ID as parameters |
DELETE | /photos/:photoId | Soft-deletes a photo of an accommodation using the accommodation ID and photo ID as parameters |
- Host: https://ontrip.herokuapp.com/
- Authorization: Bearer Token
- User must be the owner of this photo's accommodation or an admin
- Content-type: multipart/form-data
Request headers
{
"authorization": "Bearer Token"
}
Request body example
file: file.jpg
Status 201 - Created
{
"message": "Photo created with success",
"photo": {
"id": "cfa647b0-5100-4633-ada4-ad17b7f58626",
"content": "https://res.cloudinary.com/de8wdumps/image/upload/v1662750917/zdlf9ppnkqfjlbxejo8f.jpg",
"accommodationId": "3ef51e41-efe6-4f0e-908f-190301ff645a"
}
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin or the owner of the accommodation
{
"status": "Error",
"code": 401,
"message": "User must be an admin or the owner of the accommodation"
}
Status 400 - Missing photo file
{
"status": "Error",
"code": 400,
"message": "file is a required field"
}
Status 400 - Invalid file type
{
"status": "Error",
"code": 400,
"message": "file has an invalid type"
}
Status 404 - Accommodation not found
{
"status": "Error",
"code": 404,
"message": "Accommodation not found"
}
Status 409 - Photo already registered in this accommodation
{
"status": "Error",
"code": 409,
"message": "Photo already registered in this accommodation"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: None
- Content-type: application/json
- Empty Body
Status 200 - OK
{
"message": "Successful request",
"photos": [
{
"id": "cfa647b0-5100-4633-ada4-ad17b7f58626",
"content": "https://res.cloudinary.com/de8wdumps/image/upload/v1662750917/zdlf9ppnkqfjlbxejo8f.jpg",
"accommodationId": "3ef51e41-efe6-4f0e-908f-190301ff645a"
},
...
]
}
Status 404 - Accommodation not found
{
"status": "Error",
"code": 404,
"message": "Accommodation not found"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: None
- Content-type: application/json
- Empty Body
Status 200 - OK
{
"message": "Successful request",
"photo": {
"id": "cfa647b0-5100-4633-ada4-ad17b7f58626",
"content": "https://res.cloudinary.com/de8wdumps/image/upload/v1662750917/zdlf9ppnkqfjlbxejo8f.jpg",
"accommodationId": "3ef51e41-efe6-4f0e-908f-190301ff645a"
}
}
Status 404 - Accommodation not found
{
"status": "Error",
"code": 404,
"message": "Accommodation not found"
}
Status 404 - Photo not found
{
"status": "Error",
"code": 404,
"message": "Photo not found"
}
- Host: https://ontrip.herokuapp.com/
- Authorization: Bearer Token
- User must be the owner of this photo's accommodation or an admin
- Content-type: application/json
- Empty Body
Request headers
{
"authorization": "Bearer Token"
}
Status 200 - OK
{
"message": "Photo deleted with success"
}
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token"
}
Status 401 - User is not an admin or the owner of the accommodation
{
"status": "Error",
"code": 401,
"message": "User must be an admin or the owner of the accommodation"
}
Status 404 - Accommodation not found
{
"status": "Error",
"code": 404,
"message": "Accommodation not found"
}
Status 404 - Photo not found
{
"status": "Error",
"code": 404,
"message": "Photo not found"
}
Status 400 - Photo already deleted
{
"status": "Error",
"code": 400,
"message": "Photo already deleted"
}
Status 400 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deactivated, please contact our customer services for more information"
}