Apartments

File Name : apartments.js File Path : /server/routes/apartments.js This route is used to handle user's apartment related queries. For example: creating an apartment, updating apartment details, fetching apartments, fetching filtered apartments, delete apartment etc.

Get Apartments

GET /api/apartments

Headers

Name
Type
Description

Authorization

string

Authentication token


{
    success: true,
    message: 'user apartments',
    data: apartmentObjArray : [
            {
            userId
            address
            gpsLoc
            availableFrom
            houseSize
            spaceFor
            monthlyRent
            oneTimeDeposit
            occupancyType
            amenities
            pictures
            description
            }
            . . . 
            . . .
            ]

}

or 

{
        success: true,
        message: 'no apartments available',
        data: []
}

Create Apartment (Flat)

POST /api/apartments

Headers

Name
Type
Description

Authorization

string

Authentication Token

Request Body

Name
Type
Description

userId

string

User Id

address

string

address of the locality of flat

gpsLoc

array

location array [lat, lng]

availableFrom

string

date from flat is available

houseSize

string

size of the flat

spaceFor

number

space for how many members

monthlyRent

number

monthly rent

oneTimeDeposit

number

one time deposit

occupancyType

string

occupancy type

amenities

array

amenities array

pictures

array

pictures array

description

string

Description

{
         success: true,
          message: 'apartment created successfully',
          data: {
            userId
            address
            gpsLoc
            availableFrom
            houseSize
            spaceFor
            monthlyRent
            oneTimeDeposit
            occupancyType
            amenities
            pictures
            description
            }
}

Update Apartment

PUT /api/apartments/?id=${_id}

Headers

Name
Type
Description

updateObj

object

updateObj contains type of the details to be modified and details obj.

Authorization

string

Authentication Token

 {
            userId
            address
            gpsLoc
            availableFrom
            houseSize
            spaceFor
            monthlyRent
            oneTimeDeposit
            occupancyType
            amenities
            pictures
            description
}

Get filtered Apartments

GET /api/apartments/filterdApartments

Headers

Name
Type
Description

filterObject

object

Contains the filter details

Authorization

string

Authentication Token

{
  success: true,
  message: 'filtered apartments',
  data: filteredApartments

}

or 

{
   success: true,
   message: 'no apartments with this filter options available',
   data: []

}

Delete Apartment

GET /api/apartments/deleteApartment/?id=${id}

Headers

Name
Type
Description

Authorization

string

Authentication Token

{
    success: true,
    message: Apartment deleted
}
or
{
     success: false,
     message: 'unable to delete  apartment ,id provided didnt match ',
}

Last updated

Was this helpful?