isauthenticated method

Future<void> isauthenticated(
  1. BuildContext context, {
  2. required ConfigurationModel tap,
})

Implementation

Future<void> isauthenticated(
  BuildContext context, {
  required ConfigurationModel tap,
}) async {
  try {
    _loader = true;
    notifyListeners();
    final ResponseModel response = await postmethod(
      endpoint: "Organization/GetByOrgId",
      payload: {"orgid": tap.orgid},
    );
    if (response.result != null) {
      // log("Result $response");
      statuscode = response.statuscode;
      var result = response.result?['result'];
      var organization = result['organization'];
      var lisce = result["license"];
      apiKey = lisce['licesence'];
      notifyListeners();
      if (organization != null) {
        scanscount = organization["scans"];
        if (scanscount > 0) {
          initbluai(context, tap.color, tap);
        }
        _loader = false;
        notifyListeners();
      } else {
        _loader = false;
        notifyListeners();
        showWarningDialog(
          context,
          title: "Warning",
          titlestye: tap.alerttitlestyle,
          messagestyle: tap.alertmessageStyle,
          message:
              "You are not opted to our services please register to use our services",
        );
      }
    } else {
      _loader = false;
      notifyListeners();
      showWarningDialog(
        context,
        title: "Something went wrong",
        titlestye: tap.alerttitlestyle,
        messagestyle: tap.alertmessageStyle,
        message: "Something went wrong please try again later",
      );
    }
  } catch (e) {
    _loader = false;
    notifyListeners();
    errortoast(
      title: "Failed to start mesasurement",
      messge: "Failed to start mesasurement $e",
    );
  }
}