Skip to content

Home (Main Page)

malhaq edited this page Nov 8, 2024 · 17 revisions

RentItOut: Backend API

Welcome to the RentItOut API documentation! This platform facilitates item rentals, making it easy for users to list and manage items for rent, such as tools, vehicles, and electronics. Built with Node.js and MongoDB, the project provides flexible rental durations and pricing models to meet user needs.

Setup and Installation

Requirements

  • Node.js
  • Express.js
  • MongoDB
  • Git

Installation Steps

  1. Clone the repository:
    git clone https://github.com/malhaq/RentItOut.git
    cd RentItOut
  2. Install dependencies:
    npm install
  3. Start the server:
    nodemon app
    

API Usage

With the server running, use these endpoints to interact with the RentItOut platform.

API Endpoints

Method Endpoint Description
GET /api/items Fetch all rentable items
POST /api/items Add a new item
PUT /api/items/:id Update item details
DELETE /api/items/:id Remove an item from the database
POST /api/ownersignup create new owner in the database
POST /api/rentrsignup create new rentr in the database
POST /api/delivsignup create new deliv in the database
POST /api/adminsignup create an admin in the database
POST /api/ownersignup login the owner in the platform
POST /api/rentrsignup login the renter in the platform
POST /api/delivsignup login the delivy in the platform
POST /api/adminsignup login an admin in the platform
POST /api/onrinsu:id owner subscription the insurance
POST /api/ouninsu:id owner unsubscribes the insurance
POST /api/complain:id renter complaint about some item
POST /api/admfeedback owner ask owners,renter feedback
POST /api/comment:id renters add comment about product
POST /api/question:id renters ask owner for item
GET /api/Owners admin retrieves all owners
GET /api/renters admin retrieves all renters
GET /api/delivery admin retrieves all delivery's
PUT /api/insu:id admin update insurance details
DELETE /api/insu:id admin delete insurance
GET /api/recomd recommendation for high rent item
POST /api/recomd:n recommendation n high rent item
GET /api/revenues retrieving all platform revenues
POST /api/owneremail notify the owner by email
POST /api/rentremail notify the renter by email
POST /api/forgetpass user can create new password
POST /api/otp sending otp code to verify email
PUT /api/verify-otp Verify the email using OTP
POST /api/resend-otp Resend verification OTP
PUT /api/delivery/:id Rate the delivery driver by his ID
PUT /api/order/:id Rate the ordered item by its ID
GET /api/delivery/unassigned Get all the orders that need delivery but not assigned to any
PUT /api/delivery/:id/assigned/ Delivery driver assigns an order to himself
PUT /api/delivery/:id/delivered/ Mark an order as delivered
GET /api/delivery/tobe-delivered/ Get all driver's undelivered orders
GET /api/delivery/my-orders/ Get all delivery orders, both delivered and undelivered
GET /api/my-orders/ Get all orders placed by a specific renter
POST /api/:id/pickup/ Add or update the pickup location for an item
PUT /api/:id/order-pickup/ Update the pickup location for an order
DELETE /api/delete/admin/:id Delete admin account by ID (only by admins)
DELETE /api/delete/renter/:id Delete renter account by ID (admin or user himself)
DELETE /api/owner/renter/:id Delete owner account by ID (admin or user himself)
DELETE /api/delivery/renter/:id Delete delivery account by ID (admin or user himself)

Example Requests

  1. List All Items (GET)

    curl http://localhost:3000/api/items
    
  2. Create New Item (POST)

    curl -X POST -H "Content-Type: application/json" -d '{
      "name": "Electric Drill",
      "category": "Tools",
      "price": 5.0,
      "duration": "Hourly"
    }' http://localhost:3000/api/items
    
  3. Update Item (PUT)

    curl -X PUT -H "Content-Type: application/json" -d '{
      "price": 6.0
    }' http://localhost:3000/api/items/{itemId}
    
  4. Delete Item (DELETE)

    curl -X DELETE http://localhost:3000/api/items/{itemId}
    
  5. Replace {itemId} with the actual ID of the item you want to delete.
    This code provides example requests with brief explanations, helping users understand how to interact with each endpoint
    
  6. Create New owner (POST)

    curl -X POST -H "Content-Type: application/json" -d '{
     "userName":"jaber Mohammad",
     "age":"21",
     "email": "jab@gmail.com",
     "address":"Nablus - Plastain",
     "phoneNumber":"0595050784",
     "gender":"Male",
     "password": "85269741"
    }' localhost:3000/auth/ownerSignUp
    
  7. List All Insurances (GET)

    curl localhost:3000/admin/allInsurance
    
  8. Update Insurance (PUT)

    curl -X PUT -H "Content-Type: application/json" -d '{
      "price": 100
    }' localhost:3000/admin/updateInsurance/{insuranceId}
    
  9. Delete Comment (DELETE)

    curl -X DELETE localhost:3000/AQ/deleteComment{commentID}
    
  10. Request owner Feedback (POST)

    curl -X  localhost:3000/feedback/ask/owners 
    

Features and Roadmap

Current Features

  • Create, view, update, and delete rental listings
  • Flexible rental durations and pricing models
  • RESTful API for managing rentable items
  • Email verification with OTP, verify,resend and generate
  • JWT verification with each API call
  • Logistics Management, suggesting pickup location based on the current location , map integration
  • create, view, update, and delete users
  • logging users into renter platform
  • managing forget password procccess
  • create, update, view, and delete insurances
  • create and delete a comment posted to owner about a certain item
  • requesting the renter and owners to write feedbacks
  • showing the items with high rentals as recommendations
  • create, and retrieve the platform revenues

External API

  • FOURSQUARE maps API utilized to help with the logistics and delivery

Planned Enhancements

  • User authentication and authorization
  • Rental history tracking
  • Advanced filtering options

Contributing

To contribute to RentItOut, please:

  1. Fork the repository and create a new branch for your feature.
  2. Make your changes, then test thoroughly.
  3. Submit a pull request for review.

Guidelines

  1. Follow consistent code styling and commenting.
  2. Document your contributions.