import 'package:cheminova/utils/api_urls.dart'; import 'package:cheminova/utils/common_api_service.dart'; import 'package:cheminova/utils/show_snackbar.dart'; class AuthService { // Function to handle user login Future?> login(Map data) async { try { // Making a POST request to the login URL using the common API service final response = await commonApiService>( url: ApiUrls.loginUrl, method: 'POST', body: data, fromJson: (json) => json, // Simply return the JSON map as is ); return response; } catch (e) { showSnackbar(e.toString()); } return null; } // Function to handle forgot password functionality // Function to handle password change functionality Future?> forgotPassword(Map data) async { try { // Making a POST request to the forgot password URL using the common API service final response = await commonApiService>( url: ApiUrls.forgetPasswordUrl, method: 'POST', body: data, fromJson: (json) => json, // Simply return the JSON map as is ); return response; } catch (e) { showSnackbar(e.toString()); } return null; } // Function to handle password change functionality Future?> changePassword(Map data, {required String token}) async { try { // Making a PUT request to the change password URL using the common API service final response = await commonApiService>( url: ApiUrls.changePasswordUrl, method: 'PUT', body: data, fromJson: (json) => json, // Simply return the JSON map as is additionalHeaders: { // Pass the token here 'Authorization': 'Bearer $token', }, ); return response; } catch (e) { showSnackbar(e.toString()); } return null; } }