-
Notifications
You must be signed in to change notification settings - Fork 98
Home
Introduction: The Banking Portal API allows users to perform various banking operations, including managing accounts, fund transfers, and transactions. This document provides details on each API endpoint, its request parameters, response structure, and authentication requirements. It also includes information on error handling and status codes.
Authentication: The API endpoints require bearer token authentication. Users must obtain a valid access token and include it in the "Authorization" header with the "Bearer" scheme to access protected endpoints.
Base URL:
http://localhost:8180
-
Endpoint:
/api/account/pin/check
-
Method:
GET
- Authorization: Bearer Token
- Request Body: None
- Description: Checks if a PIN has been created for the user's account.
-
Response:
- Status Code: 200 OK
- Body:
or
PIN has been created for this account
PIN has not been created for this account
Possible Status Codes:
- 200 OK: The PIN status was successfully retrieved.
- 401 Unauthorized: The user is not authenticated. Please ensure you include a valid bearer token in the request header.
-
Endpoint:
/api/account/pin/create
-
Method:
POST
- Authorization: Bearer Token
-
Request Body:
{ "pin": "1234", "password": "secretpassword1" }
- Description: Creates a new PIN for the user's account.
-
Response:
- Status Code: 200 OK
- Body:
{ "hasPIN": true, "msg": "PIN created successfully" }
Possible Status Codes:
- 200 OK: The PIN was successfully created.
- 400 Bad Request: The request body is missing or invalid.
- 401 Unauthorized: The user is not authenticated or the provided password is incorrect. Please ensure you include a valid bearer token in the request header.
- 404 Not Found: The user's account was not found.
-
Endpoint:
/api/account/pin/update
-
Method:
POST
- Authorization: Bearer Token
-
Request Body:
{ "accountNumber": "236480" "oldPin": "4321", "newPin": "1234", "password": "secretpassword1" }
- Description: Updates the existing PIN for the user's account.
-
Response:
- Status Code: 200 OK
- Body:
{ "hasPIN": false, "msg": "PIN updated successfully" }
Possible Status Codes:
- 200 OK: The PIN was successfully updated.
- 400 Bad Request: The request body is missing or invalid.
- 401 Unauthorized: The user is not authenticated, the provided password is incorrect, or the old PIN is incorrect. Please ensure you include a valid bearer token in the request header.
- 404 Not Found: The user's account was not found.
-
Endpoint:
/api/account/withdraw
-
Method:
POST
- Authorization: Bearer Token
-
Request Body:
{ "amount": 10.0, "pin": "4321" }
- Description: Withdraws the specified amount from the user's account.
-
Response:
- Status Code: 200 OK
- Body:
{ "msg": "Cash withdrawn successfully" }
Possible Status Codes:
- 200 OK: The cash withdrawal was successful.
- 400 Bad Request: The request body is missing or invalid, or the account does not have sufficient balance.
- 401 Unauthorized: The user is not authenticated or the provided PIN is incorrect. Please ensure you include a valid bearer token in the request header.
- 404 Not Found: The user's account was not found.
-
Endpoint:
/api/account/deposit
-
Method:
POST
- Authorization: Bearer Token
-
Request Body:
{ "amount": 100.0, "pin": "4321" }
- Description: Deposits the specified amount into the user's account.
-
Response:
- Status Code: 200 OK
- Body:
{ "msg": "Cash deposited successfully" }
Possible Status Codes:
- 200 OK: The cash deposit was successful.
- 400 Bad Request: The request body is missing or invalid.
- 401 Unauthorized: The user is not authenticated or the provided PIN is incorrect. Please ensure you include a valid bearer token in the request header.
- 404 Not Found: The user's account was not found.
-
Endpoint:
/api/account/fund-transfer
-
Method:
POST
- Authorization: Bearer Token
-
Request Body:
{ "amount": 10.0, "pin": "4321", "targetAccountNumber": "556704" }
- Description: Transfers the specified amount to another user's account.
-
Response:
- Status Code: 200 OK
- Body:
{ "msg": "Fund transferred successfully" }
Possible Status Codes:
- 200 OK: The fund transfer was successful.
- 400 Bad Request: The request body is missing or invalid, or the account does not have sufficient balance.
- 401 Unauthorized: The user is not authenticated or the provided PIN is incorrect. Please ensure you include a valid bearer token in the request header.
- 404 Not Found: The user's source or target account was not found.
-
Endpoint:
/api/account/transactions
-
Method:
GET
- Authorization: Bearer Token
- Description: Retrieves the list of transactions for the user's account.
-
Response:
- Status Code: 200 OK
- Body: List of transaction objects.
Possible Status Codes:
- 200 OK: The list of transactions was successfully retrieved.
- 401 Unauthorized: The user is not authenticated. Please ensure you include a valid bearer token in the request header.
-
Endpoint:
/api/dashboard/account
-
Method:
GET
- Authorization: Bearer Token
- Description: Retrieves details of the user's account.
-
Response:
- Status Code: 200 OK
- Body: Account details object.
Possible Status Codes:
- 200 OK: The account details were successfully retrieved.
- 401 Unauthorized: The user is not authenticated. Please ensure you include a valid bearer token in the request header.
- 404 Not Found: The user's account was not found.
-
Endpoint:
/api/users/register
-
Method:
POST
-
Request Body:
{ "name": "Abhishek a", "password": "secretpassword2", "email": "[email protected]", "countryCode": "US", "phone_number": "134566690", "address": "123 Main Street" }
- Description: Registers a new user with the provided details.
-
Response:
- Status Code: 200 OK
- Body:
{ "name": "Abhishek a", "email": "[email protected]", "countryCode": "US", "phone_number": "134566690", "address": "123 Main Street", "accountNumber": "236480", "IFSC_code": "[IFSC_CODE]", "branch": "[BRANCH]", "account_type": "[ACCOUNT_TYPE]" }
Possible Status Codes:
- 200 OK: The user was successfully registered.
- 400 Bad Request: The request body is missing or invalid.
- 404 Not Found: The user's account was not found.
-
Endpoint:
/api/dashboard/user
-
Method:
GET
- Authorization: Bearer Token
- Description: Retrieves details of the authenticated user.
-
Response:
- Status Code: 200 OK
- Body: User details object.
Possible Status Codes:
- 200 OK: The user details were successfully retrieved.
- 401 Unauthorized: The user is not authenticated. Please ensure you include a valid bearer token in the request header.
- 404 Not Found: The user's account was not found.
-
Endpoint:
/api/users/login
-
Method:
POST
-
Request Body:
{ "accountNumber": "236480", "password": "secretpassword2" }
- Description: Logs in the user with the provided account number and password.
-
Response:
- Status Code: 200 OK
- Body:
{ "token": "[JWT_TOKEN]" }
Possible Status Codes:
- 200 OK: The login was successful, and a JWT token is provided in the response body.
- 400 Bad Request: The request body is missing or invalid.
- 401 Unauthorized: The provided account number or password is incorrect.
- 404 Not Found: The user's account was not found.
-
Endpoint:
/api/users/logout
-
Method:
GET
- Request Body: None
- Description: Logs out the user and invalidates the existing bearer token.
-
Response:
- Status Code: 200 OK
Possible Status Codes:
- 200 OK: The login was successful, and a JWT token is provided in the response body.
- 401 Unauthorized: The provided account number or password is incorrect.
- 404 Not Found: The user's account was not found.
-
Endpoint:
/api/users/update
-
Method:
POST
-
Request Body:
{ "name": "Abhishek a", "password": "secretpassword2", "email": "[email protected]", "countryCode": "US", "phoneNumber": "134566690", "address": "123 Main Street" }
- Description: Updates an existing logged in user with new details. The "password" field for this endpoint is the account password to verify the account before updates are saved.
-
Response:
- Status Code: 200 OK
- Body:
{ "name": "Abhishek a", "email": "[email protected]", "countryCode": "US", "phoneNumber": "134566690", "address": "123 Main St", "accountNumber": "236480", "ifscCode": "NIT001", "branch": "NIT", "accountType": "Savings" }
Possible Status Codes:
- 200 OK: The user was successfully registered.
- 400 Bad Request: The request body is missing or invalid.
- 401 Unauthorized: The provided account number or password is incorrect.
- 404 Not Found: The user's account was not found.
- 500 Internal Server Error: The email or phone number for the user information being updated is already in use by another user in the database.
-
Endpoint:
/api/auth/password-reset/send-otp
-
Method:
POST
- Authorization: Bearer Token
-
Request Body:
{ "identifier": "236480" }
- Description: Sends an OTP (6-digit integer string) to the email for the identifier account number.
-
Response:
- Status Code: 200 OK
- Body:
{ "message": "OTP sent successfully to: [email protected]" }
Possible Status Codes:
- 200 OK: The OTP was generated successfully.
- 400 Bad Request: The request body is missing or invalid.
- 401 Unauthorized: The user is not authenticated. Please ensure you include a valid bearer token in the request header.
- 404 Not Found: The user's account was not found.
-
Endpoint:
/api/auth/password-reset/verify-otp
-
Method:
POST
- Authorization: Bearer Token
-
Request Body:
{ "identifier": "236480", "otp": "123456" }
- Description: Verifies the OTP (6-digit integer string) in the message body OTP field matches the OTP sent to the email for the identifier account number, then provides a password reset token.
-
Response:
- Status Code: 200 OK
- Body:
{ "passwordResetToken": "[Password Reset Token]" }
Possible Status Codes:
- 200 OK: The OTP was generated successfully.
- 400 Bad Request: The request body is missing or invalid.
- 401 Unauthorized: The user is not authenticated. Please ensure you include a valid bearer token in the request header.
- 404 Not Found: The user's account was not found.
-
Endpoint:
/api/auth/password-reset/verify-otp
-
Method:
POST
- Authorization: Bearer Token
-
Request Body:
{ "identifier": "236480", "resetToken": "[Reset Token from 3.2. Verify OTP]" "newPassword": "newsecretpassword2" }
- Description: Resets the password for the identifier account to the new password.
-
Response:
- Status Code: 200 OK
- Body:
{ "message": "Password reset successfully" }
Possible Status Codes:
- 200 OK: The OTP was generated successfully.
- 400 Bad Request: The request body is missing or invalid.
- 401 Unauthorized: The user is not authenticated. Please ensure you include a valid bearer token in the request header.
- 404 Not Found: The user's account was not found.
Error Handling: The API implements global exception handling for the following scenarios:
- NotFoundException: Returns 404 Not Found with an error message.
- UnauthorizedException: Returns 401 Unauthorized with an error message.
- InsufficientBalanceException: Returns 400 Bad Request with an error message.
Please note that this API documentation provides an overview of the available endpoints, request parameters, and response structures, along with additional details on error handling and status codes. For a comprehensive understanding of the API, further details such as possible response data and detailed error messages should be included in the final API documentation.