function __construct(\ShipperHQ\Shipper\Helper\Data $shipperDataHelper, \Magento\Customer\Model\GroupFactory $groupFactory, \ShipperHQ\WS\Rate\Request\RateRequestFactory $rateRequestFactory, \ShipperHQ\WS\Rate\Request\InfoRequestFactory $infoRequestFactory, \ShipperHQ\WS\Shared\AddressFactory $addressFactory, \ShipperHQ\WS\Shared\CredentialsFactory $credentialsFactory, \ShipperHQ\WS\Shared\SiteDetailsFactory $siteDetailsFactory, \ShipperHQ\WS\Rate\Request\CustomerDetailsFactory $customerDetailsFactory, \ShipperHQ\WS\Rate\Request\ShipDetailsFactory $shipDetailsFactory, \ShipperHQ\WS\Rate\Request\Shipping\SelectedOptionsFactory $selectedOptionsFactory, \ShipperHQ\WS\Rate\Request\Checkout\CartFactory $cartFactory, \ShipperHQ\WS\Rate\Request\Checkout\ItemFactory $itemFactory, \Magento\Tax\Model\Calculation $taxCalculation, \ShipperHQ\Shipper\Helper\LogAssist $shipperLogger, \Magento\Catalog\Helper\Product\Configuration $productConfiguration, \Magento\Framework\App\ProductMetadata $productMetadata, \Magento\Backend\Block\Template\Context $context, StockHandler $stockHandler, \Magento\Checkout\Model\Session $checkoutSession, \ShipperHQ\WS\Rate\Request\Checkout\PhysicalBuildingDetailFactory $physicalBuildingDetailFactory, \ShipperHQ\WS\Rate\Request\Checkout\StockDetailFactory $stockDetailFactory)
 {
     $this->shipperDataHelper = $shipperDataHelper;
     $this->storeManager = $context->getStoreManager();
     self::$prodAttributes = $this->shipperDataHelper->getProductAttributes();
     $this->groupFactory = $groupFactory;
     $this->productMetadata = $productMetadata;
     $this->taxCalculation = $taxCalculation;
     $this->productConfiguration = $productConfiguration;
     $this->rateRequestFactory = $rateRequestFactory;
     $this->shipperLogger = $shipperLogger;
     $this->selectedOptionsFactory = $selectedOptionsFactory;
     $this->cartFactory = $cartFactory;
     $this->itemFactory = $itemFactory;
     $this->addressFactory = $addressFactory;
     $this->infoRequestFactory = $infoRequestFactory;
     $this->credentialsFactory = $credentialsFactory;
     $this->siteDetailsFactory = $siteDetailsFactory;
     $this->customerDetailsFactory = $customerDetailsFactory;
     $this->shipDetailsFactory = $shipDetailsFactory;
     $this->stockHandler = $stockHandler;
     $this->physicalBuildingDetailFactory = $physicalBuildingDetailFactory;
     $this->checkoutSession = $checkoutSession;
     $this->stockDetailFactory = $stockDetailFactory;
 }
 protected function compareAttributeData($latestAttributes)
 {
     $result = array();
     $productAttributes = $this->shipperDataHelper->getProductAttributes();
     foreach ($latestAttributes as $attribute) {
         switch ($attribute->type) {
             case 'product':
                 try {
                     $existingAttributeOptions = array();
                     if (!in_array($attribute->code, $productAttributes)) {
                         $this->shipperLogger->postDebug('Shipperhq_Shipper', 'Attribute ' . $attribute->code . ' does not exist.', '');
                         continue;
                     }
                     $existingAttributeInfo = $this->attributeOptionManagement->getItems($attribute->code);
                     if (is_array($existingAttributeInfo)) {
                         $existingAttributeOptions = $existingAttributeInfo;
                     }
                 } catch (\Exception $e) {
                     $e->getMessage();
                     $this->shipperLogger->postDebug('Shipperhq_Shipper', 'Unable to find attribute ' . $attribute->code, 'Error: ' . $e->getMessage());
                     $result = false;
                     break;
                 }
                 $trackValues = $existingAttributeOptions;
                 foreach ($attribute->attributes as $latestValue) {
                     $found = false;
                     foreach ($existingAttributeOptions as $key => $option) {
                         if ($option->getLabel() == $latestValue->name) {
                             $found = true;
                             unset($trackValues[$key]);
                             continue;
                         }
                     }
                     if (!$found) {
                         $result[] = array('attribute_type' => $attribute->type, 'attribute_code' => $attribute->code, 'value' => $latestValue->name, 'status' => self::ADD_ATTRIBUTE_OPTION, 'date_added' => date('Y-m-d H:i:s'));
                     }
                 }
                 if (count($trackValues) > 0) {
                     //TODO add store selector in here
                     $storeId = '';
                     foreach ($trackValues as $key => $option) {
                         if (ctype_space($option->getLabel()) || $option->getLabel() == '') {
                             unset($trackValues[$key]);
                             continue;
                         }
                         $isAssigned = $this->getIsAttributeValueUsed($attribute->code, $option->getValue(), $storeId, true);
                         $deleteFlag = self::AUTO_REMOVE_ATTRIBUTE_OPTION;
                         if ($isAssigned) {
                             $deleteFlag = self::REMOVE_ATTRIBUTE_OPTION;
                         }
                         $result[] = array('attribute_type' => $attribute->type, 'attribute_code' => $attribute->code, 'value' => $option->getLabel(), 'option_id' => $option->getValue(), 'status' => $deleteFlag, 'date_added' => date('Y-m-d H:i:s'));
                     }
                 }
                 break;
             case 'global':
                 if ($attribute->code == 'global_settings') {
                     foreach ($attribute->attributes as $globalSetting) {
                         $value = $globalSetting->value == 'true' ? 1 : 0;
                         if ($this->shipperDataHelper->getConfigValue('carriers/shipper/' . $globalSetting->code) != $value) {
                             $result[] = array('attribute_type' => 'global_setting', 'attribute_code' => $globalSetting->code, 'value' => $value, 'option_id' => '', 'status' => self::ADD_ATTRIBUTE_OPTION, 'date_added' => date('Y-m-d H:i:s'));
                         }
                     }
                 }
             case 'customer':
                 //compare customer groups
                 break;
             default:
                 break;
         }
     }
     $this->shipperLogger->postDebug('Shipperhq_Shipper', 'Compare attributes result: ', $result);
     return $result;
 }