Kids Fly BE
- Root URL
https://kids-fly-be.herokuapp.com/api
- Tokens will be needed for authenticated routes.
- Routes will decode the token and grab information needed for user specific actions.
- URL
/auth
Test your token, and role with this route.
To register, send a post request with a body object as followed:
{
"id": 1,
"email": "[email protected]", // required field (string)
"password": "password", // required field (string)
"name": null, // (string)
"street": null, // (string)
"city": null, // (string)
"state": null, // (string)
"zip": null, // (int)
"airport": null, // (string)
"phone": null, (int)
"role": "traveler" // This will default to 'traveler', if user is an 'admin', specify in role property. (string)
}
Upon successful creation of user, the API will return an object as followed:
{
"message": "[email protected] was registered and logged in.",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRpbW90aHkxIiwiaWF0IjoxNTgwNjY5Mzg1LCJleHAiOjE1ODA3NTU3ODV9.gTutCRxg3eHfvUl3lEEugJk5mNPvg6UEVCDeQoh6TAQ"
}
To log a user in, send a post request with a body object as followed:
{
email: "[email protected], // (string)
password: "password", // (string)
}
Upon successful login, the API will return an object as followed:
{
"message": "[email protected] was logged in successfully.",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRpbW90aHkxIiwiaWF0IjoxNTgwNjY5ODAwLCJleHAiOjE1ODA3NTYyMDB9.0d6amBRv2VaYiNhO8dPWuUzRJzDQdCw_fQK6FTqjYkQ"
}
To delete user, send a DELETE request to /:email, I.E. /api/auth/[email protected]
To edit a user, send a PUT request to /:email, I.E. /api/auth/[email protected]
{
"email": "[email protected]", // required field (string)
"password": "password", // required field (string)
"name": null, // (string)
"street": null, // (string)
"city": null, // (string)
"state": null, // (string)
"zip": null, // (int)
"airport": null, // (string)
"phone": null, (int)
"role": "traveler" // 'admin' or 'traveler' (string)
}
Upon successful user edit, the response will look like this:
{
"email": "[email protected]",
"name": "Tim",
"street": "Jefferson Ave.",
"city": null,
"state": null,
"zip": null,
"airport": null,
"phone": null,
"role": "traveler",
"rating": null
}
- URL -
/connection
To register, send a post request with a body object as followed:
{
"email": "[email protected]", // required field (string)
"password": "password", // required field (string)
"name": null // (string)
}
Upon successful creation of connection, the API will return an object as followed:
{
"message": "[email protected] was registered and logged in as a KidsFlyConnection.",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRpbUB0aW0uY29tIiwiaWF0IjoxNTgwNzUzMTM1LCJleHAiOjE1ODA4Mzk1MzV9.tnUsmd4UzZcHjjTjrYN8uVz7UeM3lNVfH_njFJpwzZ4"
}
To log a connection in, send a post request with a body object as followed:
{
email: "[email protected], // (string)
password: "password", // (string)
}
Upon successful login, the API will return an object as followed:
{
"message": "[email protected] was logged in successfully as a KidsFlyConnection.",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRpbUB0aW0uY29tIiwiaWF0IjoxNTgwNzUzMjE2LCJleHAiOjE1ODA4Mzk2MTZ9.IdU4X_NGqDshmGu_7uSOKjVPzcmFQvIX6xkPP8yZev0"
}
To delete a connection, send a DELETE request to /:email, I.E. /api/connection/[email protected]
To edit a connection, send a PUT request to /:email, I.E. /api/connection/[email protected]
- URL
/flights
Get all flights.
{
"airline": "Southwest", // required (string)
"airport": "MCD", // required (string)
"flight_number": "F33", // required (string)
"flight_date": "2020-03-22", // required (date)
"flight_time": "06:00" // required (time)
}
{
"airline": "Southwest",
"airport": "MCD",
"flight_number": "F33",
"flight_date": "2020-03-22",
"flight_time": "06:00"
}
To delete a flight, send a DELETE api call to the delete url i.e. /api/flights/F33
To edit a flight, send a PUT api call to the url with an update object i.e. /api/flights/F33
{
"airline": "Delta",
"airport": "MCD",
"flight_number": "F34",
"flight_date": "2020-03-22",
"flight_time": "06:00"
}
- URL
/user_flights
To get all flights for a user, send a GET request to /api/user_flights/
To add a user to a flight, send a POST request to the url i.e. /api/user_flights/F34
with the following body:
{
"carry_ons": "2",
"number_of_children": "2",
"special_needs_req": false
}
To delete a flight from a user, send a DELETE request to the url with the flight number, i.e. /api/user_flights/F34
- URL
/user_connection
To GET all connections for a KidsFlyConnection account send a GET request with the KidsFlyConnection user email to the endpoint, i.e. /api/user_connection/[email protected]
.
[
{
"userName": null,
"userEmail": "[email protected]",
"airline": "Delta",
"airport": "BDA",
"flight_number": "F31",
"flight_date": "2020-03-22",
"flight_time": "06:00",
"carry_ons": 3,
"number_of_children": 3,
"special_needs_req": 0, // This is a boolean
"completed": 0, // This is a boolean
"connectionName": "tim",
"connectionEmail": "[email protected]"
}
]
To add a KidsFlyConnection send a POST request to the URL with the user_email, connection_email and flight_number, i.e. /api/user_connection/[email protected]/[email protected]/F32
.
{
"completed": true // This is an optional field. There is an endpoint to edit a KidsFlyConnection.
}
Response will return all KidsFlyConnections associated with the KidsFlyConnection account.
[
{
"userName": null,
"userEmail": "[email protected]",
"airline": "Delta",
"airport": "BDA",
"flight_number": "F31",
"flight_date": "2020-03-22",
"flight_time": "06:00",
"carry_ons": 3,
"number_of_children": 3,
"special_needs_req": 0,
"completed": 0,
"connectionName": "tim",
"connectionEmail": "[email protected]"
},
{
"userName": null,
"userEmail": "[email protected]",
"airline": "American",
"airport": "LAX",
"flight_number": "F33",
"flight_date": "2020-03-24",
"flight_time": "08:00",
"carry_ons": 3,
"number_of_children": 3,
"special_needs_req": 0,
"completed": 1,
"connectionName": "tim",
"connectionEmail": "[email protected]"
},
{
"userName": null,
"userEmail": "[email protected]",
"airline": "Southwest",
"airport": "MCD",
"flight_number": "F32",
"flight_date": "2020-03-23",
"flight_time": "07:00",
"carry_ons": 3,
"number_of_children": 3,
"special_needs_req": 0,
"completed": 1,
"connectionName": "tim",
"connectionEmail": "[email protected]"
}
]
To remove a KidsFlyConnection, send a DELETE request to the URL with the flight number and KidsFlyConnection user email, i.e. /api/user_connection/F31/[email protected]
.
{
"message": "Flight F31 was removed as a KidsFlyConnection for user [email protected]"
}
To edit a KidsFlyConnection, send a PUT request to the URL with the flight number and the KidsFlyConnection user email, i.e. /api/user_connection/F32/[email protected]
.
{
completed: true; // While this is not a required property, something is required in the request body.
}
Response will be all KidsFlyConnections associated with KidsFlyConnection user account.
[
{
"userName": null,
"userEmail": "[email protected]",
"airline": "Southwest",
"airport": "MCD",
"flight_number": "F32",
"flight_date": "2020-03-23",
"flight_time": "07:00",
"carry_ons": 3,
"number_of_children": 3,
"special_needs_req": 1,
"completed": 1,
"connectionName": "tom",
"connectionEmail": "[email protected]"
}
]