This is the API documentation for the User Microservice. This service allows users to register, log in, retrieve user details, and manage user account balances. The API uses JWT-based authentication for secure access to certain endpoints.
-
Clone the repository:
git clone https://github.com/smammahdi/hackfleet.git
-
Navigate to the project directory:
cd user-microservice -
Build the project using Maven:
mvn clean install
-
Run the application:
mvn spring-boot:run
The application should now be running locally on http://20.115.178.62.
Endpoint: POST /users/register
{
"nid": "long",
"name": "string",
"email": "string",
"password": "string",
"money": "long"
}- Body:
{ "token": "string" } - Status Code:
200 OK
Endpoint: POST /users/login
{
"email": "string",
"password": "string"
}- Body:
{ "token": "string" } - Status Code:
200 OK
Endpoint: GET /users/{id}
id: User's ID (Long)
- Body:
{ "id": "long", "nid": "long", "name": "string", "email": "string", "money": "long" } - Status Code:
200 OK
Endpoint: PUT /users/balance/add
userId: User's ID (Long)balance: Amount to add to the user's balance (Long)
- Body:
"Balance updated successfully" - Status Code:
200 OK
Endpoint: PUT /users/balance/reduce
userId: User's ID (Long)balance: Amount to reduce from the user's balance (Long)
- Body:
"Balance updated successfully" - Status Code:
200 OK
For endpoints like Get User by ID, Add Balance, and Reduce Balance, you need to provide the JWT token in the request headers.
Authorization: Bearer <token>Replace <token> with the actual token you received upon registration or login.
This documentation provides an overview of the Trains Microservice. This service allows users to search for trains, view seats, manage train data, and update seat statuses.
Endpoint: GET /trains
Retrieve a list of trains based on the departure location, destination, and date.
{
"fromPlace": "string",
"toPlace": "string",
"departureDate": "yyyy-MM-dd"
}- Body:
[ { "id": "long", "name": "string", "fromPlace": "string", "toPlace": "string", "departureTime": "yyyy-MM-ddTHH:mm:ss", "seats": [...] } ] - Status Code:
200 OK
Endpoint: GET /trains/{trainId}/seats
Retrieve a list of seats for a specific train. You can optionally filter the seats by class.
trainId: The ID of the train.
seatClass(optional): The class of the seats (e.g., "Economy", "Business").
- Body:
[ { "seatId": "long", "seatClass": "string", "status": "string", "price": "long" } ] - Status Code:
200 OK
Endpoint: POST /trains/add
Add new trains with their associated seats. You can add multiple trains at once.
[
{
"name": "string",
"fromPlace": "string",
"toPlace": "string",
"departureTime": "yyyy-MM-ddTHH:mm:ss",
"seats": [
{
"seatClass": "string",
"status": "string",
"price": "long"
}
]
}
]- Body:
[ { "id": "long", "name": "string", "fromPlace": "string", "toPlace": "string", "departureTime": "yyyy-MM-ddTHH:mm:ss", "seats": [...] } ] - Status Code:
200 OK
Endpoint: GET /trains/with-seats
Retrieve all trains along with their seats.
- Body:
[ { "trainId": "long", "trainName": "string", "fromPlace": "string", "toPlace": "string", "departureTime": "yyyy-MM-ddTHH:mm:ss", "seats": [...] } ] - Status Code:
200 OK
Endpoint: PUT /trains/setStatus
Set the status of one or more seats and calculate the total cost of the seats with the specified status.
{
"seatIds": ["long", "long"],
"status": "string"
}- Body:
{ "totalCost": "long" } - Status Code:
200 OK
Currently, the Trains Microservice API does not require authentication for accessing its endpoints. All endpoints are publicly accessible.
This documentation provides an overview of the Payment Microservice. The service is responsible for handling payment creation, retrieving tickets associated with a user, and managing ticket deletion.
-
Clone the repository:
git clone https://github.com/your-repository/payment-microservice.git
-
Navigate to the project directory:
cd payment-microservice -
Build the project using Maven:
mvn clean install
-
Run the application:
mvn spring-boot:run
The application will run locally at http://localhost:8080.
Endpoint: POST /payment
This endpoint allows the creation of a payment for a user by specifying user ID, booking ID, and a list of passengers. Upon successful creation, the payment details are returned.
{
"userId": "long",
"bookingId": "long",
"passengerList": ["string"]
}- Body:
{ "paymentId": "long", "userId": "long", "bookingId": "long", "amount": "long" } - Status Code:
201 Created
- Body:
"Error message" - Status Code:
400 Bad Request
Endpoint: GET /payment/ticket
Retrieve a list of tickets associated with a specific user by providing their user ID.
{
"userId": "long"
}- Body:
[ { "ticketId": "long", "userId": "long", "passengerList": ["string", "string"], "seatId": ["long"], "amount": "long", "bookingId": "long", "paymentId": "long" } ] - Status Code:
200 OK
- Status Code:
404 Not Found
Endpoint: GET /payment/ticket/{ticketId}
Retrieve a specific ticket by its ID and the user associated with it. You must provide the user ID in the request body and the ticket ID in the path variable.
ticketId: Ticket's ID (Long)
{
"userId": "long"
}- Body:
{ "ticketId": "long", "userId": "long", "passengerList": ["string"], "seatId": ["long"], "amount": "long", "bookingId": "long", "paymentId": "long" } - Status Code:
200 OK
- Status Code:
404 Not Found
Endpoint: DELETE /payment/ticket/{ticketId}
Delete a specific ticket by providing the user ID and the ticket ID.
ticketId: Ticket's ID (Long)
{
"userId": "long"
}- Body:
"Ticket deletion was successful" - Status Code:
200 OK
- Status Code:
404 Not Found
Currently, the Payment Microservice API does not require authentication for accessing its endpoints. All endpoints are publicly accessible.
This documentation provides an overview of the Booking Microservice. The service is responsible for managing user bookings, verifying bookings using OTP, and retrieving booking details.
Endpoint: POST /booking
This endpoint allows a user to create a booking by providing their user ID and a list of seat IDs. Upon successful booking, the booking ID is returned.
{
"userId": "long",
"seatIds": ["long"]
}- Body:
{ "bookingId": "long" } - Status Code:
202 Accepted
- Body:
"Booking wasn't successful!" - Status Code:
404 Not Found
Endpoint: POST /booking/verify
This endpoint allows the user to verify their booking by providing the OTP (One-Time Password) sent to their registered contact details. If the OTP is correct, the booking is confirmed.
{
"userId": "long",
"bookingId": "long",
"otp": "long"
}- Body:
true(if verified) orfalse(if verification failed) - Status Code:
202 Accepted
Endpoint: GET /booking/{id}
Retrieve the details of a booking using its booking ID.
id: The ID of the booking.
- Body:
{ "bookingId": "long", "userId": "long", "seatIds": ["long"], "status": "string" } - Status Code:
200 OK
- Status Code:
404 Not Found
