From 6e427e4c257b444e1128ea4fdce2fe09399ba587 Mon Sep 17 00:00:00 2001 From: Peter Borodatyy Date: Sun, 2 Apr 2017 22:10:54 +0300 Subject: [PATCH] Fixed bug's with empty people_id on set. --- src/Producers/People.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Producers/People.php b/src/Producers/People.php index 32cc296..d2e85e0 100644 --- a/src/Producers/People.php +++ b/src/Producers/People.php @@ -48,16 +48,17 @@ public function identify($identifier) { return $this->_people_id; } - if(empty($this->_visitor_id)) { - throw new Exception('Empty visitor_id.'); - } - $this->_transport->setEndpoint('people/identify'); - $response = $this->_transport->execute([ - 'visitor_id' => $this->_visitor_id, + $data = [ 'identifier' => $identifier - ]); + ]; + + if(!empty($this->_visitor_id)) { + $data['visitor_id'] = $this->_visitor_id; + } + + $response = $this->_transport->execute($data); $this->_people = $response['people']; @@ -79,6 +80,12 @@ public function set(array $args) { } } + if(empty($this->get()['id'])) { + if(!empty($this->_identifier)) { + $this->identify($this->_identifier); + } + } + $this->_transport->setEndpoint('people/'.$this->get()['id']); $this->_transport->execute($data);