Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit 58aa5f0

Browse files
committed
added repository and ViewModel for user api
1 parent fb93827 commit 58aa5f0

File tree

3 files changed

+448
-0
lines changed

3 files changed

+448
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package com.fictadvisor.android.repository
2+
3+
import com.fictadvisor.android.data.dto.TelegramDTO
4+
import com.fictadvisor.android.data.dto.user.AddContactBody
5+
import com.fictadvisor.android.data.dto.user.ChangeAvatarResponse
6+
import com.fictadvisor.android.data.dto.user.ChangeInfoBody
7+
import com.fictadvisor.android.data.dto.user.ChangeRoleBody
8+
import com.fictadvisor.android.data.dto.user.ChangeUserBody
9+
import com.fictadvisor.android.data.dto.user.Contact
10+
import com.fictadvisor.android.data.dto.user.GetContactsResponse
11+
import com.fictadvisor.android.data.dto.user.GetSelectiveDisciplinesBySemesterResponse
12+
import com.fictadvisor.android.data.dto.user.GetSelectiveDisciplinesResponse
13+
import com.fictadvisor.android.data.dto.user.GetSelectiveResponse
14+
import com.fictadvisor.android.data.dto.user.PostSelectiveDisciplinesBody
15+
import com.fictadvisor.android.data.dto.user.RequestNewGroupBody
16+
import com.fictadvisor.android.data.dto.user.SimplifiedUser
17+
import com.fictadvisor.android.data.dto.user.UserDTOResponse
18+
import com.fictadvisor.android.data.dto.user.VerifyStudentBody
19+
import com.fictadvisor.android.data.dto.user.VerifyStudentResponse
20+
import com.fictadvisor.android.data.remote.RetrofitClient
21+
import okhttp3.MultipartBody
22+
import okhttp3.ResponseBody
23+
import retrofit2.Response
24+
25+
class UserRepository {
26+
27+
private val userService = RetrofitClient.userApi
28+
29+
suspend fun getUser(token: String, userId: String): Response<SimplifiedUser> {
30+
return userService.getUser(token, userId)
31+
}
32+
33+
suspend fun editUser(token: String, userId: String, body: ChangeUserBody): Response<SimplifiedUser> {
34+
return userService.editUser(token, userId, body)
35+
}
36+
37+
suspend fun changeInfo(token: String, userId: String, body: ChangeInfoBody): Response<UserDTOResponse> {
38+
return userService.changeInfo(token, userId, body)
39+
}
40+
41+
suspend fun linkTelegram(token: String, userId: String, body: TelegramDTO): Response<UserDTOResponse> {
42+
return userService.linkTelegram(token, userId, body)
43+
}
44+
45+
suspend fun addContact(token: String, userId: String, body: AddContactBody): Response<Contact> {
46+
return userService.addContact(token, userId, body)
47+
}
48+
49+
suspend fun getContacts(token: String, userId: String): Response<GetContactsResponse> {
50+
return userService.getContacts(token, userId)
51+
}
52+
53+
suspend fun deleteContact(token: String, userId: String, id: String): Response<ResponseBody> {
54+
return userService.deleteContact(token, userId, id)
55+
}
56+
57+
suspend fun requestNewGroup(token: String, userId: String, body: RequestNewGroupBody): Response<ResponseBody> {
58+
return userService.requestNewGroup(token, userId, body)
59+
}
60+
61+
suspend fun getSelectiveDisciplinesBySemester(token: String, userId: String): Response<GetSelectiveDisciplinesBySemesterResponse> {
62+
return userService.getSelectiveDisciplinesBySemester(token, userId)
63+
}
64+
65+
suspend fun postSelectiveDisciplines(token: String, userId: String, body: PostSelectiveDisciplinesBody): Response<ResponseBody> {
66+
return userService.postSelectiveDisciplines(token, userId, body)
67+
}
68+
69+
suspend fun getSelectiveDisciplines(token: String, userId: String, year: Int, semester: Int): Response<GetSelectiveDisciplinesResponse> {
70+
return userService.getSelectiveDisciplines(token, userId, year, semester)
71+
}
72+
73+
suspend fun changeAvatar(token: String, userId: String, avatar: MultipartBody.Part): Response<ChangeAvatarResponse> {
74+
return userService.changeAvatar(token, userId, avatar)
75+
}
76+
77+
suspend fun setRole(token: String, userId: String, body: ChangeRoleBody): Response<ResponseBody> {
78+
return userService.setRole(token, userId, body)
79+
}
80+
81+
suspend fun getSelective(token: String, userId: String): Response<GetSelectiveResponse> {
82+
return userService.getSelective(token, userId)
83+
}
84+
85+
suspend fun verifyStudent(token: String, userId: String, body: VerifyStudentBody): Response<VerifyStudentResponse> {
86+
return userService.verifyStudent(token, userId, body)
87+
}
88+
}

0 commit comments

Comments
 (0)