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

Implement Gift Card System: Schema, Controller, Middleware, and Routes #962

Closed
IkkiOcean opened this issue Nov 9, 2024 · 2 comments · Fixed by #970
Closed

Implement Gift Card System: Schema, Controller, Middleware, and Routes #962

IkkiOcean opened this issue Nov 9, 2024 · 2 comments · Fixed by #970
Assignees

Comments

@IkkiOcean
Copy link
Contributor

Description:

We need to implement a gift card system to allow users to purchase, redeem, and manage gift cards. This will involve the following:

  1. Gift Card Schema: A schema to store gift card details such as card number, value, status (active, redeemed, expired), and user association.
  2. Controller: Logic to handle the creation, activation, and redemption of gift cards.
  3. Middleware: Middleware to validate gift cards before redemption and ensure that they are valid and have not expired.
  4. Routes: Define API routes to handle actions such as:
    • Creating and managing gift cards
    • Redeeming gift cards
    • Fetching gift card details

Tasks:

  • Schema Design:

    • Create a GiftCard schema with fields like cardNumber, value, status (active, redeemed, expired), userId (associated user), expiryDate, and createdAt.
  • Controller:

    • GiftCardController: Logic to create new gift cards, activate them, redeem them, and check the status of a gift card.
  • Middleware:

    • Validation middleware to ensure the gift card is valid, not expired, and can only be redeemed once.
    • Check that the value on the gift card is greater than 0 before allowing redemption.
  • Routes:

    • POST /api/gift-cards: To create a new gift card.
    • GET /api/gift-cards/:cardNumber: To fetch details of a specific gift card.
    • POST /api/gift-cards/redeem: To redeem a gift card by entering its card number.

Expected Outcome:

  • Proper schema setup for the gift card system.
  • Functional controller logic for creating, activating, and redeeming gift cards.
  • Middleware for validation of gift card status.
  • REST API routes to interact with the gift card system.
Copy link
Contributor

github-actions bot commented Nov 9, 2024

Thank you for creating this issue! 🎉 We'll look into it as soon as possible. In the meantime, please make sure to provide all the necessary details and context. If you have any questions or additional information, feel free to add them here. Your contributions are highly appreciated! 😊

You can also check our CONTRIBUTING.md for guidelines on contributing to this project.

Copy link
Contributor

Hello @IkkiOcean! Your issue #962 has been closed. Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants