getOrgUsers method

  1. @override
Future<OrgUsersData?> getOrgUsers()
override

Implementation

@override
Future<OrgUsersData?> getOrgUsers() {

  if(reportingTokenCall==null || orgUniqueKey==null){
    Fluttertoast.showToast(msg: "Please wait for the app to register");
    return Future.value(null);
  }

  return networkAPI
      .getOrgUsers(reportingTokenCall!, orgUniqueKey!)
      .then((response) {
    if (response.statusCode == 200) {
      orgUsersData = OrgUsers.fromJson(response.data).data;
      debugPrint(orgUsersData.organisationName);
      debugPrint('Users fetched successfully!');
      return orgUsersData;
    } else {
      debugPrint('An error occurred while fetching users!');
      debugPrint(response.statusCode as String?);
      return null;
    }
  }).catchError((error) {
    debugPrint('An error occurred while fetching users!');
    return null;
  });
}