/**
  * Converts a higher-level contact object into a standard
  * object class for writing to the database
  * @param MoodletxtAddressbookRecipient $contact Full-fat data object
  * @return object Object ready for DB
  * @version 2012091301
  * @since 2012090501
  */
 private function convertContactBeanToStandardClass(MoodletxtAddressbookRecipient $contact)
 {
     $dbObj = new object();
     $dbObj->addressbook = $contact->getAddressbookId();
     $dbObj->firstname = $contact->getFirstName();
     $dbObj->lastname = $contact->getLastName();
     $dbObj->company = $contact->getCompanyName();
     $dbObj->phoneno = $contact->getRecipientNumber()->getPhoneNumber();
     if ($contact->getContactId() > 0) {
         $dbObj->id = $contact->getContactId();
     }
     return $dbObj;
 }
 /**
  * Build JSON response structure for an updated contact
  * @param MoodletxtAddressbookRecipient $contact Updated contact
  * @return string Constructed JSON
  * @version 2012090501
  * @since 2012090501
  */
 private function buildResponse(MoodletxtAddressbookRecipient $contact)
 {
     // Copy template down
     $response = $this->responseTemplate;
     $contactArray = array('contactId' => $contact->getContactId(), 'firstName' => $contact->getFirstName(), 'lastName' => $contact->getLastName(), 'company' => $contact->getCompanyName(), 'phoneNo' => $contact->getRecipientNumber()->getPhoneNumber());
     array_push($response['contacts'], $contactArray);
     return json_encode($response);
 }