pratik-app / trip-builder

This is RESTfull API using PHP. As a task of assessment I need to create an API that will get flight details. API covers all type of request such as GET, POST, PATCH and DELETE

Home Page:https://trip-builder-view.pratikmore.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trip-Builder

This is a collection of API's to manage flights and airlines information in the Trip-Builder application. NOTE: This is Assesment

Getting Started

This API is built using the localhost server. The API endpoints can be accessed by sending HTTP requests using a tool like Postman or a similar tool.

Prerequisites

To be able to use this API, you will need the following installed on your system:

  • A tool to send HTTP requests such as POSTMAN.
  • A local server like XAMPP.

Installation

  1. Clone or download the repository to your local machine.
  2. Import the sql file attached in this repository to phpmyadmin.
  3. Store the project in htdocs, inside a folder like Trip-Builder.
  4. Now send request using POSTMAN with the help of API Endpints.

Live Application Requests

  • https://trip-builder.pratikmore.com/

  • Please send request using postman or view this website with EndPoints for example:

      This will fetch all trips details
    
      - https://trip-builder.pratikmore.com/trips/ 
    
      This will fetch One Way Trip Details 
    
      - https://trip-builder.pratikmore.com/onewaytrip/
    
      NOTE: Data must be passed with the request
      NOTE: Data must be passed with the Details For Example using postman pass data using Body data must be 
      Key =  "source"  | Value "YUL" 
      Key = "destination" | Value "YVR" 
      
      This will fetch Round Trip Details
    
      - https://trip-builder.pratikmore.com/roundtrip
    
      NOTE: Data must be passed with the Details For Example using postman pass data using Body data must be 
      Key =  "departure_airport"  | Value "YUL" 
      Key = "arrival_airport" | Value "YVR" 
      Key = "departure_date"| Value "2023-04-04 07:35" 
      key = "return_date" | Value "2023-04-05 12:35"
    

Live Application

Updated CORS Policy 03-04-2023

  • After creating frontend, I faced problem of CORS.
  • So now CORS is Allowed for this domain. However, the CORS is updated via FileZilla as the changes was in .htaccess.

Connection

  • This Application is built on live server.
    • Application first Created and Connected with GitHub.
    • Then a Sub Domain is created to access the site.
    • Git is linked via Server so every commit will be live.
    • Using Webhook at server side and in GIT repo, to Auto-Deploy the application.
  • This way it is easier for adding any team member to the project and work with them.

API ENDPOINTS

ONE-WAY-FLIGHTS

  • POST/onewaytrip - Get details as mentioned in the task. NOTE: use POST request insted of GET.Example will be shown in Request Examples.

Flights

  • GET/trips/ - get all the flights.
  • POST/trips - add new flight details to the flight table. NOTE: If using POSTMAN send a form data in JSON format Example will be shown in Request Examples. KEY: flightNumber,airlineCode, departureAirportCode, departureTime, arrivalAirportCode, arrivalTime, price.
  • GET/trips/{flightNumber} - Get flight details from the flight number. NOTE: The flight Number must be in INT format you can try /trips/301.
  • PATCH/trips/{flightNumber} - Update flight details NOTE: If using POSTMAN send a raw data in JSON format Example will be shown in Request Examples.
  • DELETE/trips/{flightNumber} - DELETE any flight details.

Airline

  • GET/airlines/ - Get all Airline Details.
  • GET/airlines/{iataAirlineCode} - GET Specific Airline Detail. NOTE: AirlineCode is String For example, AC stands for Air Canada
  • POST/airlines - ADD new Airline Detail. NOTE: Data must be pass via form-data KEY: iataAirlineCOde, name, description.
  • PATCH/airlines/{iataAirlineCode} - Update existing record. NOTE: If using POSTMAN send a raw data in JSON format Example will be shown in Request Examples.
  • DELETE/airlines/{iataAirlineCode} - DELETE any Airline Details.

Airport

  • GET/airports/ - Get all Airline Details.
  • GET/airports/{iataAirportCode} - GET Specific Airline Detail. NOTE: AirlineCode is String For example, AC stands for Air Canada
  • POST/airlines - ADD new Airline Detail. NOTE: Data must be pass via form-data KEY: iataAirlineCOde, name, description.
  • PATCH/airlines/{iataAirportCode} - Update existing record. NOTE: If using POSTMAN send a raw data in JSON format Example will be shown in Request Examples.
  • DELETE/airlines/{iataAirportCode} - DELETE any Airline Details.

REQUEST SAMPLES

  • POST Request

One Way Trip Request

alt text

  • GET Request

alt text

  • POST Request

alt text

  • PATCH Request

alt text

  • DELETE Request

alt text

About

This is RESTfull API using PHP. As a task of assessment I need to create an API that will get flight details. API covers all type of request such as GET, POST, PATCH and DELETE

https://trip-builder-view.pratikmore.com/

License:Apache License 2.0


Languages

Language:PHP 100.0%