Skip to content
This repository was archived by the owner on Jan 26, 2022. It is now read-only.

Commit a41f25a

Browse files
author
Marc Zahn
committed
Merge remote-tracking branch 'origin/develop'
2 parents 8de8e02 + 05c4885 commit a41f25a

File tree

6 files changed

+512
-343
lines changed

6 files changed

+512
-343
lines changed

src/LooplineSystems/CloseIoApiWrapper/Api/ActivityApi.php

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
use LooplineSystems\CloseIoApiWrapper\CloseIoResponse;
66
use LooplineSystems\CloseIoApiWrapper\Library\Api\AbstractApi;
77
use LooplineSystems\CloseIoApiWrapper\Model\Activity;
8-
use LooplineSystems\CloseIoApiWrapper\Model\Call;
8+
use LooplineSystems\CloseIoApiWrapper\Model\CallActivity;
9+
use LooplineSystems\CloseIoApiWrapper\Model\EmailActivity;
10+
use LooplineSystems\CloseIoApiWrapper\Model\NoteActivity;
911

1012
class ActivityApi extends AbstractApi
1113
{
@@ -21,16 +23,18 @@ protected function initUrls()
2123
'add-note' => '/activity/note/',
2224
'get-notes' => '/activity/note/',
2325
'add-call' => '/activity/call/',
24-
'get-calls' => '/activity/call/'
26+
'get-calls' => '/activity/call/',
27+
'add-email' => '/activity/email/',
28+
'get-emails' => '/activity/email/',
2529
];
2630
}
2731

2832
/**
29-
* @param Activity $activity
33+
* @param NoteActivity $activity
3034
*
3135
* @return Activity
3236
*/
33-
public function addNote(Activity $activity)
37+
public function addNote(NoteActivity $activity)
3438
{
3539
$activity = json_encode($activity);
3640
$apiRequest = $this->prepareRequest('add-note', $activity);
@@ -41,24 +45,39 @@ public function addNote(Activity $activity)
4145
}
4246

4347
/**
44-
* @param Call $call
48+
* @param CallActivity $call
4549
*
46-
* @return Call
50+
* @return CallActivity
4751
*/
48-
public function addCall(Call $call)
52+
public function addCall(CallActivity $call)
4953
{
5054
$call = json_encode($call);
5155
$apiRequest = $this->prepareRequest('add-call', $call);
5256

5357
$result = $this->triggerPost($apiRequest);
5458

55-
return new Call($result->getData());
59+
return new CallActivity($result->getData());
60+
}
61+
62+
/**
63+
* @param EmailActivity $email
64+
*
65+
* @return EmailActivity
66+
*/
67+
public function addEmail(EmailActivity $email)
68+
{
69+
$email = json_encode($email);
70+
$apiRequest = $this->prepareRequest('add-email', $email);
71+
72+
$result = $this->triggerPost($apiRequest);
73+
74+
return new EmailActivity($result->getData());
5675
}
5776

5877
/**
5978
* @param array $filters
6079
*
61-
* @return array
80+
* @return NoteActivity[]
6281
*/
6382
public function getNotes(array $filters)
6483
{
@@ -69,7 +88,7 @@ public function getNotes(array $filters)
6988
$rawData = $result->getData()[CloseIoResponse::GET_RESPONSE_DATA_KEY];
7089
$notes = [];
7190
foreach ($rawData as $note) {
72-
$notes[] = new Activity($note);
91+
$notes[] = new NoteActivity($note);
7392
}
7493

7594
return $notes;
@@ -78,7 +97,7 @@ public function getNotes(array $filters)
7897
/**
7998
* @param array $filters
8099
*
81-
* @return array
100+
* @return CallActivity[]
82101
*/
83102
public function getCalls(array $filters)
84103
{
@@ -89,7 +108,27 @@ public function getCalls(array $filters)
89108
$rawData = $result->getData()[CloseIoResponse::GET_RESPONSE_DATA_KEY];
90109
$calls = [];
91110
foreach ($rawData as $call) {
92-
$calls[] = new Activity($call);
111+
$calls[] = new CallActivity($call);
112+
}
113+
114+
return $calls;
115+
}
116+
117+
/**
118+
* @param array $filters
119+
*
120+
* @return EmailActivity[]
121+
*/
122+
public function getEmails(array $filters)
123+
{
124+
$apiRequest = $this->prepareRequest('get-emails', null, [], $filters);
125+
126+
$result = $this->triggerGet($apiRequest);
127+
128+
$rawData = $result->getData()[CloseIoResponse::GET_RESPONSE_DATA_KEY];
129+
$calls = [];
130+
foreach ($rawData as $call) {
131+
$calls[] = new EmailActivity($call);
93132
}
94133

95134
return $calls;

src/LooplineSystems/CloseIoApiWrapper/Model/Activity.php

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,75 +10,74 @@ class Activity implements \JsonSerializable
1010
use ObjectHydrateHelperTrait;
1111
use JsonSerializableHelperTrait;
1212

13-
/**
14-
* @var string
15-
*/
16-
private $note;
13+
const ACTIVITY_TYPE_CALL = 'Call';
14+
const ACTIVITY_TYPE_EMAIL = 'Email';
15+
const ACTIVITY_TYPE_NOTE = 'Note';
1716

1817
/**
1918
* @var string
2019
*/
21-
private $user_id;
20+
protected $user_id;
2221

2322
/**
2423
* @var string
2524
*/
26-
private $user_name;
25+
protected $user_name;
2726

2827
/**
2928
* @var string
3029
*/
31-
private $updated_by;
30+
protected $updated_by;
3231

3332
/**
3433
* @var string
3534
*/
36-
private $updated_by_name;
35+
protected $updated_by_name;
3736

3837
/**
3938
* @var string
4039
*/
41-
private $date_updated;
40+
protected $date_updated;
4241

4342
/**
4443
* @var string
4544
*/
46-
private $created_by;
45+
protected $created_by;
4746

4847
/**
4948
* @var string
5049
*/
51-
private $created_by_name;
50+
protected $created_by_name;
5251

5352
/**
5453
* @var string
5554
*/
56-
private $organization_id;
55+
protected $organization_id;
5756

5857
/**
5958
* @var string
6059
*/
61-
private $contact_id;
60+
protected $contact_id;
6261

6362
/**
6463
* @var string
6564
*/
66-
private $date_created;
65+
protected $date_created;
6766

6867
/**
6968
* @var string
7069
*/
71-
private $id;
70+
protected $id;
7271

7372
/**
7473
* @var string
7574
*/
76-
private $lead_id;
75+
protected $lead_id;
7776

7877
/**
7978
* @var string
8079
*/
81-
private $type;
80+
protected $type;
8281

8382
/**
8483
* @param array $data
@@ -90,26 +89,6 @@ public function __construct(array $data = null)
9089
}
9190
}
9291

93-
/**
94-
* @return string
95-
*/
96-
public function getNote()
97-
{
98-
return $this->note;
99-
}
100-
101-
/**
102-
* @param string $note
103-
*
104-
* @return $this
105-
*/
106-
public function setNote($note)
107-
{
108-
$this->note = $note;
109-
110-
return $this;
111-
}
112-
11392
/**
11493
* @return string
11594
*/
@@ -360,12 +339,13 @@ public function getType()
360339

361340
/**
362341
* @param string $type
342+
*
343+
* @return Activity
363344
*/
364345
public function setType($type)
365346
{
366347
$this->type = $type;
367348

368349
return $this;
369350
}
370-
371351
}

0 commit comments

Comments
 (0)