getAllReceiveMessageOpt static method

Future<V2TimValueCallback<V2TimReceiveMessageOptInfo>> getAllReceiveMessageOpt()

Implementation

static Future<V2TimValueCallback<V2TimReceiveMessageOptInfo>> getAllReceiveMessageOpt() async {
  String userData = Tools.generateUserData();
  Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
  int res1 = desktopSDK.D_TIMMsgGetAllReceiveMessageOpt(user_data);
  if (res1 != TIMResult.TIM_SUCC) {
    return V2TimValueCallback<V2TimReceiveMessageOptInfo>.fromJson({
      "code": res1,
      "desc": "",
    });
  } else {
    Map<String, dynamic> data = await getAsyncData(apiKey: userData);
    Map<String, dynamic> dataMap = Map<String, dynamic>.from(
      json.decode(data["json_param"].isEmpty ? json.encode({}) : data["json_param"]),
    );
    return V2TimValueCallback<V2TimReceiveMessageOptInfo>.fromJson({
      "code": data["code"],
      "desc": data["desc"],
      "data": Map<String, dynamic>.from({
        "c2CReceiveMessageOpt": dataMap["msg_recv_msg_opt_result_opt"],
        "userID": dataMap["msg_recv_msg_opt_result_identifier"],
        "allReceiveMessageOpt": dataMap["msg_all_recv_msg_opt_level"],
        "duration": dataMap["msg_all_recv_msg_duration"],
        "startHour": dataMap["msg_all_recv_msg_opt_start_hour"],
        "startSecond": dataMap["msg_all_recv_msg_opt_start_second"],
        "startTimeStamp": dataMap["msg_all_recv_msg_opt_start_time_stamp"],
        "startMinute": dataMap["msg_all_recv_msg_opt_start_minute"],
      }),
    });
  }
}