<?php

namespace Benhauer\Salesmanago\Observer;

use \Magento\Framework\Event\Observer;
use \Benhauer\Salesmanago\Helper\Tagger;
use \Benhauer\Salesmanago\Observer\AbstractObserver as SalesmanagoAbstractObserver;

class CustomerLogin extends SalesmanagoAbstractObserver
{
    public function hookAct(Observer $observer) {
        try {
            $connectSalesManago = $this->getConnectSalesManago();

            $customerId = $observer->getCustomer()->getEntityId();
            $customer = $this->getCustomerById($customerId);

            $customer['options'] = isset($customer['options'])
                ? $customer['options']
                : '';

            $this->upsertContact($customer, $connectSalesManago, SalesmanagoAbstractObserver::UPSERT_FLAG_ALL_DATA);

        } catch (\Exception $e) {
            $this->logger->critical($e->getMessage());
        }
    }
}
