authenticateWMS function

Future<EmployeeData?> authenticateWMS({
  1. required String wmsUsername,
  2. required String wmsPassword,
})

Implementation

Future<EmployeeData?> authenticateWMS({
  required String wmsUsername,
  required String wmsPassword,
}) async {
  try {
    final api = await ARSDataAPI.getAndInit();
    final Map<String, dynamic> parameters = {
      "login": {
        "Username": wmsUsername,
        "Password": wmsPassword,
      },
    };
    const String method = "AuthenticateWMS";
    final response = await api.execute(
      method,
      parameters: parameters,
    );
    logger.verbose(response);
    if (response.code == 0) {
      return EmployeeData.fromJson(response.data as Map<String, dynamic>);
    } else {
      logger.verbose(
        "Login Failed with Code: ${response.code} ${response.data is String ? "Message: ${response.data}" : ""}",
      );
      return null;
    }
  } on Exception catch (ex) {
    logger.error(ex);
    rethrow;
  }
}