Skip to content

mazlumDemirel/cloudbees

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloudbees Train Booking API

CloudBees Booking Application to manage bookings for travels by train.

There are 4 main APIs to manage the processes;

  1. Creating a booking: Purchases a ticket for a passenger using the details below;
  • From

  • To

  • User

    • Name
    • Surname
    • Email Address
  • Price paid.

    Note: After a succesffull booking a seat from an A or B section will be allocated for the passenger.

POST /tickets 
curl -X 'POST' 'http://localhost:8080/tickets' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{
  "name": "Mazlum",
  "surname": "Demirel",
  "email": "[email protected]",
  "section": "A",
  "number": 1,
  "location": "UPPER_BED",
  "departure": "France",
  "destination": "London"
}'
SAMPLE SUCCESS RESPONSE

{
"id": 1,
"name": "Mazlum",
"surname": "Demirel",
"email": "[email protected]",
"section": "A",
"number": 1,
"location": "UPPER_BED",
"departure": "France",
"destination": "London",
"pricePaid": 20
}
SAMPLE ERROR RESPONSE

{
  "messages": [
    "SEAT not found"
  ]
}
  1. Get Receipt: Retrieves the details of the paxDetail for the passenger.
GET /tickets/{ticketId} 
curl -X 'GET' \
'http://localhost:8080/tickets/1' \
-H 'accept: application/json'
SAMPLE TICKET RESPONSE

{
  "id": 1,
  "name": "Mazlum",
  "surname": "Demirel",
  "email": "[email protected]",
  "section": "A",
  "number": 1,
  "location": "UPPER_BED",
  "departure": "France",
  "destination": "London",
  "pricePaid": 20
}
SAMPLE NOT FOUND RESPONSE
{
  "messages": [
    "TICKET not found"
  ]
}
  1. Filter passenger/seat info bysection: Retrieves the passenger info depending on the section.
GET /tickets?section=[A,B] 
curl -X 'GET' 'http://localhost:8080/tickets?section=A' -H 'accept: application/json'
SAMPLE RESPONSE

{
"section": "A",
"paxes": [
{
"id": 1,
"name": "Mazlum",
"surname": "Demirel",
"email": "[email protected]",
"section": "A",
"number": 1,
"location": "UPPER_BED",
"departure": "France",
"destination": "London",
"pricePaid": 20
}
]
}
  1. Cancel the Purchase: Removes a passenger from the train.
DELETE /tickets/{ticketId} 
curl -X 'DELETE' 'http://localhost:8080/tickets/10' -H 'accept: */*'
  1. Modify Ticket: Changes passenger's seat.
PUT /tickets/{ticketId} 
curl -X 'PUT' 'http://localhost:8080/tickets/1' -H 'accept: */*' -H 'Content-Type: application/json' -d '{
  "number": 2,
  "section": "A",
  "location": "LOWER_BED"
}'
SAMPLE ERROR RESPONSE

{
  "messages": [
    "SEAT not found"
  ]
}

NOTE: To access the swagger UI you can click below link after running the application.

http://localhost:8080/swagger.html

Instructions

Building and launching tests

Developed with JAVA 22, no extra requirements are needed for build and launch the application.

Building and launching tests:

./gradlew build

You can see the Jacoco coverage report at /build/reports/jacoco/test/html/index.html

Running
./gradlew bootRun

Alternatively, your can run this project with docker, since the Dockerfile contains a multi-stage build, no build in the host machine is needed before:

docker build --tag=cloudbees/booking:latest . 
docker run -p8080:8080 cloudbees/booking

About

CloudBees Booking App

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published