Skip to content

Commit

Permalink
Fixed bug's with empty people_id on set.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterborodatyy committed Apr 2, 2017
1 parent d3752d4 commit 6e427e4
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/Producers/People.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand All @@ -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);
Expand Down

0 comments on commit 6e427e4

Please sign in to comment.