TimelineController - adkuba/TL-backend GitHub Wiki
- Create timeline
- Create timelines
- Add pictures
- Add pictures url
- Like timeline
- Make active
- Dislike timeline
- Delete main timeline
- Delete user timelines
- Get reported
- Get user timelines
- Get homepage special
- Homepage timelines
- Get timeline by id
- Get timeline by id editor
- Report timeline
- Unreport timeline
- Premium view
- Get timeline by event id
- Search timelines
- Get all timelines
Path
POST /api/timelines
Request Body
{
"id": "kubatl",
"user": Object, #DBRef
"premium": false,
"active": true, #2 timelines limit for free users
"description": "my timeline desc",
"descriptionTitle": "My projects",
"eventId": "eehdd34", # not null if sub-timeline
"pictures": null, #List of FileResource
"viewsDetails": null, #Map<LocalDate, Map<String, Long>> desc below
"views": 7365, #long
"trendingViews": 6354 #long
"reported": false,
"numberOfReports": 0, #long
"premiumViews": 34, #boost from premium section
"creationDate": 2020-09-16, #localDate
"likes": null, #list of InteractionEvent
}
User, FileResource, InteractionEvent
viewsDetails = date, ( object -> deviceid, number-of-views)
Request params
Parameter | Type | Description |
---|---|---|
findUser |
Boolean | find user that sends timeline by jwt token |
withDelete |
Boolean | first delete existing timeline (editing) |
add |
Boolean | true if first time saving timeline |
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | timeline created |
400 Bad Request | error |
Returns created timeline.
Saves multiple timelines, usefull when adding sub-timelines.
Path
POST /api/timelines/multiple
Request body
List<Timeline>
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | timelines created |
400 Bad Request | error |
Returns List<TimelineResponse>.
Path
POST /api/timelines/{id}/pictures
Path variable
Variable | Type | Description |
---|---|---|
id |
String | timeline's id |
Request param
Parameter | Type | Description |
---|---|---|
pictures |
List<MultipartFile> | images to add |
consumes "multipart/form-data"
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | images added to timeline |
400 Bad Request | error |
Returns timeline with added pictures. Pictures are now in Google Storage and parsed to URL link in response.
Links already uploaded pictures to timeline. Usefull during timeline edit.
Path
POST /api/timelines/{id}/picturesURL
Path variable
Variable | Type | Description |
---|---|---|
id |
String | timeline's id |
Request param
Parameter | Type | Description |
---|---|---|
picturesURL |
List<String> | imagesURL to add |
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | images added to timeline |
400 Bad Request | error |
Returns timeline with added pictures.
Based on jwt token username likes selected timeline.
Path
POST /api/timelines/{id}/like
Path variable
Variable | Type | Description |
---|---|---|
id |
String | timeline's id |
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | timeline liked |
400 Bad Request | error |
Returns new list of likes for the user.
User can select which timeline should be active if number of timelines exeeds 2 on free account. Case when switching from premium to free.
Path
POST /api/timelines/make-active
Request body
Parameter | Type | Description |
---|---|---|
active |
List<String> | list of to be activated timelines (max 2) |
Based on jwt token checks if sending user is owner.
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | timelines activated |
400 Bad Request | error |
Path
POST /api/timelines/{id}/dislike
Path variable
Variable | Type | Description |
---|---|---|
id |
String | timeline's id |
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | timeline disliked |
400 Bad Request | error |
Returns new list of likes for the user.
Deletes master timeline with all events and sub-timelines.
Path
DELETE /api/timelines/{id}
Path variable
Variable | Type | Description |
---|---|---|
id |
String | timeline's id |
Request param
Parameter | Type | Description |
---|---|---|
reason |
String | optional message if admin deletes timeline due to regulations validation |
Response
HTTP Status Code | Scenario |
---|---|
204 No Content | timeline deleted |
400 Bad Request | error |
Deletes all user timelines - blocking user.
Requires "ROLE_ADMIN"
Path
DELETE /api/timelines
Request param
Parameter | Type | Description |
---|---|---|
username |
String | user's username |
Response
HTTP Status Code | Scenario |
---|---|
204 No Content | timelines deleted |
Path
GET /api/timelines/get-reported
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | reported timelines returned |
Returns List<TimelineResponse>
Path
GET /api/timelines/public/{username}
Path variable
Variable | Type | Description |
---|---|---|
username |
String | user's username |
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | user timelines returned |
Returns List<TimelineResponse>
Path
GET /api/timelines/public/homepage/special
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | user timelines returned |
400 Bad Request | error |
Returns List<TimelineResponse> or List<UserResponse> for special section on homepage.
Path
POST /api/timelines/public/homepage
Request body
{
"timelinesIDS": [ #list of seen timelines
"kubatl",
"timeline2"
],
"username": "akuba" #requesting user
}
Response
Returns List<TimelineResponse> of yet unseen timelines.
Path
GET /api/timelines/public
Request params
Parameter | Type | Description |
---|---|---|
username |
String | optional, requesting user for views stats |
id |
String | timeline's id |
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | timeline returned |
Returns TimelineResponse
The same as Get timeline by id but returns FullTimelineResponse, for editing timeline.
Path
GET /api/timelines/editor
Path
POST /api/timelines/public/report
Request param
Parameter | Type | Description |
---|---|---|
id |
String | timeline's id |
Response
void
Path
POST /api/timelines/public/un-report
Request param
Parameter | Type | Description |
---|---|---|
id |
String | timeline's id |
Response
void
Increments number of premium views for timeline - view from premium section.
Path
POST /api/timelines/public/premium-view
Request param
Parameter | Type | Description |
---|---|---|
id |
String | timeline's id |
Response
void
Path
GET /api/timelines/public/event
Request param
Parameter | Type | Description |
---|---|---|
eventId |
String | sub-timeline's master event id |
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | sub-timeline returned |
Returns TimelineResponse.
Path
GET /api/timelines/public/search
Request param
Parameter | Type | Description |
---|---|---|
text |
String | searched text |
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | matching timelines returned |
Returns List<TimelineResponse>
Path
GET /api/timelines/all
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | all timelines returned |
Returns List<TimelineResponse> only maser timelines not sub-timelines!