getTimerData method

Future<Map<String, dynamic>?> getTimerData(
  1. VaConfig config,
  2. ProfilingModel payload
)

Implementation

Future<Map<String, dynamic>?> getTimerData(
    VaConfig config, ProfilingModel payload) async {
  Map<String, dynamic>? otherInfoDynamic;

  payload.accessToken = config.profileAccessToken;
  if (payload.data != null) {
    payload.data!.botId = config.profileBotId;
  }

  String url =
      "http://api.botika.online/public/botika/user-profiling/index.php";
  Map<String, dynamic> body = payload.toJson();
  Map<String, String> header = {
    "Authorization": "Bearer ${payload.accessToken}",
  };

  Map<String, dynamic>? response = await post(
    url,
    body,
    header: header,
  );
  if (response == null) {
    return null;
  }

  try {
    ProfilingModel data = ProfilingModel.fromJson(response);
    otherInfoDynamic = jsonDecode(
      data.data!.otherInfoDynamic,
    );
  } catch (e) {
    //
    errorMessage = "$e";
    return null;
  }

  return otherInfoDynamic;
}