31 'COUNT_VALID' =>
'COUNT',
32 'COUNT_MATCHED' =>
'COUNT',
33 'SUPPORTED_CONTACT_TYPES' => [
34 self::ENUM_CONTACT_TYPE_EMAIL,
35 self::ENUM_CONTACT_TYPE_PHONE,
36 self::ENUM_CONTACT_TYPE_IDFA_GAID,
37 self::ENUM_CONTACT_TYPE_INTERNAL_ID
48 parent::__construct();
58 return trim(mb_strtolower($email));
63 return preg_replace(
"/[^\+0-9]/",
'', $phone);
103 return static::URL_AUDIENCE_LIST;
108 return static::MAX_CONTACTS_PER_PACKET;
113 return static::MIN_CONTACTS_FOR_ACTIVATING;
118 $this->isQueueAutoRemove =
false;
123 $this->isQueueAutoRemove =
true;
126 $this->queueDaysAutoRemove = $daysNumber;
142 return $this->isQueueModeEnabled;
147 $itemsResult = $this->
getList();
148 while($itemData = $itemsResult->fetch())
151 if ($itemData[
'ID'] == $itemId)
163 foreach (static::$listRowMap[
'SUPPORTED_CONTACT_TYPES'] as $contactType)
165 if (!isset($contacts[$contactType]))
170 $contactsCount = count($contacts[$contactType]);
171 for ($i = 0; $i < $contactsCount; $i++)
173 if (empty($contacts[$contactType][$i]))
178 $contactPhone =
null;
179 $contact = $contacts[$contactType][$i];
180 switch ($contactType)
182 case self::ENUM_CONTACT_TYPE_EMAIL:
183 $contact = static::normalizeEmail($contact);
186 case self::ENUM_CONTACT_TYPE_PHONE:
187 $contact = static::normalizePhone($contact);
188 if (mb_substr($contact, 0, 1) ==
'8' && mb_strlen($contact) > 8)
190 $contactPhone =
'+7'.mb_substr($contact, 1);
197 $data[$contactType][] = $contact;
202 $data[$contactType][] = $contactPhone;
210 protected function addToQueue($audienceId, $contacts, $options = [], $isRemove =
false)
212 $dateAutoRemove =
null;
213 if ($this->isQueueAutoRemove && $this->queueDaysAutoRemove > 0)
216 $dateAutoRemove->add($this->queueDaysAutoRemove .
' DAY');
223 else if ($this->isQueueAutoRemove)
233 foreach (static::$listRowMap[
'SUPPORTED_CONTACT_TYPES'] as $contactType)
235 if (!isset($contacts[$contactType]))
240 $contactsCount = count($contacts[$contactType]);
241 for ($i = 0; $i < $contactsCount; $i++)
243 $contact = $contacts[$contactType][$i];
244 $resultDb = QueueTable::add(array(
245 'TYPE' => static::TYPE_CODE,
246 'ACCOUNT_ID' => $this->accountId,
249 'PARENT_ID' => $options[
'parentId'] ?:
null,
250 'CONTACT_TYPE' => $contactType,
253 'DATE_AUTO_REMOVE' => $dateAutoRemove,
255 $resultDb->isSuccess();
264 foreach (static::$listRowMap[
'SUPPORTED_CONTACT_TYPES'] as $contactType)
266 if (!isset($contacts[$contactType]))
271 $contactsCount = count($contacts[$contactType]);
272 for ($i = 0; $i < $contactsCount; $i++)
274 $contact = $contacts[$contactType][$i];
275 $itemDb = QueueTable::getList(array(
276 'select' => array(
'ID'),
278 'TYPE' => static::TYPE_CODE,
279 'ACCOUNT_ID' => $this->accountId,
281 'CONTACT_TYPE' => $contactType,
285 while ($item = $itemDb->fetch())
287 $result = QueueTable::delete($item[
'ID']);
288 $result->isSuccess();
302 public function addContacts($audienceId, array $contacts, array $options)
308 if ($this->emptyResponse ===
null)
311 $this->emptyResponse->setData(array());
314 return $this->emptyResponse;
334 $response->setData(array());
349 abstract public function add(array $data);
367 abstract protected function importContacts($audienceId, array $contacts, array $options);
378 abstract protected function removeContacts($audienceId, array $contacts, array $options);
387 return !QueueTable::getCount([
'=PARENT_ID' => $parentId]);
const ENUM_CONTACT_TYPE_INTERNAL_ID
const ENUM_CONTACT_TYPE_IDFA_GAID
deleteContacts($audienceId, array $contacts, array $options)
removeContacts($audienceId, array $contacts, array $options)
static getMaxContactsPerPacket()
static isAddingRequireContacts()
static normalizePhone($phone)
deleteFromQueue($audienceId, $contacts)
addToQueue($audienceId, $contacts, $options=[], $isRemove=false)
__construct($accountId=null)
static isSupportMultiTypeContacts()
enableQueueAutoRemove($daysNumber=null)
isQueueProcessed($parentId)
const ENUM_CONTACT_TYPE_PHONE
static normalizeEmail($email)
static isSupportAddAudience()
static getUrlAudienceList()
static isSupportAccount()
importContacts($audienceId, array $contacts, array $options)
normalizeContacts(array $contacts=array())
static isSupportRemoveContacts()
const MIN_CONTACTS_FOR_ACTIVATING
addContacts($audienceId, array $contacts, array $options)
const MAX_CONTACTS_PER_PACKET
getLookalikeAudiencesParams()
static isSupportCreateLookalikeFromSegments()
static getMinContactsForActivating()
const ENUM_CONTACT_TYPE_EMAIL
createLookalike($sourceAudienceId, array $options)
static normalizeListRow(array $row)
const ACTION_IMPORT_AND_AUTO_REMOVE