Class ProfileSearchController
- java.lang.Object
-
- in.cs699.tensors.delagram.profile_search_service.controller.ProfileSearchController
-
@RestController @RequestMapping("/search-api") @CrossOrigin("http://localhost:3000") public class ProfileSearchController extends Object
This controller defines an end-point to search for a user, and add a user to your circle.- Author:
- swaroop_nath
-
-
Constructor Summary
Constructors Constructor Description ProfileSearchController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
bindUsersInCircle(String authorizationToken, Map<String,Object> payload)
This end-point lets a user add another user in their circle.User
getUserByID(String authorizationToken, Map<String,Object> payload)
This end-point lets a user search another user by user-id.
-
-
-
Method Detail
-
getUserByID
@PostMapping("/search-by-id") public User getUserByID(@RequestHeader("authorization") String authorizationToken, @RequestBody Map<String,Object> payload) throws AuthorizationFailedException, AuthenticationFailedException, SearchFailedException, UserDoesNotExistException
This end-point lets a user search another user by user-id.- Parameters:
authorizationToken
- The firebase token/JWT that identifies the user.payload
- The payload with the request. It must include the id of the user to be searched and the currently logged in user.- Returns:
- Returns the user, if found.
- Throws:
AuthorizationFailedException
- Thrown in case the JWT doesn't represent the said user.AuthenticationFailedException
- Thrown in case JWT isn't valid.SearchFailedException
- Thrown in case the search couldn't be done.UserDoesNotExistException
- Thrown in case the user was not found.
-
bindUsersInCircle
@PostMapping("/add-in-circle") public boolean bindUsersInCircle(@RequestHeader("authorization") String authorizationToken, @RequestBody Map<String,Object> payload) throws InternalServerException, UserNotAddedToCircleException
This end-point lets a user add another user in their circle.- Parameters:
authorizationToken
- The firebase token/JWT that identifies the user.payload
- The payload with the request. It must include the user ids of both the users.- Returns:
- Returns true if the addition in circle operation was successful.
- Throws:
InternalServerException
- Thrown in case there is any internal server error.UserNotAddedToCircleException
- Thrown in case the user couldn't be added to the circle.
-
-