Update fan inventory method

Use the methods provided within sdbusplus.hpp to update fan inventory
along with prepping inventory to be updated for each fan rotor sensor's
functional state.

Change-Id: I7d3026d289b1dd22cd4e7b4457c4d4396309c0b5
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index ba0744a..a6af74a 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -18,6 +18,7 @@
 #include "fan.hpp"
 #include "types.hpp"
 #include "utility.hpp"
+#include "sdbusplus.hpp"
 
 namespace phosphor
 {
@@ -28,14 +29,6 @@
 
 using namespace phosphor::logging;
 
-constexpr auto INVENTORY_PATH = "/xyz/openbmc_project/inventory";
-constexpr auto INVENTORY_INTF = "xyz.openbmc_project.Inventory.Manager";
-
-constexpr auto FUNCTIONAL_PROPERTY = "Functional";
-constexpr auto OPERATIONAL_STATUS_INTF  =
-    "xyz.openbmc_project.State.Decorator.OperationalStatus";
-
-
 Fan::Fan(Mode mode,
          sdbusplus::bus::bus& bus,
          phosphor::fan::event::EventPtr&  events,
@@ -221,18 +214,17 @@
 
 void Fan::updateInventory(bool functional)
 {
-    ObjectMap objectMap = getObjectMap(functional);
-    std::string service;
-
-    service = phosphor::fan::util::getInvService(_bus);
-
-    auto msg = _bus.new_method_call(service.c_str(),
-                                   INVENTORY_PATH,
-                                   INVENTORY_INTF,
-                                   "Notify");
-
-    msg.append(std::move(objectMap));
-    auto response = _bus.call(msg);
+    auto objectMap = util::getObjMap<bool>(
+            _name,
+            util::OPERATIONAL_STATUS_INTF,
+            util::FUNCTIONAL_PROPERTY,
+            functional);
+    auto response = util::SDBusPlus::lookupAndCallMethod(
+            _bus,
+            util::INVENTORY_PATH,
+            util::INVENTORY_INTF,
+            "Notify",
+            objectMap);
     if (response.is_method_error())
     {
         log<level::ERR>("Error in Notify call to update inventory");
@@ -243,21 +235,6 @@
     _functional = functional;
 }
 
-
-Fan::ObjectMap Fan::getObjectMap(bool functional)
-{
-    ObjectMap objectMap;
-    InterfaceMap interfaceMap;
-    PropertyMap propertyMap;
-
-    propertyMap.emplace(FUNCTIONAL_PROPERTY, functional);
-    interfaceMap.emplace(OPERATIONAL_STATUS_INTF, std::move(propertyMap));
-    objectMap.emplace(_name, std::move(interfaceMap));
-
-    return objectMap;
-}
-
-
 }
 }
 }