/Flagright-Transactions

This project focuses on creating a Transaction API with features like creation, retrieval, and reporting. It emphasizes scalability, performance, security, and includes advanced functionalities like authentication and CSV reports.

Primary LanguageJavaScript

Flagright-Transactions

image

API Endpoints

1. Create a New Transaction

Endpoint: POST /transactions

Description: This API endpoint allows users to create a new transaction with the provided details.

Request Method: POST

Request Payload: JSON data with the following fields:

  • amount (Number, required): The transaction amount.
  • description (String, required): A description of the transaction.

Response: Returns the details of the created transaction, including the unique transaction ID and timestamp.

Status Codes:

  • 201 Created: The transaction was successfully created.
  • 400 Bad Request: If the request payload is missing or invalid.
  • 500 Internal Server Error: In case of server-side issues.

2. Retrieve Transaction Details by Transaction ID

Endpoint: GET /transactions/{transactionId}

Description: This API endpoint retrieves details of a specific transaction based on its unique transaction ID.

Request Method: GET

Request Parameters: {transactionId} (String, required): The unique ID of the transaction.

Response: Returns detailed information about the transaction, including amount, description, datetime, and other relevant fields.

Status Codes:

  • 200 OK: The transaction was found and returned.
  • 404 Not Found: If the transaction with the provided ID does not exist.
  • 500 Internal Server Error: In case of server-side issues.

3. Search for Transactions

Endpoint: GET /transactions/search

Description: This API endpoint allows users to search for transactions based on specific criteria.

Request Method: GET

Query Parameters: Users can provide query parameters to filter transactions based on criteria such as:

  • amount (Number): Filter transactions by a specific amount or range of amounts.
  • dateRange (Date Range): Search for transactions within a specified date range.
  • description (String): Search for transactions containing a particular keyword in the description.
  • Other relevant query parameters.

Response: Returns a list of transactions that match the specified criteria.

Status Codes:

  • 200 OK: Transactions matching the criteria were found and returned.
  • 400 Bad Request: If the query parameters are invalid.
  • 500 Internal Server Error: In case of server-side issues.

4. Generate Transaction Reports

Endpoint: GET /reports

Description: This API endpoint allows users to generate transaction reports based on specified parameters.

Request Method: GET

Query Parameters: Users can specify parameters such as:

  • period (String, required): The period for the report (e.g., daily, monthly).
  • reportType (String, required): The type of report to generate (e.g., summary, total amount).
  • Other relevant query parameters.

Response: Returns the requested transaction report as structured data (e.g., JSON or CSV).

Status Codes:

  • 200 OK: The report was generated successfully and returned.
  • 400 Bad Request: If the query parameters are missing or invalid.
  • 500 Internal Server Error: In case of server-side issues.

5. Control CRON Job (Start/Stop)

Endpoints: POST /cronjob/start and POST /cronjob/stop

Description: These API endpoints allow users to control the background CRON job responsible for generating transactions. The start endpoint starts the CRON job, while the stop endpoint halts it.

Request Method: POST

Response: Returns a confirmation message indicating whether the CRON job has been started or stopped.

Status Codes:

  • 200 OK: The CRON job was started or stopped successfully.
  • 500 Internal Server Error: In case of server-side issues.