sendNewEmailOTP method
Step 3: Send OTP to new email
Implementation
Future<Map<String, dynamic>> sendNewEmailOTP({
required String tenantId,
required String email,
required String newEmail,
}) async {
const query = r'''
mutation SendNewEmailOTP($input: EmailChangeInput!) {
sendNewEmailOTP(input: $input) {
success
message
otpSent
}
}
''';
try {
final res = await _api.graphql(query, {
'input': {
'tenantID': tenantId,
'email': email,
'newEmail': newEmail,
}
});
final data = res['sendNewEmailOTP'];
if (data == null) {
return {
'success': false,
'message': 'No data returned from server',
};
}
return Map<String, dynamic>.from(data);
} catch (e) {
print(" ERROR sending new email OTP: $e");
return {
'success': false,
'message': 'Failed to send OTP: $e',
};
}
}