addPrimaryEmail method
Future<Map<String, dynamic> >
addPrimaryEmail({
- required BuildContext context,
- required String? email,
- required String? otp,
adds a primary email to an account
Implementation
Future<Map<String, dynamic>> addPrimaryEmail(
{required BuildContext context,
required String? email,
required String? otp}) async {
try {
final http.Response result =
await client.query(setPrimaryEmailQuery, <String, dynamic>{
'email': email,
'otp': otp,
}) as http.Response;
final Map<String, dynamic> body =
client.toMap(result) as Map<String, dynamic>;
if (client.parseError(body) != null) {
return <String, dynamic>{
'status': 'error',
};
}
/// update user profile with the primary email
updateStateFunc(
context: context, type: StateContactType.primaryEmail, value: email);
return <String, dynamic>{
'status': 'ok',
'value': json.decode(result.body)['data']['addPrimaryEmailAddress'],
};
} catch (e) {
return <String, dynamic>{
'status': 'error',
};
}
}