diff --git a/lib/app/data/model/deleteAccount/deleteAccountRequest.dart b/lib/app/data/model/deleteAccount/deleteAccountRequest.dart new file mode 100644 index 0000000..9bb8da0 --- /dev/null +++ b/lib/app/data/model/deleteAccount/deleteAccountRequest.dart @@ -0,0 +1,16 @@ +class DeleteAccountRequest { + String? mobile_number; + + DeleteAccountRequest({this.mobile_number}); + + DeleteAccountRequest.fromJson(Map json) { + mobile_number = json['mobile_number']; + } + + Map toJson() { + final Map data = new Map(); + data['mobile_number'] = this.mobile_number; + + return data; + } +} \ No newline at end of file diff --git a/lib/app/data/remote/user_remote_data_source.dart b/lib/app/data/remote/user_remote_data_source.dart index 7b485ab..52abbfc 100644 --- a/lib/app/data/remote/user_remote_data_source.dart +++ b/lib/app/data/remote/user_remote_data_source.dart @@ -1,3 +1,4 @@ +import 'package:Data4Diabetes/app/data/model/deleteAccount/deleteAccountRequest.dart'; import 'package:Data4Diabetes/app/data/model/dexcom/AccessTokenRequest.dart'; import 'package:Data4Diabetes/app/data/model/dexcom/AccessTokenResponse.dart'; import 'package:Data4Diabetes/app/data/model/dexcom/EstimatedGlucoseValue.dart'; @@ -18,7 +19,7 @@ abstract class UserRemoteDataSource { Future register(RegisterRequest request); Future verifyOTP(VerifyOtpRequest request); Future validateMobileNumber(ValidateMobileNumberRequest request); - Future deleteUserAccount(); + Future deleteUserAccount(DeleteAccountRequest request); Future obtainAccessToken(AccessTokenRequest request); Future evgs(EstimatedGlucoseValueRequest request); } diff --git a/lib/app/data/remote/user_remote_data_source_impl.dart b/lib/app/data/remote/user_remote_data_source_impl.dart index 3e0e5ac..345a0ee 100644 --- a/lib/app/data/remote/user_remote_data_source_impl.dart +++ b/lib/app/data/remote/user_remote_data_source_impl.dart @@ -1,3 +1,4 @@ +import 'package:Data4Diabetes/app/data/model/deleteAccount/deleteAccountRequest.dart'; import 'package:Data4Diabetes/app/data/model/deleteAccount/deleteAccountResponse.dart'; import 'package:Data4Diabetes/app/data/model/dexcom/AccessTokenRequest.dart'; import 'package:Data4Diabetes/app/data/model/dexcom/EstimatedGlucoseValue.dart'; @@ -81,10 +82,10 @@ class UserRemoteDataSourceImpl extends BaseRemoteSource } /// delete user account @override - Future deleteUserAccount() { + Future deleteUserAccount(DeleteAccountRequest request) { var endpoint = "${DioProvider.baseUrl}${ApiEndPoints.deleteAccount}"; - var dioCall = postWithJson(endpoint,isAuthNeeded: true); + var dioCall = postWithJson(endpoint,data: request, isAuthNeeded: true); try { return callApiWithErrorParser(dioCall) diff --git a/lib/app/data/repository/user_repository.dart b/lib/app/data/repository/user_repository.dart index 8976dff..de18b0f 100644 --- a/lib/app/data/repository/user_repository.dart +++ b/lib/app/data/repository/user_repository.dart @@ -1,4 +1,5 @@ +import 'package:Data4Diabetes/app/data/model/deleteAccount/deleteAccountRequest.dart'; import 'package:Data4Diabetes/app/data/model/deleteAccount/deleteAccountResponse.dart'; import 'package:Data4Diabetes/app/data/model/dexcom/AccessTokenRequest.dart'; import 'package:Data4Diabetes/app/data/model/dexcom/AccessTokenResponse.dart'; @@ -20,7 +21,7 @@ abstract class UserRepository { Future register(RegisterRequest request); Future verifyOTP(VerifyOtpRequest request); Future validateMobileNumber(ValidateMobileNumberRequest request); - Future deleteUserAccount(); + Future deleteUserAccount(DeleteAccountRequest request); Future obtainAccessToken(AccessTokenRequest request); Future evgs(EstimatedGlucoseValueRequest request); } diff --git a/lib/app/data/repository/user_repository_impl.dart b/lib/app/data/repository/user_repository_impl.dart index c5f89ab..5f66ffe 100644 --- a/lib/app/data/repository/user_repository_impl.dart +++ b/lib/app/data/repository/user_repository_impl.dart @@ -1,3 +1,4 @@ +import 'package:Data4Diabetes/app/data/model/deleteAccount/deleteAccountRequest.dart'; import 'package:Data4Diabetes/app/data/model/deleteAccount/deleteAccountResponse.dart'; import 'package:Data4Diabetes/app/data/model/dexcom/AccessTokenRequest.dart'; import 'package:Data4Diabetes/app/data/model/dexcom/AccessTokenResponse.dart'; @@ -41,8 +42,8 @@ class UserRepositoryImpl implements UserRepository { } /// delete user account @override - Future deleteUserAccount() { - return _remoteSource.deleteUserAccount(); + Future deleteUserAccount(DeleteAccountRequest request) { + return _remoteSource.deleteUserAccount(request); } /// obtain dexcom access token @override diff --git a/lib/app/modules/otp/controllers/otp_controller.dart b/lib/app/modules/otp/controllers/otp_controller.dart index bc8ce1b..df300d3 100644 --- a/lib/app/modules/otp/controllers/otp_controller.dart +++ b/lib/app/modules/otp/controllers/otp_controller.dart @@ -35,8 +35,15 @@ class OtpController extends BaseController { _preferenceManagerImpl.setString('token', response.token); SharedPreferences _prefs = await SharedPreferences.getInstance(); _prefs.setString('privacyDashboarduserId', response.lastname); + if(loginController.sharePhoneNumber.value!=""){ + _prefs.setString('userMobileNumber', loginController.sharePhoneNumber.value); + }else if(registerController.sharePhoneNumber.value!=""){ + _prefs.setString('userMobileNumber', registerController.sharePhoneNumber.value); + } + hideLoading(); verifyOtpController.clear(); + Get.offAll(MainView()); } } catch (e) { diff --git a/lib/app/modules/settings/controllers/settings_controller.dart b/lib/app/modules/settings/controllers/settings_controller.dart index 5c6d5c8..81edd8b 100644 --- a/lib/app/modules/settings/controllers/settings_controller.dart +++ b/lib/app/modules/settings/controllers/settings_controller.dart @@ -1,3 +1,4 @@ +import 'package:Data4Diabetes/app/data/model/deleteAccount/deleteAccountRequest.dart'; import 'package:flutter/cupertino.dart'; import 'package:Data4Diabetes/app/modules/Dexcom/controllers/dexcom_controller.dart'; @@ -56,7 +57,12 @@ class SettingsController extends BaseController { } void deleteAccount() async { - int response = await _impl.deleteUserAccount(); + SharedPreferences _prefs = await SharedPreferences.getInstance(); + var mobileNumber= _prefs.getString('userMobileNumber'); + print("user mobile number with code is :$mobileNumber"); + DeleteAccountRequest request = + DeleteAccountRequest(mobile_number: mobileNumber); + int response = await _impl.deleteUserAccount(request); debugPrint('this is the response:$response'); if (response == successWithoutContent) { GetSnackToast( diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 691237b..f1be1cc 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -26,7 +26,7 @@ "settingsDexcomLoginNo":"No", "settingsLogout":"Logout", "settingsSettings":"Settings", - "settingsDeleteAccount":"Delete Account", + "settingsDeleteAccount":"Remove My Account", "settingsPrivacyPolicy":"Privacy Policy", "settingsDeleteAccountSuccess":"User account deleted successfully", "settingsDeleteAccountFail":"User does not exist", diff --git a/lib/l10n/app_sv.arb b/lib/l10n/app_sv.arb index a35e4f7..fbc0303 100644 --- a/lib/l10n/app_sv.arb +++ b/lib/l10n/app_sv.arb @@ -26,7 +26,7 @@ "settingsDexcomLoginNo":"Nej", "settingsLogout":"Logga ut", "settingsSettings":"Inställningar", - "settingsDeleteAccount":"Ta bort konto", + "settingsDeleteAccount":"Ta bort mitt konto", "settingsPrivacyPolicy":"Integritetspolicy", "settingsDeleteAccountSuccess":"Användarkontot har tagits bort", "settingsDeleteAccountFail":"Användaren finns inte",