Пример #1
0
 /**
  * Saves a Person
  * 
  * @param \DeskPRO\Builder\Person $person
  * @return \DeskPRO\Api\Result
  * @throws \Exception if required parameters are missing
  */
 public function save(\DeskPRO\Builder\Person $person)
 {
     if ($person->getId()) {
         return $this->call('POST', '/people/' . intval($person->getId()), $person->getDataArray());
     }
     return $this->call('POST', '/people', $person->getDataArray());
 }
Пример #2
0
 /**
  * Sets the person who created the ticket
  * Tries to find an User with the given ID, if no ID is given
  * a new person will be created with the given info
  * 
  * @param \DeskPRO\Builder\Person $person
  * @return \DeskPRO\Builder\Ticket
  */
 public function setCreatedBy(\DeskPRO\Builder\Person $person)
 {
     if ($person->getId()) {
         $this->_dataArray['person_id'] = $person->getId();
     } else {
         $personDataArray = $person->getDataArray();
         $this->_dataArray['person_email'] = $person->getEmail();
         $this->_dataArray['person_name'] = $person->getName();
         if (isset($personDataArray['organization']) && !empty($personDataArray['organization'])) {
             $this->_dataArray['person_organization'] = $personDataArray['organization'];
         }
         if (isset($personDataArray['organization_position'])) {
             $this->_dataArray['person_organization_position'] = $personDataArray['organization_position'];
         }
     }
     return $this;
 }