/**
  * Public function that gets list members of a single list object passed to it.
  *
  * @param object $list - a valid list object with a valid list link
  * @return array $List - returns first 50 contact objects that are part of that list, and a link to next 50
  */
 public function getListMembers($list)
 {
     $utility = new CTCTUtility();
     $call = $utility->getApiPath() . $list->getLink() . '/members';
     $return = $utility->httpGet($call);
     $parsedReturn = simplexml_load_string($return['xml']);
     $List = array();
     $listMembers = array();
     $pages = array();
     foreach ($parsedReturn->entry as $item) {
         $contact = new CTCTContact();
         $contact->setLink($item->link->Attributes()->href);
         $contact->setId($item->id);
         $contact->setFullName($item->content->ContactListMember->Name);
         $contact->setEmailAddress($item->content->ContactListMember->EmailAddress);
         $listMembers[] = $contact;
     }
     $pages[] = $parsedReturn->link[2]->Attributes();
     $pages[] = $parsedReturn->link[3]->Attributes();
     //$pages[] = $parsedReturn->link[4]->Attributes();
     $List = array($listMembers, $pages);
     if (!$return) {
         return false;
     } else {
         return $List;
     }
 }
 /**
  * @param array $contact Submitted contact details
  * @param CTCTContact $ExistingContact Existing contact object
  */
 private static function mapMergeVars($contact, &$ExistingContact)
 {
     if (!empty($contact['first_name'])) {
         $ExistingContact->setFirstName($contact['first_name']);
     }
     if (!empty($contact['middle_name'])) {
         $ExistingContact->setMiddleName($contact['middle_name']);
     }
     if (!empty($contact['last_name'])) {
         $ExistingContact->setLastName($contact['last_name']);
     }
     if (!empty($contact['company_name'])) {
         $ExistingContact->setCompanyName($contact['company_name']);
     }
     if (!empty($contact['job_title'])) {
         $ExistingContact->setJobTitle($contact['job_title']);
     }
     if (!empty($contact['home_number'])) {
         $ExistingContact->setHomeNumber($contact['home_number']);
     }
     if (!empty($contact['work_number'])) {
         $ExistingContact->setWorkNumber($contact['work_number']);
     }
     if (!empty($contact['address_line_1'])) {
         $ExistingContact->setAddr1($contact['address_line_1']);
     }
     if (!empty($contact['address_line_2'])) {
         $ExistingContact->setAddr2($contact['address_line_2']);
     }
     if (!empty($contact['address_line_3'])) {
         $ExistingContact->setAddr3($contact['address_line_3']);
     }
     if (!empty($contact['city_name'])) {
         $ExistingContact->setCity($contact['city_name']);
     }
     if (!empty($contact['state_code'])) {
         $ExistingContact->setStateCode($contact['state_code']);
         $ExistingContact->setStateName('');
     }
     if (!empty($contact['state_name'])) {
         $ExistingContact->setStateName($contact['state_name']);
         $ExistingContact->setStateCode('');
     }
     if (!empty($contact['country_code'])) {
         $ExistingContact->setCountryCode($contact['country_code']);
     }
     if (!empty($contact['zip_code'])) {
         $ExistingContact->setPostalCode($contact['zip_code']);
     }
     if (!empty($contact['sub_zip_code'])) {
         $ExistingContact->setSubPostalCode($contact['sub_zip_code']);
     }
     if (!empty($contact['notes'])) {
         $ExistingContact->setNotes($contact['notes']);
     }
     if (!empty($contact['custom_field_1'])) {
         $ExistingContact->setCustomField1($contact['custom_field_1']);
     }
     if (!empty($contact['custom_field_2'])) {
         $ExistingContact->setCustomField2($contact['custom_field_2']);
     }
     if (!empty($contact['custom_field_3'])) {
         $ExistingContact->setCustomField3($contact['custom_field_3']);
     }
     if (!empty($contact['custom_field_4'])) {
         $ExistingContact->setCustomField4($contact['custom_field_4']);
     }
     if (!empty($contact['custom_field_5'])) {
         $ExistingContact->setCustomField5($contact['custom_field_5']);
     }
     if (!empty($contact['custom_field_6'])) {
         $ExistingContact->setCustomField6($contact['custom_field_6']);
     }
     if (!empty($contact['custom_field_7'])) {
         $ExistingContact->setCustomField7($contact['custom_field_7']);
     }
     if (!empty($contact['custom_field_8'])) {
         $ExistingContact->setCustomField8($contact['custom_field_8']);
     }
     if (!empty($contact['custom_field_9'])) {
         $ExistingContact->setCustomField9($contact['custom_field_9']);
     }
     if (!empty($contact['custom_field_10'])) {
         $ExistingContact->setCustomField10($contact['custom_field_10']);
     }
     if (!empty($contact['custom_field_11'])) {
         $ExistingContact->setCustomField11($contact['custom_field_11']);
     }
     if (!empty($contact['custom_field_12'])) {
         $ExistingContact->setCustomField12($contact['custom_field_12']);
     }
     if (!empty($contact['custom_field_13'])) {
         $ExistingContact->setCustomField13($contact['custom_field_13']);
     }
     if (!empty($contact['custom_field_14'])) {
         $ExistingContact->setCustomField14($contact['custom_field_14']);
     }
     if (!empty($contact['custom_field_15'])) {
         $ExistingContact->setCustomField15($contact['custom_field_15']);
     }
 }