TimelineController - adkuba/TL-backend GitHub Wiki


Endpoints

Create timeline

Path

POST /api/timelines

Request Body

Timeline

{
    "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.


Create timelines

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>.


Add pictures

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.


Add pictures url

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.


Like timeline

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.


Make active

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

Dislike timeline

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.


Delete main timeline

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

Delete user timelines

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

Get reported

Path

GET /api/timelines/get-reported

Response

HTTP Status Code Scenario
201 Ok reported timelines returned

Returns List<TimelineResponse>


Get user timelines

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>


Get homepage special

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.


Homepage timelines

Path

POST /api/timelines/public/homepage

Request body

Homepage request

{
    "timelinesIDS": [ #list of seen timelines
        "kubatl",
        "timeline2"
    ],
    "username": "akuba" #requesting user
}

Response
Returns List<TimelineResponse> of yet unseen timelines.


Get timeline by id

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


Get timeline by id editor

The same as Get timeline by id but returns FullTimelineResponse, for editing timeline.

Path

GET /api/timelines/editor

Report timeline

Path

POST /api/timelines/public/report

Request param

Parameter Type Description
id String timeline's id

Response
void


Unreport timeline

Path

POST /api/timelines/public/un-report

Request param

Parameter Type Description
id String timeline's id

Response
void


Premium view

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


Get timeline by event id

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.


Search timelines

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>


Get all timelines

Path

GET /api/timelines/all

Response

HTTP Status Code Scenario
201 Ok all timelines returned

Returns List<TimelineResponse> only maser timelines not sub-timelines!

⚠️ **GitHub.com Fallback** ⚠️