/**
  * @param StaticSegment $entity
  */
 protected function onSuccess($entity)
 {
     // Reset originId of static segment if subscribers list was changed to force list creation
     if ($this->oldSubscribersList && $this->oldSubscribersList->getId() != $entity->getSubscribersList()->getId()) {
         $entity->setOriginId(null);
     }
     parent::onSuccess($entity);
 }
 /**
  * @param StaticSegment $staticSegment
  * @return null|StaticSegment
  */
 protected function addStaticListSegment(StaticSegment $staticSegment)
 {
     if (!$staticSegment->getOriginId()) {
         $response = $this->transport->addStaticListSegment(['id' => $staticSegment->getSubscribersList()->getOriginId(), 'name' => $staticSegment->getName()]);
         if (!empty($response['id'])) {
             $staticSegment->setOriginId($response['id']);
             $this->logger->debug(sprintf('StaticSegment with id "%s" added', $staticSegment->getOriginId()));
             return $staticSegment;
         }
     }
     return null;
 }