<?php

namespace FiloBlu\Flow\Model\Actions\From;

/*
 * This action is currently used on the project PalZileri
 */
class Setsinesycustomerprogid
{
    public function process($customer, $progId, $storeId){
        $class = 'FiloBlu\Palzileri\Helper\Sinesy';
        if (!class_exists($class)){
            return true;
        }
        if (!$customer->getEmail()){
            return true;
        }
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $sinesyHelper = $objectManager->create($class);
        try {
            $sinesyCustomer = $sinesyHelper->getSinesyCustomerByEmail($customer->getEmail(),$storeId);
            if ($sinesyCustomer){
                $sinesyHelper->updateProgId($sinesyCustomer,$progId);
            }
        } catch (\Exception $e) {}
        return true;
    }
}
