Overview

Namespaces

  • Ctct
    • Auth
    • Components
      • Account
      • Activities
      • Contacts
      • EmailMarketing
      • Library
      • Tracking
    • Exceptions
    • Services
    • Util
    • WebHooks

Classes

  • Ctct\Auth\CtctOAuth2
  • Ctct\Auth\SessionDataStore
  • Ctct\Components\Account\AccountInfo
  • Ctct\Components\Account\VerifiedEmailAddress
  • Ctct\Components\Activities\Activity
  • Ctct\Components\Activities\ActivityError
  • Ctct\Components\Activities\AddContacts
  • Ctct\Components\Activities\AddContactsImportData
  • Ctct\Components\Activities\ExportContacts
  • Ctct\Components\Component
  • Ctct\Components\Contacts\Address
  • Ctct\Components\Contacts\Contact
  • Ctct\Components\Contacts\ContactList
  • Ctct\Components\Contacts\CustomField
  • Ctct\Components\Contacts\EmailAddress
  • Ctct\Components\Contacts\Note
  • Ctct\Components\EmailMarketing\Campaign
  • Ctct\Components\EmailMarketing\ClickThroughDetails
  • Ctct\Components\EmailMarketing\MessageFooter
  • Ctct\Components\EmailMarketing\Schedule
  • Ctct\Components\EmailMarketing\TestSend
  • Ctct\Components\Library\File
  • Ctct\Components\Library\FileUploadStatus
  • Ctct\Components\Library\Folder
  • Ctct\Components\Library\Thumbnail
  • Ctct\Components\ResultSet
  • Ctct\Components\Tracking\BounceActivity
  • Ctct\Components\Tracking\ClickActivity
  • Ctct\Components\Tracking\ForwardActivity
  • Ctct\Components\Tracking\OpenActivity
  • Ctct\Components\Tracking\SendActivity
  • Ctct\Components\Tracking\TrackingActivity
  • Ctct\Components\Tracking\TrackingSummary
  • Ctct\Components\Tracking\UnsubscribeActivity
  • Ctct\ConstantContact
  • Ctct\Services\AccountService
  • Ctct\Services\ActivityService
  • Ctct\Services\BaseService
  • Ctct\Services\CampaignScheduleService
  • Ctct\Services\CampaignTrackingService
  • Ctct\Services\ContactService
  • Ctct\Services\ContactTrackingService
  • Ctct\Services\EmailMarketingService
  • Ctct\Services\LibraryService
  • Ctct\Services\ListService
  • Ctct\SplClassLoader
  • Ctct\Util\Config
  • Ctct\WebHooks\CTCTWebhookUtil

Interfaces

  • Ctct\Auth\CtctDataStore

Exceptions

  • Ctct\Exceptions\CtctException
  • Ctct\Exceptions\IllegalArgumentException
  • Ctct\Exceptions\OAuth2Exception
  • Overview
  • Namespace
  • Class
  1: <?php
  2: namespace Ctct\Components\Contacts;
  3: 
  4: use Ctct\Components\Component;
  5: 
  6: /**
  7:  * Represents a single Contact in Constant Contact
  8:  *
  9:  * @package        Components
 10:  * @subpackage     Contacts
 11:  * @author         Constant Contact
 12:  */
 13: class Contact extends Component
 14: {
 15: 
 16:     /**
 17:      * Unique identifier for the contact
 18:      * @var string
 19:      */
 20:     public $id;
 21: 
 22:     /**
 23:      * Status of the contact, must be one of "ACTIVE", "UNCONFIRMED", "OPTOUT", "REMOVED", "NON_SUBSCRIBER", "VISITOR"
 24:      * @var string
 25:      */
 26:     public $status;
 27: 
 28:     /**
 29:      * First name of the contact
 30:      * @var string
 31:      */
 32:     public $first_name;
 33: 
 34:     /**
 35:      * Last name of the contact
 36:      * @var string
 37:      */
 38:     public $last_name;
 39: 
 40:     /**
 41:      * Whether or not the contact is confirmed
 42:      * @var boolean
 43:      */
 44:     public $confirmed;
 45: 
 46:     /**
 47:      * Contact source information
 48:      * @var string
 49:      */
 50:     public $source;
 51: 
 52:     /**
 53:      * Array of email addresses associated with this contact
 54:      * @var EmailAddress[]
 55:      */
 56:     public $email_addresses = array();
 57: 
 58:     /**
 59:      * The prefix name of the contact
 60:      * @var string
 61:      */
 62:     public $prefix_name;
 63: 
 64:     /**
 65:      * The job title of the contact
 66:      * @var string
 67:      */
 68:     public $job_title;
 69: 
 70:     /**
 71:      * Array of addresses associated with this contact
 72:      * @var Address[]
 73:      */
 74:     public $addresses = array();
 75: 
 76:     /**
 77:      * Array of notes associated with this contact
 78:      * @var Note[]
 79:      */
 80:     public $notes = array();
 81: 
 82:     /**
 83:      * Company name this contact works for
 84:      * @var string
 85:      */
 86:     public $company_name;
 87: 
 88:     /**
 89:      * Contact's home phone number
 90:      * @var string
 91:      */
 92:     public $home_phone;
 93: 
 94:     /**
 95:      * Contact's work phone number
 96:      * @var string
 97:      */
 98:     public $work_phone;
 99: 
100:     /**
101:      * Contact's cell phone number
102:      * @var string
103:      */
104:     public $cell_phone;
105: 
106:     /**
107:      * Contact's fax number
108:      * @var string
109:      */
110:     public $fax;
111: 
112:     /**
113:      * Array of custom fields associated with this contact
114:      * @var CustomField[]
115:      */
116:     public $custom_fields = array();
117: 
118:     /**
119:      * Array of contact lists this contact belongs to
120:      * @var ContactList[]
121:      */
122:     public $lists = array();
123: 
124:     /**
125:      * Date the contact was created
126:      * @var string
127:      */
128:     public $created_date;
129: 
130:     /**
131:      * Date the contact was last modified
132:      * @var string
133:      */
134:     public $modified_date;
135: 
136:     /**
137:      * Contact source details
138:      * @var string
139:      */
140:     public $source_details;
141: 
142:     /**
143:      * Factory method to create a Contact object from an array
144:      * @param array $props - Associative array of initial properties to set
145:      * @return Contact
146:      */
147:     public static function create(array $props)
148:     {
149:         $contact = new Contact();
150:         $contact->id = parent::getValue($props, "id");
151:         $contact->status = parent::getValue($props, "status");
152:         $contact->first_name = parent::getValue($props, "first_name");
153:         $contact->last_name = parent::getValue($props, "last_name");
154:         $contact->confirmed = parent::getValue($props, "confirmed");
155:         $contact->source = parent::getValue($props, "source");
156: 
157:         if (isset($props['email_addresses'])) {
158:             foreach ($props['email_addresses'] as $email_address) {
159:                 $contact->email_addresses[] = EmailAddress::create($email_address);
160:             }
161:         }
162: 
163:         $contact->prefix_name = parent::getValue($props, "prefix_name");
164:         $contact->job_title = parent::getValue($props, "job_title");
165: 
166:         if (isset($props['addresses'])) {
167:             foreach ($props['addresses'] as $address) {
168:                 $contact->addresses[] = Address::create($address);
169:             }
170:         }
171: 
172:         if (isset($props['notes'])) {
173:             foreach ($props['notes'] as $note) {
174:                 $contact->notes[] = Note::create($note);
175:             }
176:         }
177: 
178:         $contact->company_name = parent::getValue($props, "company_name");
179:         $contact->home_phone = parent::getValue($props, "home_phone");
180:         $contact->work_phone = parent::getValue($props, "work_phone");
181:         $contact->cell_phone = parent::getValue($props, "cell_phone");
182:         $contact->fax = parent::getValue($props, "fax");
183: 
184:         if (isset($props['custom_fields'])) {
185:             foreach ($props['custom_fields'] as $custom_field) {
186:                 $contact->custom_fields[] = CustomField::create($custom_field);
187:             }
188:         }
189: 
190:         if (isset($props['lists'])) {
191:           foreach ($props['lists'] as $contact_list) {
192:               $contact->lists[] = ContactList::create($contact_list);
193:           }
194:         }
195: 
196:         $contact->created_date = parent::getValue($props, "created_date");
197:         $contact->modified_date = parent::getValue($props, "modified_date");
198: 
199:         $contact->source_details = parent::getValue($props, "source_details");
200: 
201:         return $contact;
202:     }
203: 
204:     /**
205:      * Add a ContactList
206:      * @param mixed $contactList - ContactList object or contact list id
207:      */
208:     public function addList($contactList)
209:     {
210:         if (!$contactList instanceof ContactList) {
211:             $contactList = new ContactList($contactList);
212:         }
213: 
214:         $this->lists[] = $contactList;
215:     }
216: 
217:     /**
218:      * Add an EmailAddress
219:      * @param mixed $emailAddress - EmailAddress object or email address
220:      */
221:     public function addEmail($emailAddress)
222:     {
223:         if (!$emailAddress instanceof EmailAddress) {
224:             $emailAddress = new EmailAddress($emailAddress);
225:         }
226: 
227:         $this->email_addresses[] = $emailAddress;
228:     }
229: 
230:     /**
231:      * Add a custom field to the contact object
232:      * @param CustomField $customField - custom field to add to the contact
233:      */
234:     public function addCustomField(CustomField $customField)
235:     {
236:         $this->custom_fields[] = $customField;
237:     }
238: 
239:     /**
240:      * Add an address
241:      * @param Address $address - Address to add
242:      */
243:     public function addAddress(Address $address)
244:     {
245:         $this->addresses[] = $address;
246:     }
247: 
248:     public function toJson()
249:     {
250:         unset($this->last_update_date);
251:         return json_encode($this);
252:     }
253: }
254: 
API documentation generated by ApiGen