Backend
Ticket Sales
This module handles the ticket sales for a given game. It provides functions to list all available tickets, purchase tickets, and retrieve ticket information.
Functions
-
post_ticket(db: Session, ticket: TicketCreate)- Parameters:
db: Database sessionticket: Ticket to create
- Returns: Ticket created
- Parameters:
-
buy_ticket(db: Session, ticket: UserTicketCreate)- Parameters:
db: Database sessionticket: Ticket to buy
- Returns: Ticket bought
- Parameters:
-
get_tickets_by_user_id(db: Session, user_id: int)- Parameters:
db: Database sessionuser_id: ID of the user
- Returns: List of tickets ID for the user
- Parameters:
-
get_ticket_by_id(db: Session, ticket_id: int)- Parameters:
db: Database sessionticket_id: ID of the ticket
- Returns: Ticket
- Parameters:
-
get_tickets_by_game_id(db: Session, game_id: int)- Parameters:
db: Database sessiongame_id: ID of the game
- Returns: List of tickets for the game
- Parameters:
-
get_tickets(db: Session, skip: int = 0, limit: int = 100)- Parameters:
db: Database sessionskip: Skiplimit: Limit
- Returns: List of tickets
- Parameters:
Tickets Endpoints
-
POST /tickets- Creates a new ticket.
- Parameters:
ticket: Ticket to createdb: Database session (injected by FastAPI)
- Responses:
200 OK: Ticket created successfully.400 Bad Request: If the request is invalid.
-
POST /tickets/buy- Buys a ticket.
- Parameters:
ticket: Ticket to buydb: Database session (injected by FastAPI)
- Responses:
200 OK: Ticket bought successfully.400 Bad Request: If the request is invalid.
-
GET /tickets/user/{user_id}- Retrieves tickets for a specific user ID.
- Parameters:
user_id: ID of the userdb: Database session (injected by FastAPI)
- Responses:
200 OK: List of tickets for the user.404 Not Found: If no tickets are found for the user.
-
GET /tickets/{ticket_id}- Retrieves a ticket by ID.
- Parameters:
ticket_id: ID of the ticketdb: Database session (injected by FastAPI)
- Responses:
200 OK: Ticket details.404 Not Found: If the ticket is not found.
-
GET /tickets/game/{game_id}- Retrieves tickets by game ID.
- Parameters:
game_id: ID of the gamedb: Database session (injected by FastAPI)
- Responses:
200 OK: List of tickets for the game.404 Not Found: If no tickets are found for the game.
-
GET /tickets- Retrieves all tickets (for debug purposes).
- Parameters:
skip: Number of records to skiplimit: Maximum number of records to returndb: Database session (injected by FastAPI)
- Responses:
200 OK: List of tickets.400 Bad Request: If the request is invalid.