Overview

Namespaces

  • Ctct
    • Auth
    • Components
      • Account
      • Activities
      • Contacts
      • EmailMarketing
      • Tracking
    • Exceptions
    • Services
  • PHP

Classes

  • Activity
  • ActivityError
  • AddContacts
  • AddContactsImportData
  • ExportContacts
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: namespace Ctct\Components\Activities;
 3: 
 4: use Ctct\Components\Component;
 5: use Ctct\Components\Activities\ActivityError;
 6:  
 7: /**
 8:  * Represents a single Activity in Constant Contact
 9:  *
10:  * @package     Components
11:  * @subpackage     Activities
12:  * @author         Constant Contact
13:  */
14: class Activity extends Component
15: {
16:     public $id;
17:     public $type;
18:     public $status;
19:     public $start_date;
20:     public $finish_date;
21:     public $file_name;
22:     public $created_date;
23:     public $error_count;
24:     public $errors = array();
25:     public $warnings = array();
26:     public $contact_count;
27: 
28:     /**
29:      * Factory method to create an Activity object from an array
30:      * @param array $props - associative array of initial properties to set
31:      * @return Campaign
32:      */
33:     public static function create(array $props)
34:     {
35:         $activity = new Activity();
36:         $activity->id = parent::getValue($props, "id");
37:         $activity->type = parent::getValue($props, "type");
38:         $activity->status = parent::getValue($props, "status");
39:         $activity->start_date = parent::getValue($props, "start_date");
40:         $activity->finish_date = parent::getValue($props, "finish_date");
41:         $activity->created_date = parent::getValue($props, "created_date");
42:         $activity->error_count = parent::getValue($props, "error_count");
43:         $activity->contact_count = parent::getValue($props, "contact_count");
44: 
45:         // set any errors that exist, otherewise destroy the property
46:         if (array_key_exists('errors', $props)) {
47:             foreach ($props['errors'] as $error) {
48:                 $activity->errors[] = ActivityError::create($error);
49:             }
50:         } else {
51:             unset($activity->errors);
52:         }
53: 
54:         // set any warnings that exist, otherewise destroy the property
55:         if (array_key_exists('warnings', $props)) {
56:             foreach ($props['warnings'] as $error) {
57:                 $activity->warnings[] = ActivityError::create($error);
58:             }
59:         } else {
60:             unset($activity->warnings);
61:         }
62: 
63:         // set the file name if exists
64:         if (array_key_exists('file_name', $props)) {
65:             $activity->file_name = $props['file_name'];
66:         } else {
67:             unset($activity->file_name);
68:         }
69: 
70:         return $activity;
71:     }
72: 
73:     /**
74:      * Create json used for a POST/PUT request, also handles removing attributes that will cause errors if sent
75:      * @return string 
76:      */
77:     public function toJson()
78:     {
79:         return json_encode($this);
80:     }
81: }
82: 
Appconnect PHP SDK API documentation generated by ApiGen 2.8.0