public function addPersonToToDo(Kohana_ToDo $todo, Kohana_Person $person) { $httpClient = new Zend_Http_Client('https://' . $this->_accountName . '.batchbook.com/service/todos/' . $todo->getId() . '/add_related_contact.xml'); $paramsPut = array('contact_id' => $person->getId()); $httpClient->setAuth($this->_token, 'x'); $httpClient->setHeaders(Zend_Http_Client::CONTENT_TYPE, Zend_Http_Client::ENC_URLENCODED); $httpClient->setRawData(http_build_query($paramsPut, '', '&'), Zend_Http_Client::ENC_URLENCODED); $response = $httpClient->request(Zend_Http_Client::PUT); if (200 != $response->getStatus()) { //TODO: throw more specific exception throw new Exception('Person not added to todo'); } return $this; }
/** * Add Tag * * @param Kohana_Person $person * @param string $tag */ public function addTag(Kohana_Person $person, Kohana_Tag $tag) { $httpClient = new Zend_Http_Client('https://' . $this->_account . '.batchbook.com/service/people/' . $person->getId() . '/add_tag.xml'); $paramsPut = array('tag' => $tag->getName()); $httpClient->setAuth($this->_token, 'x'); $httpClient->setHeaders(Zend_Http_Client::CONTENT_TYPE, Zend_Http_Client::ENC_URLENCODED); $httpClient->setRawData(http_build_query($paramsPut, '', '&'), Zend_Http_Client::ENC_URLENCODED); $response = $httpClient->request(Zend_Http_Client::PUT); if (200 != $response->getStatus()) { //TODO: throw more specific exception throw new Exception('Tag not added to person with id=' . $person->getId()); } }