@@ -8,12 +8,7 @@ import '../models/user.dart';
88import '../models/user_profile.dart' ;
99
1010class UserRepository {
11- static void init () => instance = UserRepository ();
12-
13- // Instance
14- static late final UserRepository instance;
15-
16- Future <bool > isEmailAvailable (String email) async {
11+ static Future <bool > isEmailAvailable (String email) async {
1712 final endpoint = 'user/available?email=$email ' ;
1813
1914 final response = await ApiService .post (
@@ -23,7 +18,7 @@ class UserRepository {
2318 return response['status_code' ] == 200 ;
2419 }
2520
26- Future <bool > isUsernameAvailable (String username) async {
21+ static Future <bool > isUsernameAvailable (String username) async {
2722 final endpoint = 'user/available?username=$username ' ;
2823
2924 final response = await ApiService .post (
@@ -33,7 +28,7 @@ class UserRepository {
3328 return response['status_code' ] == 200 ;
3429 }
3530
36- Future <String ?> signUp (SignUp details) async {
31+ static Future <String ?> signUp (SignUp details) async {
3732 const endpoint = 'user/signup' ;
3833 final data = {...details.toJson (), ...details.handle? .toJson () ?? {}}
3934 ..remove ('handle' );
@@ -48,7 +43,7 @@ class UserRepository {
4843 }
4944 }
5045
51- Future <String ?> login (String username, String password) async {
46+ static Future <String ?> login (String username, String password) async {
5247 const endpoint = 'user/login' ;
5348
5449 final response = await ApiService .post (
@@ -64,11 +59,11 @@ class UserRepository {
6459 }
6560 }
6661
67- Future <bool > logout () async {
62+ static Future <bool > logout () async {
6863 const endpoint = 'user/logout' ;
6964 final headers = < String , dynamic > {};
7065
71- await ApiService .addTokenToHeaders (headers);
66+ ApiService .addTokenToHeaders (headers);
7267 final response = await ApiService .post (
7368 endpoint,
7469 headers: headers,
@@ -77,7 +72,7 @@ class UserRepository {
7772 return response['status_code' ] == 200 ;
7873 }
7974
80- Future <bool > sendVerifyEmail (String uid) async {
75+ static Future <bool > sendVerifyEmail (String uid) async {
8176 final endpoint = 'user/send-verify-email/$uid ' ;
8277
8378 final response = await ApiService .post (
@@ -87,7 +82,7 @@ class UserRepository {
8782 return response['status_code' ] == 200 ;
8883 }
8984
90- Future <bool > resetPassword (String email) async {
85+ static Future <bool > resetPassword (String email) async {
9186 const endpoint = 'user/password-reset-email' ;
9287
9388 final response = await ApiService .post (
@@ -98,11 +93,11 @@ class UserRepository {
9893 return response['status_code' ] == 200 ;
9994 }
10095
101- Future <int > followUser (String uid) async {
96+ static Future <int > followUser (String uid) async {
10297 final endpoint = 'friends/follow?uid2=$uid ' ;
10398 final headers = < String , dynamic > {};
10499
105- await ApiService .addTokenToHeaders (headers);
100+ ApiService .addTokenToHeaders (headers);
106101 final response = await ApiService .post (
107102 endpoint,
108103 headers: headers,
@@ -111,11 +106,11 @@ class UserRepository {
111106 return response['status_code' ];
112107 }
113108
114- Future <int > unfollowUser (String uid) async {
109+ static Future <int > unfollowUser (String uid) async {
115110 final endpoint = 'friends/unfollow?uid2=$uid ' ;
116111 final headers = < String , dynamic > {};
117112
118- await ApiService .addTokenToHeaders (headers);
113+ ApiService .addTokenToHeaders (headers);
119114 final response = await ApiService .post (
120115 endpoint,
121116 headers: headers,
@@ -124,11 +119,11 @@ class UserRepository {
124119 return response['status_code' ];
125120 }
126121
127- Future <List <Following >?> getFollowingList () async {
122+ static Future <List <Following >?> getFollowingList () async {
128123 const endpoint = 'friends/following' ;
129124 final headers = < String , dynamic > {};
130125
131- await ApiService .addTokenToHeaders (headers);
126+ ApiService .addTokenToHeaders (headers);
132127 final response = await ApiService .get (
133128 endpoint,
134129 headers: headers,
@@ -141,7 +136,7 @@ class UserRepository {
141136 }
142137 }
143138
144- Future <bool > verifyHandle (String site, String handle) async {
139+ static Future <bool > verifyHandle (String site, String handle) async {
145140 final endpoint = 'user/verify/$site ?handle=$handle ' ;
146141
147142 final response = await ApiService .post (
@@ -151,11 +146,11 @@ class UserRepository {
151146 return response['status_code' ] == 200 ;
152147 }
153148
154- Future <List <User >> search (String query) async {
149+ static Future <List <User >> search (String query) async {
155150 final endpoint = 'user/search?query=$query ' ;
156151 final headers = < String , dynamic > {};
157152
158- await ApiService .addTokenToHeaders (headers);
153+ ApiService .addTokenToHeaders (headers);
159154 final response = await ApiService .get (
160155 endpoint,
161156 headers: headers,
@@ -170,12 +165,12 @@ class UserRepository {
170165 return _users;
171166 }
172167
173- Future <List <String >> getInstituteList () async {
168+ static Future <List <String >> getInstituteList () async {
174169 const endpoint = 'institutes' ;
175170 const baseUrl = 'https://codephile.mdg.iitr.ac.in/' ;
176171 final headers = < String , dynamic > {};
177172
178- await ApiService .addTokenToHeaders (headers);
173+ ApiService .addTokenToHeaders (headers);
179174 final response = await ApiService .get (
180175 endpoint,
181176 baseUrl: baseUrl,
@@ -191,11 +186,12 @@ class UserRepository {
191186 return [];
192187 }
193188
194- Future <List <SubmissionStatus >?> getSubmissionStatusData (String id) async {
189+ static Future <List <SubmissionStatus >?> getSubmissionStatusData (
190+ String id) async {
195191 final endpoint = 'graph/status/$id ' ;
196192 final headers = < String , dynamic > {};
197193
198- await ApiService .addTokenToHeaders (headers);
194+ ApiService .addTokenToHeaders (headers);
199195 final response = await ApiService .get (
200196 endpoint,
201197 headers: headers,
@@ -208,11 +204,14 @@ class UserRepository {
208204 }
209205 }
210206
211- Future <int > updatePassword (String oldPassword, String newPassword) async {
207+ static Future <int > updatePassword (
208+ String oldPassword,
209+ String newPassword,
210+ ) async {
212211 const endpoint = 'user/password-reset' ;
213212 final headers = < String , dynamic > {};
214213
215- await ApiService .addTokenToHeaders (headers);
214+ ApiService .addTokenToHeaders (headers);
216215 final response = await ApiService .post (
217216 endpoint,
218217 headers: headers,
@@ -225,11 +224,11 @@ class UserRepository {
225224 return response['status_code' ];
226225 }
227226
228- Future <int > updateUserDetails (Map <String , dynamic >? data) async {
227+ static Future <int > updateUserDetails (Map <String , dynamic >? data) async {
229228 const endpoint = 'user/' ;
230229 final headers = < String , dynamic > {};
231230
232- await ApiService .addTokenToHeaders (headers);
231+ ApiService .addTokenToHeaders (headers);
233232 final response = await ApiService .post (
234233 endpoint,
235234 headers: headers,
@@ -239,11 +238,11 @@ class UserRepository {
239238 return response['status_code' ];
240239 }
241240
242- Future <User ?> getUser (String uid) async {
241+ static Future <User ?> getUser (String uid) async {
243242 final endpoint = '/user/$uid ' ;
244243 final headers = < String , dynamic > {};
245244
246- await ApiService .addTokenToHeaders (headers);
245+ ApiService .addTokenToHeaders (headers);
247246 final response = await ApiService .get (
248247 endpoint,
249248 headers: headers,
@@ -254,11 +253,11 @@ class UserRepository {
254253 }
255254 }
256255
257- Future <UserProfile ?> getAllPlatformDetails (String uid) async {
256+ static Future <UserProfile ?> getAllPlatformDetails (String uid) async {
258257 final endpoint = '/user/fetch/$uid ' ;
259258 final headers = < String , dynamic > {};
260259
261- await ApiService .addTokenToHeaders (headers);
260+ ApiService .addTokenToHeaders (headers);
262261 final response = await ApiService .get (
263262 endpoint,
264263 headers: headers,
0 commit comments