Skip to content

Commit

Permalink
Merge pull request #231 from COS301-SE-2024/chore/backend/get-rooms/b…
Browse files Browse the repository at this point in the history
…ooking-endpoint

chore: rewrote some backend logix and added some new endpoints
  • Loading branch information
waveyboym authored Jul 19, 2024
2 parents d932c83 + 8349383 commit 567228a
Show file tree
Hide file tree
Showing 9 changed files with 574 additions and 265 deletions.
73 changes: 67 additions & 6 deletions documentation/occupi-docs/pages/api-documentation/api-usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ The API also allows you to retrieve information about these resources.
- [Base URL](#base-url)
- [Api](#api)
- [Resources](#resources)
- [BookRoom](#BookRoom)
- [ViewBookings](#ViewBookings)
- [CancelBooking](#CancelBooking)
- [CheckIn](#CheckIn)
- [Book Room](#BookRoom)
- [View Bookings](#ViewBookings)
- [View Rooms](#ViewRooms)
- [Cancel Booking](#CancelBooking)
- [Check In](#CheckIn)
- [Get Users](#Get-users)
- [Get Notifications](#Get-notifications)
- [Get push tokens](#Get-push-tokens)
- [UpdateSecuritySettings](#UpdateSecuritySettings)
- [Get User Details](#GetUserDetails)
- [Update User Details](#UpdateUserDetails)
- [Get Security Settings](#GetSecuritySettings)
- [Update Notification Settings](#UpdateNotificationSettings)
- [Get Notification Settings](#GetNotificationSettings)

## Api

Expand Down Expand Up @@ -127,8 +133,63 @@ If there are any errors during the process, appropriate error messages are retur
- **Content**

```json copy
{
"emails": "string"
{
"operator": "eq", // eq, ne, gt, gte, lt, lte, in, nin default to eq
"filter": {
"email": "[email protected]" // the email is required
},
"order_asc": "creator", // column to sort in ascending order
"order_desc": "floor", // column to sort in descending order
"projection": ["floor"], // this is which columns you want returned
"limit": 50, // default is 50 and is the maximum
"page": 1 // default is 1, but can be incremented to get the next page
}
```

**Success Response**

- **Code:** 200
- **Content:** `{ "status": 200, "message": "Successfully fetched bookings!", "data": null }`

**Error Response**

- **Code:** 400
- **Content:** `{ "status": 400, "message": "Invalid request payload", "error": {"code":"BAD_REQUEST","details":null,"message":"Expected Email Address"}, }`


**Error Response**

- **Code:** 500
- **Content:** `{ "status": 500, "message": "Failed to get bookings", "error": {"code":"INTERNAL_SERVER_ERROR","details":"Failed to get bookings","message":"Failed to get bookings"} }`

### View Rooms

This endpoint is used to view all rooms in the Occupi system.
Upon a successful request, a list of all rooms is returned.

- **URL**

`/api/view-rooms`

- **Method**

`GET`

- **Request Body**

- **Content**

```json copy
{
"operator": "eq", // eq, ne, gt, gte, lt, lte, in, nin default to eq
"filter": {
"floorNo": 3 // this is a filter to filter by
},
"order_asc": "description", // column to sort in ascending order
"order_desc": "floor", // column to sort in descending order
"projection": ["floor"], // this is which columns you want returned
"limit": 50, // default is 50 and is the maximum
"page": 1 // default is 1, but can be incremented to get the next page
}
```

Expand Down
2 changes: 2 additions & 0 deletions occupi-backend/pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ const (
ChangePassword = "changePassword"
ChangeEmail = "changeEmail"
ConfirmIPAddress = "confirmIPAddress"
Off = "off"
On = "on"
)
Loading

0 comments on commit 567228a

Please sign in to comment.