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

Add rental APIs #916

Merged
merged 1 commit into from
Nov 9, 2024
Merged

Conversation

haseebzaki-07
Copy link
Contributor

@haseebzaki-07 haseebzaki-07 commented Nov 9, 2024

Pull Request

Title

Renting APIs for products

Description

Renting Agricultural Equipment
Endpoint: POST /rentals

Updating Rental Details
Endpoint: PUT /rentals/{rentalId}

Cancelling a Rental
Endpoint: DELETE /rentals/{rentalId}

Viewing Rental Details
Endpoint: GET /rentals/{rentalId}

Returning Rented Equipment
Endpoint: POST /rentals/{rentalId}/return

Related Issues

fixes #882

Changes Made

RentProduct Schema:

Added rental price fields for different durations: rentalPricePerHour, rentalPricePerDay, rentalPricePerWeek, rentalPricePerMonth.
Introduced availabilityStatus to track product rental status ('available', 'rented', 'maintenance').
Included rentedQuantity to track how many items of the product have been rented.

User Schema:

Rentals array stores rental data with rentalId, product, quantity, rentalDuration, and rental status.

Rental Controller:

Implemented logic to check product availability using availabilityStatus before proceeding with rental creation.
Added dynamic rental price calculation based on rentalDuration and corresponding product price.
Improved error handling for missing rental prices depending on the duration type.
Added logging for better debugging (e.g., logging product availability status).
Managed the update of rented quantity and availability status of the product upon successful rental creation.

Checklist

  • I have tested the changes locally
  • Documentation has been updated (if necessary)
  • Changes are backward-compatible

Screenshots (if applicable)

Screenshot 2024-11-09 133140
Screenshot 2024-11-09 133400
Screenshot 2024-11-09 133426

Copy link

vercel bot commented Nov 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
agro-tech-ai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 9, 2024 8:08am

Copy link
Contributor

github-actions bot commented Nov 9, 2024

Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. In the meantime, please ensure that your changes align with our CONTRIBUTING.md. If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊

@manikumarreddyu manikumarreddyu merged commit f9e8359 into manikumarreddyu:main Nov 9, 2024
4 checks passed
Copy link
Contributor

github-actions bot commented Nov 9, 2024

🎉 Your pull request has been successfully merged! 🎉 Thank you for your valuable contribution to our project. Your efforts are greatly appreciated. Feel free to reach out if you have any more contributions or if there's anything else we can assist you with. Keep up the fantastic work! 🚀

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

Successfully merging this pull request may close these issues.

[Feature Request]: Renting APIs for products
2 participants