setGroupMemberInfo method

Future setGroupMemberInfo(
  1. Map<String, dynamic> params
)

Implementation

Future<dynamic> setGroupMemberInfo(Map<String, dynamic> params) async {
  try {
    final setParams = SetGroupMemberInfo.formateParams(params);
    final customInfo = params['customInfo'];
    final nameCard = params['nameCard'];
    final nameCardParams = setParams['nameCardParams'];
    final customInfoParams = setParams['customInfoParams'];
    final haveBothValue =
        nameCard != null && customInfo != null && customInfo.keys.length > 0;

    if (haveBothValue) {
      final responses = await Future.wait(
          [setNameCard(nameCardParams!), setCustomInfo(customInfoParams!)]);
      if (responses[0].code == 0 && responses[1].code == 0) {
        return CommonUtils.returnSuccessWithDesc('set success');
      }
    }

    if (nameCard != null) {
      final responses = await setNameCard(nameCardParams!);
      if (responses.code == 0) {
        return CommonUtils.returnSuccessWithDesc('set success');
      }
    }

    if (customInfo != null && customInfo.keys.length > 0) {
      final responses = await setCustomInfo(customInfoParams!);
      if (responses.code == 0) {
        return CommonUtils.returnSuccessWithDesc('set success');
      }
    }

    return CommonUtils.returnSuccessWithDesc('set failed');
  } catch (error) {
    return CommonUtils.returnError(error);
  }
}