Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get asset by id endpoint and user profile photo coloumn update #471

Merged

Conversation

TheRealLowyer
Copy link
Contributor

Implement GET /api/assets/{id} Endpoint for Retrieving Asset by ID


Description:

This pull request adds the GET /api/assets/{id} endpoint to the Tradeverse application, enabling retrieval of asset details by their unique ID. The implementation adheres to RESTful standards and handles missing resources gracefully.


Changes Implemented:

  1. Controller Layer:

    • Added a getAssetById method in AssetController to handle requests to fetch asset details by ID.
    • Returns:
      • 200 OK with asset details when found.
      • 404 Not Found when the asset does not exist.
  2. Service Layer:

    • Implemented a getAssetById method in AssetService to retrieve asset details using the repository layer.
    • Throws a RuntimeException for missing assets (or can return null if exceptions are avoided).
  3. Repository Layer:

    • Leveraged the findById method from JpaRepository for efficient asset retrieval.
  4. Error Handling:

    • Directly returns 404 Not Found for missing assets without using custom exceptions.

Testing:

  • Verified the endpoint with both valid and invalid IDs:
    • Valid ID returns the asset details (200 OK).
    • Invalid ID returns 404 Not Found.

Endpoint Summary:

GET /api/assets/{id}

  • Request: Fetches an asset by its unique ID.
  • Responses:
    • 200 OK: Returns the asset details in JSON format.
    • 404 Not Found: No asset exists for the provided ID.

Example Response:

{
    "id": 1,
    "name": "Apple Inc.",
    "yahooFinanceSymbol": "AAPL",
    "tradingViewSymbol": "NASDAQ:AAPL"
}

Copy link
Contributor

@karatashsyn karatashsyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done properly 🔥

@TheRealLowyer TheRealLowyer linked an issue Dec 4, 2024 that may be closed by this pull request
2 tasks
@karatashsyn karatashsyn merged commit c05c197 into main Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend Enhancement New feature or request Priority: High Requires taking action ASAP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get asset by id endpoint and user profile photo coloumn update
2 participants