Skip to content

Commit

Permalink
#236 Remove user account
Browse files Browse the repository at this point in the history
As the play console recommends, we need to add an new option for users to delete their account.
Add a new option in settings, "Remove My Account"
  • Loading branch information
lijogeorgep authored and josmilan committed Dec 5, 2023
1 parent 476b5c9 commit 89f729d
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 9 deletions.
16 changes: 16 additions & 0 deletions lib/app/data/model/deleteAccount/deleteAccountRequest.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class DeleteAccountRequest {
String? mobile_number;

DeleteAccountRequest({this.mobile_number});

DeleteAccountRequest.fromJson(Map<String, dynamic> json) {
mobile_number = json['mobile_number'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['mobile_number'] = this.mobile_number;

return data;
}
}
3 changes: 2 additions & 1 deletion lib/app/data/remote/user_remote_data_source.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -18,7 +19,7 @@ abstract class UserRemoteDataSource {
Future<RegisterResponse> register(RegisterRequest request);
Future<VerifyOtpResponse> verifyOTP(VerifyOtpRequest request);
Future<ValidateMobileNumberResponse> validateMobileNumber(ValidateMobileNumberRequest request);
Future<dynamic> deleteUserAccount();
Future<dynamic> deleteUserAccount(DeleteAccountRequest request);
Future<AccessTokenResponse> obtainAccessToken(AccessTokenRequest request);
Future<EstimatedGlucoseValue> evgs(EstimatedGlucoseValueRequest request);
}
5 changes: 3 additions & 2 deletions lib/app/data/remote/user_remote_data_source_impl.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -81,10 +82,10 @@ class UserRemoteDataSourceImpl extends BaseRemoteSource
}
/// delete user account
@override
Future<dynamic> deleteUserAccount() {
Future<dynamic> 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)
Expand Down
3 changes: 2 additions & 1 deletion lib/app/data/repository/user_repository.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -20,7 +21,7 @@ abstract class UserRepository {
Future<RegisterResponse> register(RegisterRequest request);
Future<VerifyOtpResponse> verifyOTP(VerifyOtpRequest request);
Future<ValidateMobileNumberResponse> validateMobileNumber(ValidateMobileNumberRequest request);
Future<dynamic> deleteUserAccount();
Future<dynamic> deleteUserAccount(DeleteAccountRequest request);
Future<AccessTokenResponse> obtainAccessToken(AccessTokenRequest request);
Future<EstimatedGlucoseValue> evgs(EstimatedGlucoseValueRequest request);
}
5 changes: 3 additions & 2 deletions lib/app/data/repository/user_repository_impl.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -41,8 +42,8 @@ class UserRepositoryImpl implements UserRepository {
}
/// delete user account
@override
Future<dynamic> deleteUserAccount() {
return _remoteSource.deleteUserAccount();
Future<dynamic> deleteUserAccount(DeleteAccountRequest request) {
return _remoteSource.deleteUserAccount(request);
}
/// obtain dexcom access token
@override
Expand Down
7 changes: 7 additions & 0 deletions lib/app/modules/otp/controllers/otp_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n/app_sv.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 89f729d

Please sign in to comment.