/** * @param Batchblue_Service_BatchBook_Deal $deal * @return Batchblue_Service_BatchBook_Deal */ public function testAddPersonToToDo() { $person = new Batchblue_Service_BatchBook_Person(); $person->setFirstName('TestFirstNameWithToDo')->setLastName('TestLastNameWithToDo')->setNotes('Downloaded my product and linking todo'); $todo = new Batchblue_Service_BatchBook_ToDo(); $todo->setTitle('Test ToDo Title with person')->setDescription('Test ToDo Description with contact attached')->setFlagged(false)->setDueDate(new DateTime('2013-12-13')); $this->_toDoService->postToDo($todo); $this->_personService->postPerson($person); $this->_toDoService->addPersonToToDo($todo, $person); $getTodo = $this->_toDoService->getToDo($todo->getId()); $this->assertEquals($todo, $getTodo); return $todo; }
/** * @param Batchblue_Service_BatchBook_Deal $deal * @return Batchblue_Service_BatchBook_Deal */ public function testAddPersonToDeal() { $person = new Batchblue_Service_BatchBook_Person(); $person->setFirstName('TestFirstNameWithDeal')->setLastName('TestLastNameWithDeal')->setNotes('Downloaded my product'); $deal = new Batchblue_Service_BatchBook_Deal(); $deal->setTitle('Test Deal Title With Person')->setDescription('Test Deal Description With Person')->setStatus('pending'); $this->_dealService->postDeal($deal); $this->_personService->postPerson($person); $this->_dealService->addPersonToDeal($deal, $person); $getDeal = $this->_dealService->getDeal($deal->getId()); $this->assertEquals($deal, $getDeal); return $deal; }
/** * Add Tag * * @param Batchblue_Service_BatchBook_Person $person * @param string $tag */ public function addTag(Batchblue_Service_BatchBook_Person $person, Batchblue_Service_BatchBook_Tag $tag) { $httpClient = new Zend_Http_Client('https://' . $this->_accountName . '.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()); } }
/** * @depends testPutPerson * @param Batchblue_Service_BatchBook_Person $person * @return void */ public function testDeletePerson(Batchblue_Service_BatchBook_Person $person) { // $this->_personService->deletePerson($person); $getPerson = $this->_personService->getPerson($person->getId()); //TODO: Test is incomplete because the API is returning deleted Person objects $this->markTestIncomplete("Test is incomplete as the REST API currently returns deleted Person objects"); // When REST API is fixed, remove comment below and delete the markTestIncomplete() line above //$this->assertNull($getPerson); }
/** Note: REST API supports adding company to the deal too */ public function addPersonToDeal(Batchblue_Service_BatchBook_Deal $deal, Batchblue_Service_BatchBook_Person $person) { $httpClient = new Zend_Http_Client('https://' . $this->_accountName . '.batchbook.com/service/deals/' . $deal->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 deal'); } return $this; }