setPrimaryEmail method
Future<Map<String, dynamic> >
setPrimaryEmail({
- required BuildContext context,
- required String? email,
- required String? otp,
Implementation
Future<Map<String, dynamic>> setPrimaryEmail(
{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 secondary email as primary
updateStateFunc(
context: context,
type: StateContactType.setPrimaryEmail,
value: email);
return <String, dynamic>{
'status': 'ok',
'value': json.decode(result.body)['data']['setPrimaryEmailAddress'],
};
} catch (e) {
return <String, dynamic>{
'status': 'error',
};
}
}