diff --git a/src/LooplineSystems/CloseIoApiWrapper/Api/ActivityApi.php b/src/LooplineSystems/CloseIoApiWrapper/Api/ActivityApi.php index 594b079..180ad90 100644 --- a/src/LooplineSystems/CloseIoApiWrapper/Api/ActivityApi.php +++ b/src/LooplineSystems/CloseIoApiWrapper/Api/ActivityApi.php @@ -5,7 +5,9 @@ use LooplineSystems\CloseIoApiWrapper\CloseIoResponse; use LooplineSystems\CloseIoApiWrapper\Library\Api\AbstractApi; use LooplineSystems\CloseIoApiWrapper\Model\Activity; -use LooplineSystems\CloseIoApiWrapper\Model\Call; +use LooplineSystems\CloseIoApiWrapper\Model\CallActivity; +use LooplineSystems\CloseIoApiWrapper\Model\EmailActivity; +use LooplineSystems\CloseIoApiWrapper\Model\NoteActivity; class ActivityApi extends AbstractApi { @@ -21,16 +23,18 @@ protected function initUrls() 'add-note' => '/activity/note/', 'get-notes' => '/activity/note/', 'add-call' => '/activity/call/', - 'get-calls' => '/activity/call/' + 'get-calls' => '/activity/call/', + 'add-email' => '/activity/email/', + 'get-emails' => '/activity/email/', ]; } /** - * @param Activity $activity + * @param NoteActivity $activity * * @return Activity */ - public function addNote(Activity $activity) + public function addNote(NoteActivity $activity) { $activity = json_encode($activity); $apiRequest = $this->prepareRequest('add-note', $activity); @@ -41,24 +45,39 @@ public function addNote(Activity $activity) } /** - * @param Call $call + * @param CallActivity $call * - * @return Call + * @return CallActivity */ - public function addCall(Call $call) + public function addCall(CallActivity $call) { $call = json_encode($call); $apiRequest = $this->prepareRequest('add-call', $call); $result = $this->triggerPost($apiRequest); - return new Call($result->getData()); + return new CallActivity($result->getData()); + } + + /** + * @param EmailActivity $email + * + * @return EmailActivity + */ + public function addEmail(EmailActivity $email) + { + $email = json_encode($email); + $apiRequest = $this->prepareRequest('add-email', $email); + + $result = $this->triggerPost($apiRequest); + + return new EmailActivity($result->getData()); } /** * @param array $filters * - * @return array + * @return NoteActivity[] */ public function getNotes(array $filters) { @@ -69,7 +88,7 @@ public function getNotes(array $filters) $rawData = $result->getData()[CloseIoResponse::GET_RESPONSE_DATA_KEY]; $notes = []; foreach ($rawData as $note) { - $notes[] = new Activity($note); + $notes[] = new NoteActivity($note); } return $notes; @@ -78,7 +97,7 @@ public function getNotes(array $filters) /** * @param array $filters * - * @return array + * @return CallActivity[] */ public function getCalls(array $filters) { @@ -89,7 +108,27 @@ public function getCalls(array $filters) $rawData = $result->getData()[CloseIoResponse::GET_RESPONSE_DATA_KEY]; $calls = []; foreach ($rawData as $call) { - $calls[] = new Activity($call); + $calls[] = new CallActivity($call); + } + + return $calls; + } + + /** + * @param array $filters + * + * @return EmailActivity[] + */ + public function getEmails(array $filters) + { + $apiRequest = $this->prepareRequest('get-emails', null, [], $filters); + + $result = $this->triggerGet($apiRequest); + + $rawData = $result->getData()[CloseIoResponse::GET_RESPONSE_DATA_KEY]; + $calls = []; + foreach ($rawData as $call) { + $calls[] = new EmailActivity($call); } return $calls; diff --git a/src/LooplineSystems/CloseIoApiWrapper/Model/Activity.php b/src/LooplineSystems/CloseIoApiWrapper/Model/Activity.php index 1120ba6..2819705 100644 --- a/src/LooplineSystems/CloseIoApiWrapper/Model/Activity.php +++ b/src/LooplineSystems/CloseIoApiWrapper/Model/Activity.php @@ -10,75 +10,74 @@ class Activity implements \JsonSerializable use ObjectHydrateHelperTrait; use JsonSerializableHelperTrait; - /** - * @var string - */ - private $note; + const ACTIVITY_TYPE_CALL = 'Call'; + const ACTIVITY_TYPE_EMAIL = 'Email'; + const ACTIVITY_TYPE_NOTE = 'Note'; /** * @var string */ - private $user_id; + protected $user_id; /** * @var string */ - private $user_name; + protected $user_name; /** * @var string */ - private $updated_by; + protected $updated_by; /** * @var string */ - private $updated_by_name; + protected $updated_by_name; /** * @var string */ - private $date_updated; + protected $date_updated; /** * @var string */ - private $created_by; + protected $created_by; /** * @var string */ - private $created_by_name; + protected $created_by_name; /** * @var string */ - private $organization_id; + protected $organization_id; /** * @var string */ - private $contact_id; + protected $contact_id; /** * @var string */ - private $date_created; + protected $date_created; /** * @var string */ - private $id; + protected $id; /** * @var string */ - private $lead_id; + protected $lead_id; /** * @var string */ - private $type; + protected $type; /** * @param array $data @@ -90,26 +89,6 @@ public function __construct(array $data = null) } } - /** - * @return string - */ - public function getNote() - { - return $this->note; - } - - /** - * @param string $note - * - * @return $this - */ - public function setNote($note) - { - $this->note = $note; - - return $this; - } - /** * @return string */ @@ -360,6 +339,8 @@ public function getType() /** * @param string $type + * + * @return Activity */ public function setType($type) { @@ -367,5 +348,4 @@ public function setType($type) return $this; } - } diff --git a/src/LooplineSystems/CloseIoApiWrapper/Model/Call.php b/src/LooplineSystems/CloseIoApiWrapper/Model/Call.php deleted file mode 100644 index f2b6082..0000000 --- a/src/LooplineSystems/CloseIoApiWrapper/Model/Call.php +++ /dev/null @@ -1,293 +0,0 @@ -hydrate($data, []); - } - } - - /** - * @return string - */ - public function getId() - { - return $this->id; - } - - /** - * @param string $id - */ - public function setId($id) - { - $this->id = $id; - - return $this; - } - - /** - * @return string - */ - public function getLeadId() - { - return $this->lead_id; - } - - /** - * @param string $lead_id - * - * @return Call - */ - public function setLeadId($lead_id) - { - $this->lead_id = $lead_id; - - return $this; - } - - /** - * @return string - */ - public function getContactId() - { - return $this->contact_id; - } - - /** - * @param string $contact_id - * - * @return Call - */ - public function setContactId($contact_id) - { - $this->contact_id = $contact_id; - - return $this; - } - - /** - * @return string - */ - public function getCreatedBy() - { - return $this->created_by; - } - - /** - * @param string $created_by - * - * @return Call - */ - public function setCreatedBy($created_by) - { - $this->created_by = $created_by; - - return $this; - } - - /** - * @return string - */ - public function getUserId() - { - return $this->user_id; - } - - /** - * @param string $user_id - * - * @return Call - */ - public function setUserId($user_id) - { - $this->user_id = $user_id; - - return $this; - } - - /** - * @return string - */ - public function getDirection() - { - return $this->direction; - } - - /** - * @param string $direction - * - * @return Call - */ - public function setDirection($direction) - { - $this->direction = $direction; - - return $this; - } - - /** - * @return string - */ - public function getStatus() - { - return $this->status; - } - - /** - * @param string $status - * - * @return Call - */ - public function setStatus($status) - { - $this->status = $status; - - return $this; - } - - /** - * @return string - */ - public function getNote() - { - return $this->note; - } - - /** - * @param string $note - * - * @return Call - */ - public function setNote($note) - { - $this->note = $note; - - return $this; - } - - /** - * @return int - */ - public function getDuration() - { - return $this->duration; - } - - /** - * @param int $duration - * - * @return Call - */ - public function setDuration($duration) - { - $this->duration = $duration; - - return $this; - } - - /** - * @return string - */ - public function getPhone() - { - return $this->phone; - } - - /** - * @param string $phone - * - * @return Call - */ - public function setPhone($phone) - { - $this->phone = $phone; - - return $this; - } - - /** - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * @param string $type - */ - public function setType($type) - { - $this->type = $type; - - return $this; - } -} diff --git a/src/LooplineSystems/CloseIoApiWrapper/Model/CallActivity.php b/src/LooplineSystems/CloseIoApiWrapper/Model/CallActivity.php new file mode 100644 index 0000000..21626a3 --- /dev/null +++ b/src/LooplineSystems/CloseIoApiWrapper/Model/CallActivity.php @@ -0,0 +1,167 @@ +direction; + } + + /** + * @param string $direction + * + * @return CallActivity + */ + public function setDirection($direction) + { + $this->direction = $direction; + + return $this; + } + + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param string $status + * + * @return CallActivity + */ + public function setStatus($status) + { + $this->status = $status; + + return $this; + } + + /** + * @return string + */ + public function getNote() + { + return $this->note; + } + + /** + * @param string $note + * + * @return CallActivity + */ + public function setNote($note) + { + $this->note = $note; + + return $this; + } + + /** + * @return int + */ + public function getDuration() + { + return $this->duration; + } + + /** + * @param int $duration + * + * @return CallActivity + */ + public function setDuration($duration) + { + $this->duration = $duration; + + return $this; + } + + /** + * @return string + */ + public function getPhone() + { + return $this->phone; + } + + /** + * @param string $phone + * + * @return CallActivity + */ + public function setPhone($phone) + { + $this->phone = $phone; + + return $this; + } + + /** + * @return string + */ + public function getRecordingURL() + { + return $this->recording_url; + } + + /** + * @param $url + * + * @return CallActivity + */ + public function setRecordingURL($url) + { + $this->recording_url = $url; + + return $this; + } +} diff --git a/src/LooplineSystems/CloseIoApiWrapper/Model/EmailActivity.php b/src/LooplineSystems/CloseIoApiWrapper/Model/EmailActivity.php new file mode 100644 index 0000000..b47eaaf --- /dev/null +++ b/src/LooplineSystems/CloseIoApiWrapper/Model/EmailActivity.php @@ -0,0 +1,235 @@ +subject; + } + + /** + * @param string $subject + * @return EmailActivity + */ + public function setSubject($subject) + { + $this->subject = $subject; + return $this; + } + + /** + * @return string + */ + public function getSender() + { + return $this->sender; + } + + /** + * @param string $sender + * @return EmailActivity + */ + public function setSender($sender) + { + $this->sender = $sender; + return $this; + } + + /** + * @return mixed + */ + public function getTo() + { + return $this->to; + } + + /** + * @param mixed $to + * @return EmailActivity + */ + public function setTo($to) + { + $this->to = $to; + return $this; + } + + /** + * @return mixed + */ + public function getBcc() + { + return $this->bcc; + } + + /** + * @param mixed $bcc + * @return EmailActivity + */ + public function setBcc($bcc) + { + $this->bcc = $bcc; + return $this; + } + + /** + * @return mixed + */ + public function getCc() + { + return $this->cc; + } + + /** + * @param mixed $cc + * @return EmailActivity + */ + public function setCc($cc) + { + $this->cc = $cc; + return $this; + } + + /** + * @return string + */ + public function getBodyText() + { + return $this->body_text; + } + + /** + * @param string $body_text + * @return EmailActivity + */ + public function setBodyText($body_text) + { + $this->body_text = $body_text; + return $this; + } + + /** + * @return string + */ + public function getBodyHtml() + { + return $this->body_html; + } + + /** + * @param string $body_html + * @return EmailActivity + */ + public function setBodyHtml($body_html) + { + $this->body_html = $body_html; + return $this; + } + + /** + * @return mixed + */ + public function getDirection() + { + return $this->direction; + } + + /** + * @param $direction + * @return EmailActivity + */ + public function setDirection($direction) + { + $this->direction = $direction; + return $this; + } + + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param $status + * @return EmailActivity + */ + public function setStatus($status) + { + $this->status = $status; + return $this; + } + + /** + * @return string + */ + public function getDateScheduled() + { + return $this->date_scheduled; + } + + /** + * @param string $date_scheduled + * @return EmailActivity + */ + public function setDateScheduled($date_scheduled) + { + $this->date_scheduled = $date_scheduled; + return $this; + } +} diff --git a/src/LooplineSystems/CloseIoApiWrapper/Model/NoteActivity.php b/src/LooplineSystems/CloseIoApiWrapper/Model/NoteActivity.php new file mode 100644 index 0000000..2f0395a --- /dev/null +++ b/src/LooplineSystems/CloseIoApiWrapper/Model/NoteActivity.php @@ -0,0 +1,41 @@ +note; + } + + /** + * @param string $note + * + * @return NoteActivity + */ + public function setNote($note) + { + $this->note = $note; + + return $this; + } +}