GithubHelp home page GithubHelp logo

airlineticketing's Introduction

Airline Ticketer

Build Status License

Requirements

For building and running the application you need:

Running the application locally

There are several ways to run a Spring Boot application on your local machine. One way is to execute the main method in the com.airline.ticketing.ticketer.TicketerApplication class from your IDE.

Alternatively you can use the Spring Boot Maven plugin like so:

mvn spring-boot:run

or

from your terminal in root directory simply run :

mvn clean install
java -jar target/ticketer-0.0.1-SNAPSHOT.jar

swagger url:

you can check all endpoints from this address http://localhost:8080/swagger-ui.html#/

Operations :

--adding Airline Company

curl -X POST "http://localhost:8080/company" -H "accept: */*" -H "Content-Type: application/json" -d 
"{
  "desc": "test company desc",
  "name": "test company"
}"

--search any entity

it returns pageable response, pageable params available at url, {key} value will be checked for name and desc fields.

entities : company, airport, route, ticket, flight

curl -X GET "http://localhost:8080/{entity}/search/{key}?direction=ASC&pageNo=0&pageSize=10&sortBy=id" -H "accept: */*"

--get an entity

curl -X GET "http://localhost:8080/{entity}/{id}" -H "accept: */*"

--delete an entity

curl -X DELETE "http://localhost:8080/{entity}/{id}" -H "accept: */*"

--update an entity

curl -X PUT "http://localhost:8080/{entity}/{id}" -H "accept: */*" -H "Content-Type: application/json" -d
"{entity json}"

--adding Airport

curl -X POST "http://localhost:8080/airport" -H "accept: */*" -H "Content-Type: application/json" -d 
"{
    "city": "istanbul",
    "desc": "test airport desc",
    "name": "test airport"
}"

--adding route

curl -X POST "http://localhost:8080/route" -H "accept: */*" -H "Content-Type: application/json" -d "{ \"desc\": \"test route desc\", \"fromAirportId\": 1, \"name\": \"test route\", \"toAirportId\": 2}
"{
   "desc": "test route desc",
   "fromAirportId": 1,
   "name": "test route",
   "toAirportId": 2
 }"

--adding flight to Airport Company

curl -X POST "http://localhost:8080/flight" -H "accept: */*" -H "Content-Type: application/json" -d 
"{
  "basePrice": 10,
  "capacity": 36,
  "companyId": 1,
  "dateStr": "20-02-2020",
  "desc": "test flight desc",
  "name": "test flight",
  "routeId": 2
}"

-search flight

there are already a pageable search endpoint for all of entities, but for flight there is anoher for searching by company

curl -X GET "http://localhost:8080/flight/company/1?direction=ASC&pageNo=0&pageSize=10&sortBy=id" -H "accept: */*"

--ask price for a flight

curl -X GET "http://localhost:8080/flight/1/price" -H "accept: */*"

it returns :

{
  "totalCapacity": 40,
  "currentCapacity": 40,
  "basePrice": 60,
  "currentPrice": 155.62
}

--get tickets for a flight

it again pageable

curl -X GET "http://localhost:8080/ticket/flight/1?direction=ASC&pageNo=0&pageSize=10&sortBy=id" -H "accept: */*"

--buy a ticket

because of there is no specific declaration, i did not ask price for buying ticket, it uses last price(effected by fullness of flight) and this business logic inside a synchronised block, so system guaranties pricing wont broke under simultaneous requests

curl -X POST "http://localhost:8080/ticket" -H "accept: */*" -H "Content-Type: application/json" -d 
"{
   "cardNumber": "1234,1234-1234;12 34",
   "flightId": 1,
   "name": "test ticket",
   "number": "1"
 }"

after this request, card number stores like this : "123412******1234"

--get ticket by ticket number

curl -X GET "http://localhost:8080/ticket/flight/1/number/a1" -H "accept: */*"

--delete ticket by ticket number

curl -X DELETE "http://localhost:8080/ticket/flight/1/number/a1" -H "accept: */*"

*every 10% ticket sold increases the price by 10%

*input card number removes non numeric characters and hides 6 digits

*hateoas for generic response implemented, for entity crud operations

*ci tool added, used https://api.travis-ci.org. You can check last commit's build status

*Spring Test added, just for entity repository, not much more, because not required :)

*swagger support, you can access from "/" path too, not need to ask swagger-ui.html

*i did not added user & authentication, it is not required too

airlineticketing's People

Watchers

James Cloos avatar Mahmut Boğaz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.