Skip to content

Commit

Permalink
Merge pull request #491 from bounswe/feature/mobile-482-request-user-…
Browse files Browse the repository at this point in the history
…role

Request Role Implementation
  • Loading branch information
GulbeycanCagri authored Nov 27, 2023
2 parents 3e90d6b + 7f00242 commit 048b39d
Show file tree
Hide file tree
Showing 3 changed files with 482 additions and 388 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,15 @@ interface ProfileService {
@Query("userId") userId: Int,
@Header("Authorization") jwtToken: String,
@Header("X-Selected-Role") role: String
): Response<UserInfo>
): Response<UserInfoResponse>

@POST("user/requestRole")
suspend fun selectRole(
@Query("userId") userId: Int,
@Query("role") requestedRole: String,
@Header("Authorization") jwtToken: String,
@Header("X-Selected-Role") role: String
): Response<String>


@POST("profile/updateProfile")
Expand All @@ -74,6 +81,7 @@ interface ProfileService {
@Header("X-Selected-Role") role: String,
@Body request: UserInfoRequest
): Response<ResponseBody>

}

class ResqService(appContext: Context) {
Expand Down Expand Up @@ -216,5 +224,18 @@ class ResqService(appContext: Context) {

}

suspend fun selectRole(requestedRole: String): Response<String> {
val userId = userSessionManager.getUserId()
val token = userSessionManager.getUserToken() ?: ""
val role = userSessionManager.getSelectedRole() ?: ""

val response = profileService.selectRole(
userId = userId,
requestedRole = requestedRole,
jwtToken = "Bearer $token",
role = requestedRole
)

return response
}
}
Loading

0 comments on commit 048b39d

Please sign in to comment.