1: <?php
2: namespace Ctct\Components\Activities;
3:
4: use Ctct\Components\Component;
5:
6: 7: 8: 9: 10: 11: 12:
13: class Activity extends Component
14: {
15: public $id;
16: public $type;
17: public $status;
18: public $start_date;
19: public $finish_date;
20: public $file_name;
21: public $created_date;
22: public $error_count;
23: public $errors = array();
24: public $warnings = array();
25: public $contact_count;
26:
27: 28: 29: 30: 31:
32: public static function create(array $props)
33: {
34: $activity = new Activity();
35: $activity->id = parent::getValue($props, "id");
36: $activity->type = parent::getValue($props, "type");
37: $activity->status = parent::getValue($props, "status");
38: $activity->start_date = parent::getValue($props, "start_date");
39: $activity->finish_date = parent::getValue($props, "finish_date");
40: $activity->created_date = parent::getValue($props, "created_date");
41: $activity->error_count = parent::getValue($props, "error_count");
42: $activity->contact_count = parent::getValue($props, "contact_count");
43:
44:
45: if (array_key_exists('errors', $props)) {
46: foreach ($props['errors'] as $error) {
47: $activity->errors[] = ActivityError::create($error);
48: }
49: } else {
50: unset($activity->errors);
51: }
52:
53:
54: if (array_key_exists('warnings', $props)) {
55: foreach ($props['warnings'] as $error) {
56: $activity->warnings[] = ActivityError::create($error);
57: }
58: } else {
59: unset($activity->warnings);
60: }
61:
62:
63: if (array_key_exists('file_name', $props)) {
64: $activity->file_name = $props['file_name'];
65: } else {
66: unset($activity->file_name);
67: }
68:
69: return $activity;
70: }
71:
72: 73: 74: 75:
76: public function toJson()
77: {
78: return json_encode($this);
79: }
80: }
81: