Skip to content

DemoCmdTTTM_BackEnd

Vifeng edited this page Sep 20, 2024 · 1 revision

Backend Demo - Table of Contents


Overview

EventHub is a ticketing application intended for professionals in the event sector and the general public.

The main goal of EventHub is to facilitate the management and sale of tickets for events, by providing an interface for venue managers and end users. On one side, professionals can manage events, venues, sessions and prices. On the other side, the general public can view shows, make reservations and buy tickets.

This document take you thru a series of requests to test the application behavior.

Use case

A customer wants to browse the events, select one and choose his seat. That would be the ticket reservation. Then he wants to make a booking and a payment of that booking. The booking is possible if its date is before the session event. The payment is possible if the booking is still valid, indeed a booking has a expiry time which is currently hard coded in PaymentService.java.

Video

A demonstration video of these commands can be found here : https://youtu.be/vzKp5uuW_zM

Create a ticket reservation

Display all events

http://localhost:8080/events

curl 'http://localhost:8080/api/events' -i -X GET \
    -H 'Accept: application/json'

Select an event of id 1

http://localhost:8080/events/1

curl 'http://localhost:8080/api/events/1' -i -X GET \
    -H 'Accept: application/json'

Display all session of this Events

http://localhost:8080/api/events/1/sessionsEvents

curl 'http://localhost:8080/api/events/1/sessionsEvents' -i -X GET \
    -H 'Accept: application/json'

Select the session event

choose the session event of id 1 ("05-01-2026 20:00:00")

http://localhost:8080/api/sessionevents/1

curl 'http://localhost:8080/api/sessionevents/1' -i -X GET \
    -H 'Accept: application/json'

We can see the configuration hall id is 1 in the response.

Display the seats by configuration hall Id 1

http://localhost:8080/api/configurationhalls/1/seats

curl 'http://localhost:8080/api/configurationhalls/1/seats' -i -X GET \
    -H 'Accept: application/json'

Notice the seat of id 4 as a seatStatus "available"

"seatStatus": {
      "id": 2,
      "name": "available"
    },

Create a ticket reservation

Make a reservation for the Seat of id 4 ("4B, orchestre") of the Event of id 1 ("Orange Blossom")

curl 'http://localhost:8080/api/ticketReservations' -i -X POST \
    -H 'Content-Type: application/json' \
    -d '{"ticketReservationKey":{"seatId":{"id":4,"isSeated":true,"seatNo":4,"rowNo":"B","categorySpatial":{"id":1,"name":"orchestre"},"categoryTariff":{"id":1,"name":"categorie 1","tarification":{"id":1,"basePrice":10.0,"taxeRate":0.2,"discountStudentRate":0.5,"discountSeniorRate":0.1,"discountChildRate":0.2,"discountUnemployedRate":0.3,"event":{"id":1,"name":"Orange Blossom","description":"concert rock super bien","dateStart":"05-01-2024","dateEnd":"25-02-2024","closedDay":"Lundi","imageUrl":"img/orangeBlossom.jpeg"}}},"seatStatus":{"id":2,"name":"available"},"configurationHall":{"id":1,"name":"debout","hall":{"id":1,"name":"Hall 1","capacityOfHall":300,"venue":{"id":1,"name":"Le Trianon","address":{"street":"sesame street","city":"Paris","zipcode":"75001","country":"France"},"employees":[{"id":1,"username":"username","password":"Secret1*","email":"email@admin.fr"}]}},"capacityOfConfiguration":120}},"sessionEventId":{"id":1,"dateAndTimeStartSessionEvent":"05-01-2026 20:00:00","durationInMinutes":90,"event":{"id":1,"name":"Orange Blossom","description":"concert rock super bien","dateStart":"05-01-2024","dateEnd":"25-02-2024","closedDay":"Lundi","imageUrl":"img/orangeBlossom.jpeg"},"configurationHall":{"id":1,"name":"debout","hall":{"id":1,"name":"Hall 1","capacityOfHall":300,"venue":{"id":1,"name":"Le Trianon","address":{"street":"sesame street","city":"Paris","zipcode":"75001","country":"France"},"employees":[{"id":1,"username":"username","password":"Secret1*","email":"email@admin.fr"}]}},"capacityOfConfiguration":120}}},"isBooked":false}'

the new location : http://localhost:8080/api/ticketReservations/sessionevent/1/seat/4
Notice the seatStatus changed to "available" because it's not booked yet

"seatStatus": {
            "id": 1,
            "name": "available"
          }

Create a new booking

Display all the bookings

http://localhost:8080/api/bookings

curl 'http://localhost:8080/api/bookings' -i -X GET \
    -H 'Accept: application/json'

Display the booking of id 1

http://localhost:8080/api/bookings/1

Notice the booking of id 1 has already two ticket reservations of:

  • seatId 1 and sessionEventId 1 (of which the seatStatus is sold)
  • seatId 2 and sessionEventId 1 (of which the seatStatus is sold)

Notice its total price of 20 corresponding to the base price of a ticket (10 euros) multiply 2

"totalPriceHt": 20.0,

Create a new booking

curl 'http://localhost:8080/api/bookings/customer/2/reservationKey' -i -X POST \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/json' \
    -d '{"seatId":{"id":4,"isSeated":true,"seatNo":4,"rowNo":"B","categorySpatial":{"id":1,"name":"orchestre"},"categoryTariff":{"id":1,"name":"categorie 1","tarification":{"id":1,"basePrice":10.0,"taxeRate":0.2,"discountStudentRate":0.5,"discountSeniorRate":0.1,"discountChildRate":0.2,"discountUnemployedRate":0.3,"event":{"id":1,"name":"Orange Blossom","description":"concert rock super bien","dateStart":"05-01-2024","dateEnd":"25-02-2024","closedDay":"Lundi","imageUrl":"img/orangeBlossom.jpeg"}}},"seatStatus":{"id":2,"name":"available"},"configurationHall":{"id":1,"name":"debout","hall":{"id":1,"name":"Hall 1","capacityOfHall":300,"venue":{"id":1,"name":"Le Trianon","address":{"street":"sesame street","city":"Paris","zipcode":"75001","country":"France"},"employees":[{"id":1,"username":"username","password":"Secret1*","email":"email@admin.fr"}]}},"capacityOfConfiguration":120}},"sessionEventId":{"id":1,"dateAndTimeStartSessionEvent":"05-01-2026 20:00:00","durationInMinutes":90,"event":{"id":1,"name":"Orange Blossom","description":"concert rock super bien","dateStart":"05-01-2024","dateEnd":"25-02-2024","closedDay":"Lundi","imageUrl":"img/orangeBlossom.jpeg"},"configurationHall":{"id":1,"name":"debout","hall":{"id":1,"name":"Hall 1","capacityOfHall":300,"venue":{"id":1,"name":"Le Trianon","address":{"street":"sesame street","city":"Paris","zipcode":"75001","country":"France"},"employees":[{"id":1,"username":"username","password":"Secret1*","email":"email@admin.fr"}]}},"capacityOfConfiguration":120}}}'

new location : http://localhost:8080/api/bookings/3

Display the booking

Location: http://localhost:8080/api/bookings/3

Notice the price of the booking

  "totalPriceHt": 10.0,

and the seat status which has changed to booked

 "seatStatus": {
            "id": 1,
            "name": "booked"
          }

Make a payment

curl 'http://localhost:8080/api/payments/booking/3' -i -X POST \
    -H 'Content-Type: application/json'

New location : http://localhost:8080/api/payments/2

notice the seat status:

"seatStatus": {
            "id": 3,
            "name": "sold"
        }

Notice the total price of the booking

    "totalPriceHt": 10.0,

and the payment status

"paymentStatus": {
    "id": 1,
    "paymentStatusName": "paid"
  }

Delete an available reservation from a booking

http://localhost:8080/api/bookings/2

Booking of id 2 has only one reservation (sessionEvent2, seat 3). It should delete the reservation of id and the booking

curl 'http://localhost:8080/api/bookings/2/reservationKey' -i -X DELETE \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/json' \
    -d '{"seatId":{"id":3,"isSeated":true,"rowNo":"B","seatNo":3,"configurationHall":{"id":1,"name":"debout","capacityOfConfiguration":120,"hall":{"id":1,"name":"Hall 1","capacityOfHall":300,"venue":{"id":1,"name":"Le Trianon","address":{"street":"sesame street","city":"Paris","zipcode":"75001","country":"France"},"employees":[{"id":1,"username":"username","password":"Secret1*","email":"email@admin.fr"}]}}},"categorySpatial":{"id":1,"name":"orchestre"},"categoryTariff":{"id":1,"name":"categorie 1","tarification":{"id":1,"basePrice":10.0,"taxeRate":0.2,"discountStudentRate":0.5,"discountSeniorRate":0.1,"discountChildRate":0.2,"discountUnemployedRate":0.3,"event":{"id":1,"name":"Orange Blossom","description":"concert rock super bien","dateStart":"05-01-2024","dateEnd":"25-02-2024","closedDay":"Lundi","imageUrl":"img/orangeBlossom.jpeg"}}},"seatStatus":{"id":2,"name":"available"}},"sessionEventId":{"id":2,"dateAndTimeStartSessionEvent":"26-10-2024 20:00:00","durationInMinutes":120,"event":{"id":2,"name":"Mamamoo","description":"Groupe mythique et très humoristique de K-pop.","dateStart":"26-10-2024","dateEnd":"26-11-2024","closedDay":"Mardi","imageUrl":"img/MAMAMOO.jpeg"},"configurationHall":{"id":1,"name":"debout","capacityOfConfiguration":120,"hall":{"id":1,"name":"Hall 1","capacityOfHall":300,"venue":{"id":1,"name":"Le Trianon","address":{"street":"sesame street","city":"Paris","zipcode":"75001","country":"France"},"employees":[{"id":1,"username":"username","password":"Secret1*","email":"email@admin.fr"}]}}}}}'

http://localhost:8080/api/ticketReservations/sessionevent/2/seat/3 "statusCode": 404 http://localhost:8080/api/bookings/2 "statusCode": 404

You can notice that the seat 3 is now available at http://localhost:8080/api/configurationhalls/1/seats

WRONG request

Try to delete a paid booking

Delete the seatId 1 which is sold

curl 'http://localhost:8080/api/bookings/1/reservationKey' -i -X DELETE \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/json' \
    -d '{"seatId":{"id":1,"isSeated":true,"rowNo":"A","seatNo":1,"configurationHall":{"id":1,"name":"debout","capacityOfConfiguration":120,"hall":{"id":1,"name":"Hall 1","capacityOfHall":300,"venue":{"id":1,"name":"Le Trianon","address":{"street":"sesame street","city":"Paris","zipcode":"75001","country":"France"},"employees":[{"id":1,"username":"username","password":"Secret1*","email":"email@admin.fr"}]}}},"categorySpatial":{"id":1,"name":"orchestre"},"categoryTariff":{"id":1,"name":"categorie 1","tarification":{"id":1,"basePrice":10.0,"taxeRate":0.2,"discountStudentRate":0.5,"discountSeniorRate":0.1,"discountChildRate":0.2,"discountUnemployedRate":0.3,"event":{"id":1,"name":"Orange Blossom","description":"concert rock super bien","dateStart":"05-01-2024","dateEnd":"25-02-2024","closedDay":"Lundi","imageUrl":"img/orangeBlossom.jpeg"}}},"seatStatus":{"id":3,"name":"sold"}},"sessionEventId":{"id":1,"dateAndTimeStartSessionEvent":"05-01-2026 20:00:00","durationInMinutes":90,"event":{"id":1,"name":"Orange Blossom","description":"concert rock super bien","dateStart":"05-01-2024","dateEnd":"25-02-2024","closedDay":"Lundi","imageUrl":"img/orangeBlossom.jpeg"},"configurationHall":{"id":1,"name":"debout","capacityOfConfiguration":120,"hall":{"id":1,"name":"Hall 1","capacityOfHall":300,"venue":{"id":1,"name":"Le Trianon","address":{"street":"sesame street","city":"Paris","zipcode":"75001","country":"France"},"employees":[{"id":1,"username":"username","password":"Secret1*","email":"email@admin.fr"}]}}}}}'

answer :

HTTP/1.1 409
Vary: origin,access-control-request-method,access-control-request-headers,accept-encoding
Content-Type: application/json
Transfer-Encoding: chunked
Date: Tue, 17 Sep 2024 14:53:52 GMT

{"timestamp":"17-09-2024 16:53:52","statusCode":409,"path":"/api/bookings/1/reservationKey","message":"Remove error : Booking with id {1} cannot be deleted because it has a paid status"}%

Try to add a sold seat to a ticket reservation

curl 'http://localhost:8080/api/ticketReservations' -i -X POST \
    -H 'Content-Type: application/json' \
    -d '{"ticketReservationKey":{"seatId":{"id":4,"isSeated":true,"seatNo":4,"rowNo":"B","categorySpatial":{"id":1,"name":"orchestre"},"categoryTariff":{"id":1,"name":"categorie 1","tarification":{"id":1,"basePrice":10.0,"taxeRate":0.2,"discountStudentRate":0.5,"discountSeniorRate":0.1,"discountChildRate":0.2,"discountUnemployedRate":0.3,"event":{"id":1,"name":"Orange Blossom","description":"concert rock super bien","dateStart":"05-01-2024","dateEnd":"25-02-2024","closedDay":"Lundi","imageUrl":"img/orangeBlossom.jpeg"}}},"seatStatus":{"id":2,"name":"available"},"configurationHall":{"id":1,"name":"debout","hall":{"id":1,"name":"Hall 1","capacityOfHall":300,"venue":{"id":1,"name":"Le Trianon","address":{"street":"sesame street","city":"Paris","zipcode":"75001","country":"France"},"employees":[{"id":1,"username":"username","password":"Secret1*","email":"email@admin.fr"}]}},"capacityOfConfiguration":120}},"sessionEventId":{"id":1,"dateAndTimeStartSessionEvent":"05-01-2026 20:00:00","durationInMinutes":90,"event":{"id":1,"name":"Orange Blossom","description":"concert rock super bien","dateStart":"05-01-2024","dateEnd":"25-02-2024","closedDay":"Lundi","imageUrl":"img/orangeBlossom.jpeg"},"configurationHall":{"id":1,"name":"debout","hall":{"id":1,"name":"Hall 1","capacityOfHall":300,"venue":{"id":1,"name":"Le Trianon","address":{"street":"sesame street","city":"Paris","zipcode":"75001","country":"France"},"employees":[{"id":1,"username":"username","password":"Secret1*","email":"email@admin.fr"}]}},"capacityOfConfiguration":120}}},"isBooked":false}'

answer is a http status code : 409

HTTP/1.1 409
Vary: origin,access-control-request-method,access-control-request-headers,accept-encoding
Content-Type: application/json
Transfer-Encoding: chunked
Date: Tue, 17 Sep 2024 11:44:45 GMT

{"timestamp":"17-09-2024 13:44:45","statusCode":409,"path":"/api/ticketReservations","message":"A duplicate key error occurred : Ticket_Reservation not created, The following id already exists in the database: TicketReservationKeyDTO[seatId=SeatDTO[id=4, isSeated=true, seatNo=4, rowNo=B, categorySpatial=CategorySpatialDTO[id=1, name=orchestre], categoryTariff=CategoryTariffDTO[id=1, name=categorie 1, tarification=TarificationDTO[id=1, basePrice=10.0, taxeRate=0.2, discountStudentRate=0.5, discountSeniorRate=0.1, discountChildRate=0.2, discountUnemployedRate=0.3, event=EventDTO[id=1, name=Orange Blossom, description=concert rock super bien, dateStart=2024-01-05, dateEnd=2024-02-25, closedDay=Lundi, imageUrl=img/orangeBlossom.jpeg]]], seatStatus=SeatStatusDTO[id=2, name=available], configurationHall=ConfigurationHallDTO[id=1, name=debout, hall=HallDTO[id=1, name=Hall 1, capacityOfHall=300, venue=VenueDTO[id=1, name=Le Trianon, address=AddressDTO[street=sesame street, city=Paris, zipcode=75001, country=France], employees=[EmployeeDTO[id=1, username=username, password=Secret1*, email=email@admin.fr]]]], capacityOfConfiguration=120]], sessionEventId=SessionEventDTO[id=1, dateAndTimeStartSessionEvent=2026-01-05T20:00, durationInMinutes=90, event=EventDTO[id=1, name=Orange Blossom, description=concert rock super bien, dateStart=2024-01-05, dateEnd=2024-02-25, closedDay=Lundi, imageUrl=img/orangeBlossom.jpeg], configurationHall=ConfigurationHallDTO[id=1, name=debout, hall=HallDTO[id=1, name=Hall 1, capacityOfHall=300, venue=VenueDTO[id=1, name=Le Trianon, address=AddressDTO[street=sesame street, city=Paris, zipcode=75001, country=France], employees=[EmployeeDTO[id=1, username=username, password=Secret1*, email=email@admin.fr]]]], capacityOfConfiguration=120]]]"}%

same kind of error if you try to replay the creation of the booking

try to replay a payment already made

curl 'http://localhost:8080/api/payments/booking/3' -i -X POST \
    -H 'Content-Type: application/json'

answer

HTTP/1.1 422
Vary: origin,access-control-request-method,access-control-request-headers,accept-encoding
Content-Type: application/json
Transfer-Encoding: chunked
Date: Tue, 17 Sep 2024 14:48:09 GMT

{"timestamp":"17-09-2024 16:48:09","statusCode":422,"path":"/api/payments/booking/3","message":"A create object error occurred : Payment already exists for booking with id {3}, cannot create payment"}%

Try to add a ticket reservation to a sold booking

Make a booking with the ticketReservation of composite key: sessionEventId 1, seatId 4.

curl 'http://localhost:8080/api/bookings/1/reservationKey' -i -X POST \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/json' \
    -d '{"seatId":{"id":4,"isSeated":true,"seatNo":4,"rowNo":"B","categorySpatial":{"id":1,"name":"orchestre"},"categoryTariff":{"id":1,"name":"categorie 1","tarification":{"id":1,"basePrice":10.0,"taxeRate":0.2,"discountStudentRate":0.5,"discountSeniorRate":0.1,"discountChildRate":0.2,"discountUnemployedRate":0.3,"event":{"id":1,"name":"Orange Blossom","description":"concert rock super bien","dateStart":"05-01-2024","dateEnd":"25-02-2024","closedDay":"Lundi","imageUrl":"img/orangeBlossom.jpeg"}}},"seatStatus":{"id":2,"name":"available"},"configurationHall":{"id":1,"name":"debout","hall":{"id":1,"name":"Hall 1","capacityOfHall":300,"venue":{"id":1,"name":"Le Trianon","address":{"street":"sesame street","city":"Paris","zipcode":"75001","country":"France"},"employees":[{"id":1,"username":"username","password":"Secret1*","email":"email@admin.fr"}]}},"capacityOfConfiguration":120}},"sessionEventId":{"id":1,"dateAndTimeStartSessionEvent":"05-01-2026 20:00:00","durationInMinutes":90,"event":{"id":1,"name":"Orange Blossom","description":"concert rock super bien","dateStart":"05-01-2024","dateEnd":"25-02-2024","closedDay":"Lundi","imageUrl":"img/orangeBlossom.jpeg"},"configurationHall":{"id":1,"name":"debout","hall":{"id":1,"name":"Hall 1","capacityOfHall":300,"venue":{"id":1,"name":"Le Trianon","address":{"street":"sesame street","city":"Paris","zipcode":"75001","country":"France"},"employees":[{"id":1,"username":"username","password":"Secret1*","email":"email@admin.fr"}]}},"capacityOfConfiguration":120}}}'

it cannot been done because the seats of the booking are already sold. So we need to create a new booking instead.