Skip to content

Instantly share code, notes, and snippets.

@rahul0208
Created January 30, 2020 08:08
Show Gist options
  • Save rahul0208/da0b4abe46143aaa63a865558a13bea4 to your computer and use it in GitHub Desktop.
Save rahul0208/da0b4abe46143aaa63a865558a13bea4 to your computer and use it in GitHub Desktop.
Collab.md
# Collab
We want to build a team calendar to meet the following objectives .
- It should allow a user to create a calendar and share it with multiple users.
- As a user I can add a calendar and control access of different users.
- A user will have different access rights (readonly / write / full-access)
- A user can add / delete /update events in the calendar(s) available.
- When an event is added the calendar should validate if there are overlapping events and should alter the user.
- Each of the calendar is available at a unique URL
- Each calendar can be de-activated by an admin user. The deactivated calendar will not be accessible to the users.
- The application has a browser based UI to which can show the calendar.
The application will have the follwoing entities :
-- Calander :
-- Events
-- Users
## Calander :
Calendar is a first class entity in the system. A calander can have events which are assicicated with different users. Each calander has a location URL which can be used to view the calander. Adiitinally the calander can have backgroud color / background image which can be customised by the user.
### Story 1 :
- Create a GoLang application skeleton for the descibed application.
### Story 2
As a user I should be able to create a Calendar.
> POST /api/calendar
Example request body:
```
{
"name": "Rahul",
“Active” : true,
"color": 7,
"overlap": true,
“attributes” : ["learning"]
}
```
Required fields: `name`, `color`
Optional fields: `active`, `overlap`, `attributes`
Attributes should be saved as lowercase.
Response:
- It will return response code 201 if calander is created successfully
- It will return 400 if validation failed
- It will return 500 if anything else happened
- It will return created article as shown below.
```
{
"id": 3619812,
"name": "Rahul",
"active": true,
"color": 7,
"overlap": true,
"attributes": ["learning"],
"creation_dt": "2017-08-16T09:06:09+00:00",
"location"
"update_dt": null,
}
```
### Story 3
Get a calander
> GET /api/calander/:calanderid
Response:
- It will return response code 200 with calander details
```
{
"id": 3619812,
"name": "Rahul",
"active": true,
"color": 7,
"overlap": true,
"attributes": ["learning"],
"creation_dt": "2017-08-16T09:06:09+00:00",
"location"
"update_dt": null,
}
```
### Story 4
Update a calander
> PATCH /api/calander/:calanderid
Example of request body
```
{
"name": "Rahul",
“Active” : true,
"color": 7,
"overlap": true,
“attributes” : ["learning"]
}
```
Response:
- It will return response code 200 with the updated calander
```
{
"id": 3619812,
"name": "Rahul",
"active": true,
"color": 7,
"overlap": true,
"attributes": ["learning"],
"creation_dt": "2017-08-16T09:06:09+00:00",
"location"
"update_dt": "2017-08-16T09:06:09+00:00",
}
```
### Story 5 :
Delete a calander
> DELETE /api/calander/:calanderid
Response:
- It will return response code 204 with empty response
### Story 6 :
Find the random image using the Unsplash API and make it background image of the calander
We want to add functionality to our API where we want to randomly assign image to our calander.
Go to this https://source.unsplash.com/ to learn how to find random image. Save that in the image field of the calander.
```
{
"id": 3619812,
"name": "Rahul",
"active": true,
"color": 7,
"overlap": true,
"attributes": ["learning"],
"creation_dt": "2017-08-16T09:06:09+00:00",
"location"
"update_dt": "2017-08-16T09:06:09+00:00",
"image": "https://images.unsplash.com/photo-1575931140251-cefba6c2b4e9?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max",
}
```
## Events
The following table documents the attributes of a calendar event. Please note that some event attributes are read-only while others are update-only. Read-only attributes are returned in server responses but do not need to be submitted in requests. Update-only attributes need to be submitted in requests but are not returned in server responses. The notes below the table give more details.
### Story 1 :
Create a new calendar event.
HTTP Request
> POST /:calendarId/events
Example of request body
```
{
"start_dt": "2020-06-17T06:00:00-0400",
"end_dt": "2020-06-17T07:00:00-0400",
"all_day": false,
"title": "Demo Event",
"who": "",
"location": "",
"notes": ""
}
```
Response:
- It will return response code 201 with event response
```
{
"id": "123",
"subcalendar_id": 730624,
"start_dt": "2015-06-17T06:00:00-0400",
"end_dt": "2015-06-17T07:00:00-0400",
"all_day": false,
"title": "Demo Event",
"who": "",
"location": "",
"notes": "",
"version": "556db1f949aa6",
"creation_dt": "2015-06-02T13:39:05+0000",
"update_dt": null,
}
```
### Story 2
Get an existing Calander Event
> GET /:calanderId/events/:eventId
Response:
- It will return response code 200 with event response
### Story 3
Get all calander events in the date range
> GET /:calanderId/events
Query Parameters
`startDate` date today Optional. The start of the date range to list events from, in YYYY-MM-DD format
`endDate` date today +1 day Optional. The end of the date range to list events from (inclusive), in YYYY-MM-DD format
Response:
- It will return response code 200 with event response collection
```
[{
"id": "123",
"subcalendar_id": 730624,
"start_dt": "2015-06-17T06:00:00-0400",
"end_dt": "2015-06-17T07:00:00-0400",
"all_day": false,
"title": "Demo Event",
"who": "",
"location": "",
"notes": "",
"version": "556db1f949aa6",
"creation_dt": "2015-06-02T13:39:05+0000",
"update_dt": null,
}]
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment