Event Ticket System - Copy this React, Tailwind Component to your project
# TicketHub API Documentation Welcome to the TicketHub API documentation. This document outlines the available endpoints, request formats, and responses for each endpoint. ## Overview The TicketHub API provides a set of endpoints to manage accounts, events, listings, sales, and other resources related to ticket management. ### Base URL All endpoints are accessed via the base URL: https://localhost:7133 ## Endpoints ### Account Endpoints #### Email Verification - **Endpoint:** `POST /api/Account/EmailVerification` - **Description:** Verifies the user's email with a verification code. - **Request Parameters:** - `Email` (string) - User's email address. - `Code` (string) - Verification code sent to the email. - **Response:** 200 OK on success. #### Sign Up - **Endpoint:** `POST /api/Account/SignUp` - **Description:** Creates a new account. - **Request Body:** JSON object following `SignUp` schema. - `username` (string) - User's name. - `firstName` (string) - first name. - `lastName` (string) - last name. - `firstName` (string) - first name. - `email` (string) - email address. - `password` (string) - password. - `confirmPassword` (string) - confirm password. - **Response:** 200 OK on success. #### Sign In - **Endpoint:** `POST /api/Account/SignIn` - **Description:** Authenticates an existing user. - **Request Body:** JSON object following `SignIn` schema. - `email` (string) - email address. - `password` (string) - password. - **Response:** 200 OK on success. #### Get Account Information - **Endpoint:** `GET /api/Account` - **Description:** Retrieves the account information of the current user. - **Response:** 200 OK with a list of `ApplicationUser` objects. #### Update Account - **Endpoint:** `PATCH /api/Account` - **Description:** Updates the account information for the current user. - **Request Body:** JSON object following `AccountDTO` schema. ```json { "userName": "string", "firstName": "string", "lastName": "string", "city": "string", "state": "string", "email": "string", "phoneNumber": "string" } ``` - **Response:** 204 No Content on success. ### Get User by ID - **Endpoint:** `GET /api/Account/{id}` - **Description:** Retrieves account information for a specific user by ID. - **Path Parameter:** - `id` (string, required) - The user’s unique identifier. - **Response Codes:** - **200 OK:** Returns an `ApplicationUser` object. - **400 Bad Request:** Invalid user ID. #### Change password - **Endpoint:** `PATCH /api/Account/changepassword` - **Description:** Changes the authenticated user’s password. - **Request Body:** JSON object following `ChangePasswordDTO` schema. - `currentPassword` (string) - User's current password. - `newPassword` (string) - New password. - `confirmPassword` (string) - New password confirmation. - **Response Codes:** - **204 No Content:** Password changed successfully. - **400 Bad Request:** Invalid or missing data. ### Change User Role - **Endpoint:** `PATCH /api/Account/changerole/{userId}` - **Description:** Updates the role of a specific user. - **Path Parameter:** - `userId` (string, required) - User’s unique ID. - **Request Body:** JSON object based on `ChangeRoleDTO` schema with: - `roleName` (string) - New role to assign. - **Response Codes:** - **204 No Content:** Role updated successfully. - **400 Bad Request:** Invalid data provided. ### Category Endpoints - **Get Categories** - **Endpoint**: `GET /api/Category` - **Description**: Retrieves a list of categories. - **Response**: - `200 Success`: Returns an array of categories. - **Get Category by ID** - **Endpoint**: `GET /api/Category/{id}` - **Description**: Retrieves details of a specific category by ID. - **Path Parameters**: - `id` (integer): The ID of the category. - **Response**: - `200 Success`: Returns the category details. - **Create Category** - **Endpoint**: `POST /api/Category` - **Description**: Creates a new category. - **Request Body**: - `application/json`: Fields as specified in `CategoryDTO`. ```json { "catGroup": "string", "catName": "string", "catDesc": "string" } ``` - **Response**: - `204 No Content` on successful creation. - **Update Category** - **Endpoint**: `PUT /api/Category/{categoryId}` - **Description**: Updates an existing category by its ID. - **Path Parameters**: - `categoryId` (integer): The ID of the category to update. - **Request Body**: - `application/json`: Fields as specified in `CategoryDTO`. ```json { "catGroup": "string", "catName": "string", "catDesc": "string" } ``` - **Response**: - `204 No Content` on successful update. - `400 Bad Request` if the request body is malformed. - `404 Not Found` if the category does not exist. - **Delete Category** - **Endpoint**: `DELETE /api/Category/{categoryId}` - **Description**: Deletes a specific category by its ID. - **Path Parameters**: - `categoryId` (integer): The ID of the category to delete. - **Response**: - `204 No Content` on successful deletion. - `400 Bad Request` if the request parameters are malformed. - `404 Not Found` if the category does not exist. ### Date Endpoints - **Get Dates** - **Endpoint**: `GET /api/Date` - **Description**: Retrieves a list of dates. - **Response**: - `200 Success`: Returns an array of dates. - **Get Date by ID** - **Endpoint**: `GET /api/Date/{id}` - **Description**: Retrieves details of a specific date by ID. - **Path Parameters**: - `id` (integer): The ID of the date. - **Response**: - `200 Success`: Returns the date details. - **Create Date** - **Endpoint**: `POST /api/Date` - **Description**: Creates a new date. - **Request Body**: - `application/json`: Fields as specified in `DateDTO`. ```json { "calDate": "date time" } ``` - **Response**: - `204 No Content` on successful creation. - **Update Date** - **Endpoint**: `PUT /api/Date/{dateId}` - **Description**: Updates an existing date by its ID. - **Path Parameters**: - `dateId` (integer): The ID of the date to update. - **Request Body**: - `application/json`: Fields as specified in `DateDTO`. ```json { "calDate": "date time" } ``` - **Response**: - `204 No Content` on successful update. - `400 Bad Request` if the request body is malformed. - `404 Not Found` if the date does not exist. - **Delete Date** - **Endpoint**: `DELETE /api/Date/{dateId}` - **Description**: Deletes a specific date by its ID. - **Path Parameters**: - `dateId` (integer): The ID of the date to delete. - **Response**: - `204 No Content` on successful deletion. - `400 Bad Request` if the request parameters are malformed. - `404 Not Found` if the date does not exist. ### Event Endpoints - **Get All Events** - **Endpoint**: `GET /api/Event` - **Description**: Retrieves a list of all events. - **Response**: - `200 Success`: Returns an array of events. - **Get Event by ID** - **Endpoint**: `GET /api/Event/{id}` - **Description**: Retrieves details of a specific event by its ID. - **Path Parameters**: - `id` (integer): The ID of the event. - **Response**: - `200 Success`: Returns the event details. - `400 Bad Request` if the request parameters are malformed. - `404 Not Found` if the event does not exist. - **Search Events** - **Endpoint**: `GET /api/Event/search` - **Description**: Searches for events based on query parameters. - **Query Parameters**: - `query` (string): Search term for the event. - `startDate` (string, date-time): Filters events starting on or after this date. - `endDate` (string, date-time): Filters events ending on or before this date. - `venueCity` (string): Filters events by city. - `category` (string): Filters events by category. - **Response**: - `200 Success`: Returns matching events based on the search criteria. - **Create Event** - **Endpoint**: `POST /api/Event` - **Description**: Creates a new event. - **Request Body**: - `application/json`: Fields as specified in `EventDTO`. ```json { "eventName": "string", "totalExpenses": 0, "venueId": 0, "catId": 0, "dateId": 0, "startTime": "date time" } ``` - **Response**: - `204 No Content` on successful creation. - `400 Bad Request` if the request body is malformed. - **Update Event** - **Endpoint**: `PATCH /api/Event/{eventId}` - **Description**: Updates an existing event by its ID. - **Path Parameters**: - `eventId` (integer): The ID of the event to update. - **Request Body**: - `application/json`: Fields as specified in `UpdateEventDTO`. ```json { "eventName": "string", "totalExpenses": 0, "venueId": 0, "catId": 0, "dateId": 0, "startTime": "datetime" } ``` - **Response**: - `204 No Content` on successful update. - `400 Bad Request` if the request body is malformed. - `404 Not Found` if the event does not exist. - **Delete Event** - **Endpoint**: `DELETE /api/Event/{eventId}` - **Description**: Deletes a specific event by its ID. - **Path Parameters**: - `eventId` (integer): The ID of the event to delete. - **Response**: - `204 No Content` on successful deletion. - `400 Bad Request` if the request parameters are malformed. - `404 Not Found` if the event does not exist. ### Listing Endpoints #### Get Listings - **Endpoint:** `GET /api/Listing` - **Description:** Retrieves a list of all listings. - **Response:** 200 OK with a list of `Listing` objects. - **Get Listing by ID** - **Endpoint**: `GET /api/Listing/{id}` - **Description**: Retrieves details of a specific listing by its ID. - **Path Parameters**: - `id` (integer): The ID of the listing. - **Response**: - `200 Success`: Returns the listing details. - `400 Bad Request` if the request parameters are malformed. - `404 Not Found` if the listing does not exist. - **Search Listings** - **Endpoint**: `GET /api/Listing/search` - **Description**: Searches for listings based on event name. - **Query Parameters**: - `eventName` (string): Event name to search for associated listings. - **Response**: - `200 Success`: Returns matching listings based on the search criteria. - `400 Bad Request` if the search parameters are invalid. - **Create Listing** - **Endpoint:** `POST /api/Listing` - **Description:** Adds a new listing. - **Request Body:** JSON object following `ListingDTO` schema. ```json { "eventId": 0, "dateId": 0, "numTickets": 0, "pricePerTicket": 0, "ticketType": 0, "listTime": "Date time" } ``` - **Response:** - `204 No Content` on successful creation. - `400 Bad Request` if the request body is malformed. - **Update Listing** - **Endpoint**: `PATCH /api/Listing/{listingId}` - **Description**: Updates an existing listing by its ID. - **Path Parameters**: - `listingId` (integer): The ID of the listing to update. - **Request Body**: - `application/json`: Fields as specified in `UpdateListingDTO`. ```json { "eventId": 0, "dateId": 0, "numTickets": 0, "pricePerTicket": 0, "ticketType": 0, "listTime": "Date time" } ``` - **Response**: - `204 No Content` on successful update. - `400 Bad Request` if the request body is malformed. - `404 Not Found` if the listing does not exist. - **Delete Listing** - **Endpoint**: `DELETE /api/Listing/{listingId}` - **Description**: Deletes a specific listing by its ID. - **Path Parameters**: - `listingId` (integer): The ID of the listing to delete. - **Response**: - `204 No Content` on successful deletion. - `400 Bad Request` if the request parameters are malformed. - `404 Not Found` if the listing does not exist. ### Sale Endpoints - **Get All Sales** - **Endpoint**: `GET /api/Sale` - **Description**: Retrieves a list of all sales. - **Response**: - `200 Success`: Returns an array of sales. - **Get Sale by ID** - **Endpoint**: `GET /api/Sale/{id}` - **Description**: Retrieves details of a specific sale by its ID. - **Path Parameters**: - `id` (integer): The ID of the sale. - **Response**: - `200 Success`: Returns the sale details. - `400 Bad Request` if the request parameters are malformed. - `404 Not Found` if the sale does not exist. - **Create Sale** - **Endpoint:** `POST /api/Sale` - **Description:** Registers a new sale. - **Request Body:** JSON object following `SaleDTO` schema. ```json { "listId": 0, "buyerId": "string", "eventId": 0, "dateId": 0, "qtySold": 0, "pricePaid": 0, "saleTime": "2024-11-10T06:57:04.132Z" } ``` - **Response:** 200 OK on success. - **Create Payment URL for Sale** - **Endpoint**: `POST /api/Sale/CreatePaymentUrl` - **Description**: Creates a payment URL for a sale. - **Request Body**: - `application/json`: Fields as specified in `OrderInfoModel` (includes information such as order ID and amount). ```json { "fullName": "string", "orderId": "string", "orderInfo": "string", "amount": 0 } ``` - **Response**: - `200 Success`: Returns the generated payment URL. - **Update Sale** - **Endpoint**: `PATCH /api/Sale/{saleId}` - **Description**: Updates an existing sale by its ID. - **Path Parameters**: - `saleId` (integer): The ID of the sale to update. - **Request Body**: - `application/json`: Fields as specified in `UpdateSaleDTO`. ```json { "listId": 0, "buyerId": "string", "eventId": 0, "dateId": 0, "qtySold": 0, "pricePaid": 0, "saleTime": "2024-11-10T06:57:04.132Z" } ``` - **Response**: - `204 No Content` on successful update. - `400 Bad Request` if the request body is malformed. - `404 Not Found` if the sale does not exist. - **Delete Sale** - **Endpoint**: `DELETE /api/Sale/{saleId}` - **Description**: Deletes a specific sale by its ID. - **Path Parameters**: - `saleId` (integer): The ID of the sale to delete. - **Response**: - `204 No Content` on successful deletion. - `400 Bad Request` if the request parameters are malformed. - `404 Not Found` if the sale does not exist. - **Momo Return for Sale** - **Endpoint**: `GET /api/Sale/momo-return` - **Description**: Handles the return from Momo payment service (used for payment processing). - **Response**: - `200 Success`: Indicates the return was processed successfully. ### Venue Endpoints - **Get All Venues** - **Endpoint:** `GET /api/Venue` - **Description:** Retrieves a list of all venues. - **Response:** 200 OK with a list of `Venue` objects. - **Get Venue by ID** - **Endpoint**: `GET /api/Venue/{id}` - **Description**: Retrieves details of a specific venue by its ID. - **Path Parameters**: - `id` (integer): The ID of the venue. - **Response**: - `200 Success`: Returns the venue details. - `400 Bad Request` if the request parameters are malformed. - `404 Not Found` if the venue does not exist. - **Create Venue** - **Endpoint:** `POST /api/Venue` - **Description:** Adds a new venue. - **Request Body:** JSON object following `VenueDTO` schema. ```json { "venueName": "string", "venueCity": "string", "venueState": "string", "venueSeats": 0 } ``` - **Response:** 204 No Content on success. - **Update Venue** - **Endpoint**: `PUT /api/Venue/{venueId}` - **Description**: Updates an existing venue by its ID. - **Path Parameters**: - `venueId` (integer): The ID of the venue to update. - **Request Body**: - `application/json`: Fields as specified in `VenueDTO`. ```json { "venueName": "string", "venueCity": "string", "venueState": "string", "venueSeats": 0 } ``` - **Response**: - `204 No Content` on successful update. - `400 Bad Request` if the request body is malformed. - `404 Not Found` if the venue does not exist. - **Delete Venue** - **Endpoint**: `DELETE /api/Venue/{venueId}` - **Description**: Deletes a specific venue by its ID. - **Path Parameters**: - `venueId` (integer): The ID of the venue to delete. - **Response**: - `204 No Content` on successful deletion. - `400 Bad Request` if the request parameters are malformed. - `404 Not Found` if the venue does not exist. ### Ticket Endpoints - **Get All Tickets** - **Endpoint**: `GET /api/Tiket` - **Description**: Retrieves a list of all tickets. - **Response**: - `200 Success`: Returns an array of tickets. - **Get Ticket by ID** - **Endpoint**: `GET /api/Tiket/{id}` - **Description**: Retrieves details of a specific ticket by its ID. - **Path Parameters**: - `id` (integer): The ID of the ticket. - **Response**: - `200 Success`: Returns the ticket details. - `400 Bad Request` if the request parameters are malformed. - `404 Not Found` if the ticket does not exist. - **Create Ticket** - **Endpoint**: `POST /api/Tiket` - **Description**: Creates a new ticket. - **Request Body**: - `application/json`: Fields as specified in `TicketDTO`. - **Response**: - `201 Created`: Returns the created ticket details. - `400 Bad Request` if the request body is malformed. - **Update Ticket** - **Endpoint**: `PATCH /api/Tiket/{id}` - **Description**: Updates the status or scanned date of a ticket. - **Path Parameters**: - `id` (integer): The ID of the ticket to update. - **Request Body**: - `multipart/form-data`: Fields `Status` (ticket status) and `ScannedDate` (datetime). - **Response**: - `204 No Content` on successful update. - `400 Bad Request` if the request body is malformed. - `404 Not Found` if the ticket does not exist. - **Get Tickets by Sale ID** - **Endpoint**: `GET /api/Tiket/sale/{saleId}` - **Description**: Retrieves tickets associated with a specific sale. - **Path Parameters**: - `saleId` (integer): The ID of the sale. - **Response**: - `200 Success`: Returns an array of tickets associated with the sale. - `400 Bad Request` if the request parameters are malformed. - `404 Not Found` if no tickets are found for the specified sale. ## Error Handling Responses may include HTTP status codes to indicate success or the type of error. Common codes include: - **200 OK:** Request was successful. - **204 No Content:** Successful operation with no additional data to return. - **400 Bad Request:** Invalid parameters were provided. - **404 Not Found:** Resource could not be found. - **500 Internal Server Error:** Server encountered an error processing the request.