Skip to content

aviaialon/FlightHubTripBuilderApi

Repository files navigation

Synopsis

A simple RESTFul API built with Laravel to manage trips

RESTful URLs

List all airports (Ordered alphabetically by city and name):

GET /airports/list
Example: curl -i -X GET '<REST SERVICE IP>:8080/airports/list?pretty'


List all available trips

GET /trips/list
Example: curl -i -X GET '<REST SERVICE IP>:8080/trips/list?pretty'


List all flights associated to a trip:

GET /trips/{trip_id}/flights

Param Name Description
trip_id The trip's id.
Example: curl -i -X GET '<REST SERVICE IP>:8080/trips/1/flights?pretty'

Create a new trip

POST /trips?name={name}

Param Name Description
name (Optional) The new trips name.
Example: curl -i -X POST '<REST SERVICE IP>:8080/trips?pretty' -d 'name=Im making a trip!'

Rename a trip

PUT /trips/{trip_id}/?name={name}

Param Name Description
trip_id The trip's id.
name The trip's new name.
Example: curl -i -X PUT '<REST SERVICE IP>:8080/trips/1?pretty' -d 'name=My Cool New Name'

Delete a flight for a trip

DELETE /trips/{trip_id}/flight/{flight_id}

Param Name Description
trip_id The trip id.
flight_id The flight id associate to the trip.
Example: curl -i -X DELETE '<REST SERVICE IP>:8080/trips/1/flights/1?pretty'

Add a flight to a trip

POST /trips/{trip_id}/flights/{origin_id}/{destination_id}

Param Name Description
trip_id The trip's id.
origin_id The origin airport id.
destination_id The destination airport id.
Example: curl -i -X POST '<REST SERVICE IP>:8080/trips/1/flights/6/5?pretty'

Delete a trip (and associated flights)

DELETE /trips/{trip_id}

Param Name Description
trip_id The trip's id.
Example: curl -i -X DELETE '<REST SERVICE IP>:8080/trips/1?pretty'

Installation

From your terminal, execute the following commands:

  1. git clone https://github.com/aviaialon/FlightHubTripBuilderApi.git
  2. cd FlightHubTripBuilderApi
  3. composer install
  4. edit /app/config/database.php to add the database connection info.
  5. php artisan migrate
  6. php artisan db:seed
  7. php artisan serve --port 8080

The service should then be running and ready for use.

Still to do

TESTS!!! - These should have been done BEFORE writing a single line of code, but because of lack of time.. (not making excuses.. just sayin..)

About

Simple trip builder API built with Laravel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published