Commit 3267dfa0 authored by Shakarim Sapa's avatar Shakarim Sapa

Добавлены:

 - Метод возвращающий статусы рассылок;
 - Метод возвращающий проверку на прочтенность письма;
parent 7b727c26
<?php <?php
namespace common\components; namespace common\components;
use common\modules\triggers\components\conditions\vendor\ConditionBase;
use yii\helpers\Json; use yii\helpers\Json;
/** /**
...@@ -39,6 +40,11 @@ class UnisenderAPI { ...@@ -39,6 +40,11 @@ class UnisenderAPI {
*/ */
protected $visitedLinks = []; protected $visitedLinks = [];
/**
* @var array
*/
protected $statuses = [];
/** /**
* @param string $ApiKey * @param string $ApiKey
* @param string $Encoding * @param string $Encoding
...@@ -94,6 +100,36 @@ class UnisenderAPI { ...@@ -94,6 +100,36 @@ class UnisenderAPI {
); );
} }
/**
* @param $message_id
* @return array
*/
public function getMessageStatuses($message_id){
$this->statuses = $this->callMethod(
'checkEmail',
[
'email_id' => $message_id
]
);
$this->statuses = Json::decode($this->statuses);
return $this->statuses;
}
/**
* @return bool
*/
public function isReaded(){
if (array_key_exists('result', $this->statuses) && array_key_exists('status', $this->statuses['result'])) {
if ($this->statuses['result']['status']==ConditionBase::MESSAGE_READ)
return true;
}
return false;
}
/**
* @param $campaign_id
* @return mixed
*/
public function getVisitedLinks($campaign_id){ public function getVisitedLinks($campaign_id){
$this->visitedLinks = $this->callMethod( $this->visitedLinks = $this->callMethod(
'getVisitedLinks', 'getVisitedLinks',
...@@ -105,6 +141,11 @@ class UnisenderAPI { ...@@ -105,6 +141,11 @@ class UnisenderAPI {
return $this->visitedLinks; return $this->visitedLinks;
} }
/**
* @param $email
* @param $link
* @return bool
*/
public function linkIsVisited($email, $link) { public function linkIsVisited($email, $link) {
if (array_key_exists('result', $this->visitedLinks) && array_key_exists('data', $this->visitedLinks['result'])) { if (array_key_exists('result', $this->visitedLinks) && array_key_exists('data', $this->visitedLinks['result'])) {
foreach($this->visitedLinks['result']['data'] as $transition) { foreach($this->visitedLinks['result']['data'] as $transition) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment