This repository has been archived by the owner on Jan 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from fictadvisor/user_api
User api
- Loading branch information
Showing
27 changed files
with
755 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/fictadvisor/android/data/dto/user/AddContactBody.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class AddContactBody( | ||
val name: ContactType, | ||
val displayName: String, | ||
val link: String | ||
) |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/fictadvisor/android/data/dto/user/ChangeAvatarResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class ChangeAvatarResponse( | ||
val id: String, | ||
val email: String, | ||
val username: String, | ||
val telegramId: Long, | ||
val avatar: String, | ||
val state: UserGroupState | ||
) |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/fictadvisor/android/data/dto/user/ChangeInfoBody.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class ChangeInfoBody( | ||
val firstName: String?, | ||
val lastName: String?, | ||
val middleName: String?, | ||
val groupId: String?, | ||
val state: UserGroupState? | ||
) |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/fictadvisor/android/data/dto/user/ChangeRoleBody.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class ChangeRoleBody( | ||
val roleId: String | ||
) |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/fictadvisor/android/data/dto/user/ChangeUserBody.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class ChangeUserBody( | ||
val email: String?, | ||
val username: String?, | ||
val state: UserGroupState? | ||
) |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/fictadvisor/android/data/dto/user/Contact.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class Contact( | ||
val link: String, | ||
val id: String, | ||
val name: ContactType, | ||
val displayName: String | ||
) |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/fictadvisor/android/data/dto/user/ContactType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
enum class ContactType { | ||
YOUTUBE, | ||
DISCORD, | ||
TELEGRAM, | ||
INSTAGRAM, | ||
FACEBOOK, | ||
GITHUB, | ||
TWITTER, | ||
} |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/fictadvisor/android/data/dto/user/GetContactsResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class GetContactsResponse( | ||
val contacts: List<Contact> | ||
) |
5 changes: 5 additions & 0 deletions
5
...n/java/com/fictadvisor/android/data/dto/user/GetSelectiveDisciplinesBySemesterResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class GetSelectiveDisciplinesBySemesterResponse( | ||
val selective: List<UserSelective> | ||
) |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/fictadvisor/android/data/dto/user/GetSelectiveDisciplinesResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class GetSelectiveDisciplinesResponse( | ||
val availableSelectiveAmount: Int, | ||
val year: Int, | ||
val semester: Int, | ||
val remainingSelective: List<UserRemainingSelective> | ||
) |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/fictadvisor/android/data/dto/user/GetSelectiveResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class GetSelectiveResponse( | ||
val disciplines: List<String> | ||
) |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/fictadvisor/android/data/dto/user/PostSelectiveDisciplinesBody.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class PostSelectiveDisciplinesBody( | ||
val disciplines: List<String> | ||
) |
6 changes: 6 additions & 0 deletions
6
app/src/main/java/com/fictadvisor/android/data/dto/user/RequestNewGroupBody.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class RequestNewGroupBody( | ||
val groupId: String, | ||
val isCaptain: Boolean | ||
) |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/fictadvisor/android/data/dto/user/SimplifiedUser.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class SimplifiedUser( | ||
val id: String, | ||
val email: String, | ||
val username: String, | ||
val telegramId: Long?, | ||
val avatar: String?, | ||
val state: UserGroupState | ||
) |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/fictadvisor/android/data/dto/user/UserDTOResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class UserDTOResponse( | ||
val id: String, | ||
val firstName: String, | ||
val middleName: String, | ||
val lastName: String, | ||
val state: UserGroupState, | ||
val username: String, | ||
val email: String, | ||
val avatar: String, | ||
val telegramId: Long, | ||
val group: UserGroup | ||
) |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/fictadvisor/android/data/dto/user/UserGroup.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class UserGroup( | ||
val id: String, | ||
val code: String, | ||
val role: UserGroupRole?, | ||
val state: UserGroupState | ||
) |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/fictadvisor/android/data/dto/user/UserGroupRole.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
enum class UserGroupRole { | ||
CAPTAIN, | ||
MODERATOR, | ||
STUDENT | ||
} |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/fictadvisor/android/data/dto/user/UserGroupState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
enum class UserGroupState { | ||
APPROVED, | ||
DECLINED, | ||
PENDING | ||
} |
6 changes: 6 additions & 0 deletions
6
app/src/main/java/com/fictadvisor/android/data/dto/user/UserRemainingSelective.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class UserRemainingSelective( | ||
val disciplineId: String, | ||
val subjectName: String | ||
) |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/fictadvisor/android/data/dto/user/UserSelective.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class UserSelective( | ||
val semester: Int, | ||
val year: Int, | ||
val disciplines: List<String>, | ||
val amount: Int | ||
) |
6 changes: 6 additions & 0 deletions
6
app/src/main/java/com/fictadvisor/android/data/dto/user/VerifyStudentBody.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class VerifyStudentBody( | ||
val state: UserGroupState, | ||
val isCaptain: Boolean | ||
) |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/fictadvisor/android/data/dto/user/VerifyStudentResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.fictadvisor.android.data.dto.user | ||
|
||
data class VerifyStudentResponse( | ||
val students: List<UserDTOResponse> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
app/src/main/java/com/fictadvisor/android/data/remote/api/UserApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
package com.fictadvisor.android.data.remote.api | ||
|
||
import com.fictadvisor.android.data.dto.TelegramDTO | ||
import com.fictadvisor.android.data.dto.user.AddContactBody | ||
import com.fictadvisor.android.data.dto.user.ChangeAvatarResponse | ||
import com.fictadvisor.android.data.dto.user.ChangeInfoBody | ||
import com.fictadvisor.android.data.dto.user.UserDTOResponse | ||
import com.fictadvisor.android.data.dto.user.ChangeRoleBody | ||
import com.fictadvisor.android.data.dto.user.ChangeUserBody | ||
import com.fictadvisor.android.data.dto.user.Contact | ||
import com.fictadvisor.android.data.dto.user.GetContactsResponse | ||
import com.fictadvisor.android.data.dto.user.GetSelectiveDisciplinesBySemesterResponse | ||
import com.fictadvisor.android.data.dto.user.GetSelectiveDisciplinesResponse | ||
import com.fictadvisor.android.data.dto.user.GetSelectiveResponse | ||
import com.fictadvisor.android.data.dto.user.PostSelectiveDisciplinesBody | ||
import com.fictadvisor.android.data.dto.user.RequestNewGroupBody | ||
import com.fictadvisor.android.data.dto.user.SimplifiedUser | ||
import com.fictadvisor.android.data.dto.user.VerifyStudentBody | ||
import com.fictadvisor.android.data.dto.user.VerifyStudentResponse | ||
import okhttp3.MultipartBody | ||
import okhttp3.ResponseBody | ||
import retrofit2.Response | ||
import retrofit2.http.Body | ||
import retrofit2.http.DELETE | ||
import retrofit2.http.GET | ||
import retrofit2.http.Header | ||
import retrofit2.http.Multipart | ||
import retrofit2.http.PATCH | ||
import retrofit2.http.POST | ||
import retrofit2.http.Part | ||
import retrofit2.http.Path | ||
import retrofit2.http.Query | ||
|
||
interface UserApi { | ||
@GET("/v2/users/{userId}") | ||
suspend fun getUser( | ||
@Header("Authorization") token: String, | ||
@Path("userId") userId: String | ||
): Response<SimplifiedUser> | ||
|
||
@PATCH("/v2/users/{userId}") | ||
suspend fun editUser( | ||
@Header("Authorization") token: String, | ||
@Path("userId") userId: String, | ||
@Body body: ChangeUserBody | ||
): Response<SimplifiedUser> | ||
|
||
@PATCH("/v2/users/{userId}/student") | ||
suspend fun changeInfo( | ||
@Header("Authorization") token: String, | ||
@Path("userId") userId: String, | ||
@Body body: ChangeInfoBody | ||
): Response<UserDTOResponse> | ||
|
||
@POST("/v2/users/{userId}/telegram") | ||
suspend fun linkTelegram( | ||
@Header("Authorization") token: String, | ||
@Path("userId") userId: String, | ||
@Body body: TelegramDTO | ||
): Response<UserDTOResponse> | ||
|
||
@POST("/v2/users/{userId}/contacts") | ||
suspend fun addContact( | ||
@Header("Authorization") token: String, | ||
@Path("userId") userId: String, | ||
@Body body: AddContactBody | ||
): Response<Contact> | ||
|
||
@GET("/v2/users/{userId}/contacts") | ||
suspend fun getContacts( | ||
@Header("Authorization") token: String, | ||
@Path("userId") userId: String | ||
): Response<GetContactsResponse> | ||
|
||
@DELETE("/v2/users/{userId}/contacts/{id}") | ||
suspend fun deleteContact( | ||
@Header("Authorization") token: String, | ||
@Path("userId") userId: String, | ||
@Path("id") id: String | ||
): Response<ResponseBody> | ||
|
||
@PATCH("/v2/users/{userId}/requestNewGroup") | ||
suspend fun requestNewGroup( | ||
@Header("Authorization") token: String, | ||
@Path("userId") userId: String, | ||
@Body body: RequestNewGroupBody | ||
): Response<ResponseBody> | ||
|
||
@GET("/v2/users/{userId}/selectiveBySemesters") | ||
suspend fun getSelectiveDisciplinesBySemester( | ||
@Header("Authorization") token: String, | ||
@Path("userId") userId: String | ||
): Response<GetSelectiveDisciplinesBySemesterResponse> | ||
|
||
@POST("/v2/users/{userId}/selectiveDisciplines") | ||
suspend fun postSelectiveDisciplines( | ||
@Header("Authorization") token: String, | ||
@Path("userId") userId: String, | ||
@Body body: PostSelectiveDisciplinesBody | ||
): Response<ResponseBody> | ||
|
||
@GET("/v2/users/{userId}/selectiveDisciplines") | ||
suspend fun getSelectiveDisciplines( | ||
@Header("Authorization") token: String, | ||
@Path("userId") userId: String, | ||
@Query("year") year: Int, | ||
@Query("semester") semester: Int | ||
): Response<GetSelectiveDisciplinesResponse> | ||
|
||
@Multipart | ||
@PATCH("/v2/users/{userId}/") | ||
suspend fun changeAvatar( | ||
@Header("Authorization") token: String, | ||
@Path("userId") userId: String, | ||
@Part avatar: MultipartBody.Part | ||
): Response<ChangeAvatarResponse> | ||
|
||
@POST("/v2/users/{userId}/roles") | ||
suspend fun setRole( | ||
@Header("Authorization") token: String, | ||
@Path("userId") userId: String, | ||
@Body body: ChangeRoleBody | ||
): Response<ResponseBody> | ||
|
||
@GET("/v2/users/{userId}/selective") | ||
suspend fun getSelective( | ||
@Header("Authorization") token: String, | ||
@Path("userId") userId: String | ||
): Response<GetSelectiveResponse> | ||
|
||
@PATCH("/v2/users/{userId}/verifyStudent") | ||
suspend fun verifyStudent( | ||
@Header("Authorization") token: String, | ||
@Path("userId") userId: String, | ||
@Body body: VerifyStudentBody | ||
): Response<VerifyStudentResponse> | ||
} |
Oops, something went wrong.