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

View File

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