Updated base URL and API endpoint paths in constants and DioClient, and updated UserRepository to use new API endpoint path for logout.

This commit is contained in:
Naresh Pratista 2024-11-09 11:07:10 +07:00
parent 6283e9bf75
commit 7c000d3cd4
3 changed files with 28 additions and 24 deletions

View File

@ -1,2 +1,2 @@
const String baseUrl =
'https://ebdc-2001-448a-50a0-3463-a4de-673f-afb-724b.ngrok-free.app/';
'https://f7fe-2001-448a-50a0-3463-a4de-673f-afb-724b.ngrok-free.app/';

View File

@ -15,7 +15,7 @@ class DioClient {
Future<Response> refreshAccessToken(String refreshToken) async {
try {
final response = await _dio.post(
'/refreshToken',
'/api/refreshToken',
data: {'REFRESH_TOKEN': refreshToken},
options: Options(
headers: {
@ -52,7 +52,7 @@ class DioClient {
String id, FormData formData, String token) async {
try {
final response = await _dio.put(
'/user/update/$id',
'/api/user/update/$id',
data: formData,
options: Options(
headers: {
@ -75,7 +75,7 @@ class DioClient {
) async {
try {
final response = await _dio.put(
'/user/update/password/$id',
'/api/user/update/password/$id',
data: data,
options: Options(
headers: {
@ -96,12 +96,16 @@ class DioClient {
String token,
) async {
try {
final response = await _dio.post('/report',
final response = await _dio.post(
'/api/report',
data: data,
options: Options(headers: {
options: Options(
headers: {
'Authorization': 'Bearer $token',
'Content-Type': 'application/json',
}));
},
),
);
return response;
} catch (e) {
print('Update Password error: $e');
@ -113,7 +117,7 @@ class DioClient {
try {
// Send POST request to the registration endpoint
final response = await _dio.post(
'/register/student',
'/api/register/student',
data: data,
options: Options(
headers: {
@ -131,7 +135,7 @@ class DioClient {
Future<Response> loginStudent(Map<String, dynamic> data) async {
try {
final response = await _dio.post(
'/login',
'/api/login',
data: data,
options: Options(
headers: {
@ -148,7 +152,7 @@ class DioClient {
Future<Response> forgotPassword(Map<String, dynamic> data) async {
try {
final response = await _dio.post(
'/forgotPassword',
'/api/forgotPassword',
data: data,
options: Options(
headers: {
@ -166,7 +170,7 @@ class DioClient {
try {
print('Sending getMe request with token: Bearer $token');
final response = await _dio.get(
'/getMe',
'/api/getMe',
options: Options(
headers: {
'Authorization': 'Bearer $token', // Add 'Bearer ' prefix here
@ -184,7 +188,7 @@ class DioClient {
Future<Response> getSections(String token) async {
try {
final response = await _dio.get(
'/section',
'/api/section',
options: Options(
headers: {
'Authorization': 'Bearer $token',
@ -203,7 +207,7 @@ class DioClient {
Future<Response> getTopics(String sectionId, String token) async {
try {
final response = await _dio.get(
'/topic/section/$sectionId',
'/api/topic/section/$sectionId',
options: Options(
headers: {
'Authorization': 'Bearer $token',
@ -222,7 +226,7 @@ class DioClient {
Future<Response> getLevels(String topicsId, String token) async {
try {
final response = await _dio.get(
'/level/topic/$topicsId',
'/api/level/topic/$topicsId',
options: Options(
headers: {
'Authorization': 'Bearer $token',
@ -241,7 +245,7 @@ class DioClient {
Future<Response> createStudentLearning(String idLevel, String token) async {
try {
final response = await _dio.post(
'/stdLearning',
'/api/stdLearning',
data: {'ID_LEVEL': idLevel},
options: Options(
headers: {
@ -260,7 +264,7 @@ class DioClient {
Future<Response> getExercises(String levelId, String token) async {
try {
final response = await _dio.get(
'/exercise/level/$levelId',
'/api/exercise/level/$levelId',
options: Options(
headers: {
'Authorization': 'Bearer $token',
@ -284,7 +288,7 @@ class DioClient {
List<Map<String, dynamic>> answers, String token) async {
try {
final response = await _dio.post(
'/stdExercise',
'/api/stdExercise',
data: {'answers': answers},
options: Options(
headers: {
@ -304,7 +308,7 @@ class DioClient {
Future<Response> getScore(String stdLearningId, String token) async {
try {
final response = await _dio.get(
'/stdLearning/score/$stdLearningId',
'/api/stdLearning/score/$stdLearningId',
options: Options(
headers: {
'Authorization': 'Bearer $token',
@ -328,7 +332,7 @@ class DioClient {
}) async {
try {
final response = await _dio.get(
'/learningHistory/section/$sectionId',
'/api/learningHistory/section/$sectionId',
queryParameters: {
'page': page,
'limit': limit,
@ -351,7 +355,7 @@ class DioClient {
Future<Response> getCompletedTopics(String token) async {
try {
final response = await _dio.get(
'/topic/complete',
'/api/topic/complete',
options: Options(
headers: {
'Authorization': 'Bearer $token',
@ -374,7 +378,7 @@ class DioClient {
) async {
try {
final response = await _dio.put(
'/stdLearning/$stdLearningId',
'/api/stdLearning/$stdLearningId',
data: {'FEEDBACK_STUDENT': feedback},
options: Options(
headers: {
@ -393,7 +397,7 @@ class DioClient {
Future<Response> getStudentAnswers(String stdLearningId, String token) async {
try {
final response = await _dio.get(
'/studentAnswers/$stdLearningId',
'/api/studentAnswers/$stdLearningId',
options: Options(
headers: {
'Authorization': 'Bearer $token',

View File

@ -18,7 +18,7 @@ class UserRepository {
}
Future<Response> logoutUser() async {
return await dioClient.post('/logout');
return await dioClient.post('/api/logout');
}
Future<Response> forgotPassword(String email) async {