addSecondaryEmail method

Future<Map<String, dynamic>> addSecondaryEmail({
  1. required BuildContext context,
  2. required String? email,
})

Implementation

Future<Map<String, dynamic>> addSecondaryEmail(
    {required BuildContext context, required String? email}) async {
  try {
    final http.Response result =
        await client.query(addSecondaryEmailQuery, <String, dynamic>{
      'email': <String?>[email],
    }) 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
    updateStateFunc(
        context: context,
        type: StateContactType.secondaryEmails,
        value: email);
    return <String, dynamic>{
      'status': 'ok',
      'value': json.decode(result.body)['data']['addSecondaryEmailAddress'],
    };
  } catch (e) {
    return <String, dynamic>{
      'status': 'error',
    };
  }
}