예제 #1
0
 public function crmLinkContactToCompany(Contact $contact, Company $company, $mode = 'link', $function = null)
 {
     $fields = array();
     $fields['contact_id'] = $contact->getId();
     $fields['company_id'] = $company->getId();
     $fields['mode'] = $mode;
     if ($function) {
         $fields['function'] = $function;
     }
     return $this->doCall('linkContactToCompany.php', $fields);
 }
예제 #2
0
 /**
  * Initialize a Company with raw data we got from the API
  *
  * @param  array   $data
  * @return Company
  */
 public static function initializeWithRawData($data)
 {
     $item = new Company();
     foreach ($data as $key => $value) {
         switch ($key) {
             case substr($key, 0, 3) == 'cf_':
                 $chunks = explode('_', $key);
                 $id = end($chunks);
                 $item->setCustomField($id, $value);
                 break;
             case 'language_name':
                 break;
             case 'deleted':
                 $item->setDeleted($value == 1);
                 break;
             default:
                 // Ignore empty values
                 if ($value == '') {
                     continue;
                 }
                 $methodName = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key)));
                 if (!method_exists(__CLASS__, $methodName)) {
                     if (Teamleader::DEBUG) {
                         var_dump($key, $value);
                         throw new Exception('Unknown method (' . $methodName . ')');
                     }
                 } else {
                     call_user_func(array($item, $methodName), $value);
                 }
         }
     }
     return $item;
 }
예제 #3
0
 /**
  * Tests teamleader->crmUpdateCompany()
  */
 public function testCrmGetAllCustomers()
 {
     $time = time();
     $company = new Company();
     $company->setName(time());
     $id = $this->teamleader->crmAddCompany($company);
     $company->setId($id);
     $company->setStreet($time);
     $companyId = $this->teamleader->crmAddCompany($company);
     $contact = new Contact();
     $contact->setForename($time);
     $contact->setSurname($time);
     $contact->setEmail($time . '@example.com');
     $contactId = $this->teamleader->crmAddContact($contact);
     $customers = $this->teamleader->crmGetAllCustomers();
     $this->assertInstanceOf('SumoCoders\\Teamleader\\Crm\\Company', $customers['companies'][$companyId]);
     $this->assertInstanceOf('SumoCoders\\Teamleader\\Crm\\Contact', $customers['contacts'][$contactId]);
 }