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
Get Apartments

/api/apartments
Request
Response
Request
Headers
Authorization
optional
string
Authentication token
Response
200: OK
{
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: []
}
404: Not Found
{
success: false,
message: 'error while finding apartments for the user',
}

post
Create Apartment (Flat)

/api/apartments
Request
Response
Request
Headers
Authorization
required
string
Authentication Token
Body Parameters
userId
optional
string
User Id
address
optional
string
address of the locality of flat
gpsLoc
optional
array
location array [lat, lng]
availableFrom
optional
string
date from flat is available
houseSize
optional
string
size of the flat
spaceFor
optional
number
space for how many members
monthlyRent
optional
number
monthly rent
oneTimeDeposit
optional
number
one time deposit
occupancyType
optional
string
occupancy type
amenities
optional
array
amenities array
pictures
optional
array
pictures array
description
optional
string
Description
Response
200: OK
{
success: true,
message: 'apartment created successfully',
data: {
userId
address
gpsLoc
availableFrom
houseSize
spaceFor
monthlyRent
oneTimeDeposit
occupancyType
amenities
pictures
description
}
}

put
Update Apartment

/api/apartments/?id=${_id}
Request
Response
Request
Headers
updateObj
optional
object
updateObj contains type of the details to be modified and details obj.
Authorization
required
string
Authentication Token
Response
200: OK
{
userId
address
gpsLoc
availableFrom
houseSize
spaceFor
monthlyRent
oneTimeDeposit
occupancyType
amenities
pictures
description
}
304: Not Modified
Error occured while updating the apartment details
404: Not Found
Error occured while searching for the Apartment

get
Get filtered Apartments

/api/apartments/filterdApartments
Request
Response
Request
Headers
filterObject
optional
object
Contains the filter details
Authorization
optional
string
Authentication Token
Response
200: OK
{
success: true,
message: 'filtered apartments',
data: filteredApartments
}
or
{
success: true,
message: 'no apartments with this filter options available',
data: []
}

get
Delete Apartment

/api/apartments/deleteApartment/?id=${id}
Request
Response
Request
Headers
Authorization
required
string
Authentication Token
Response
200: OK
{
success: true,
message: Apartment deleted
}
or
{
success: false,
message: 'unable to delete apartment ,id provided didnt match ',
}