127 $audience->setAccountId($accountId);
128 $audiencesResult = $audience->getList();
129 if ($audiencesResult->isSuccess())
131 while ($audienceData = $audiencesResult->fetch())
133 $audienceData = $audience->normalizeListRow($audienceData);
134 if ($audienceData[
'ID'])
137 'id' => $audienceData[
'ID'],
138 'isSupportMultiTypeContacts' => $audience->isSupportMultiTypeContacts(),
140 'supportedContactTypes' => $audienceData[
'SUPPORTED_CONTACT_TYPES'],
141 'status' => $audienceData[
'STATUS'] ??
'',
143 $audienceData[
'NAME']
145 $audienceData[
'NAME'] . (
146 $audienceData[
'COUNT_VALID'] > 0 ?
147 ' (' . $audienceData[
'COUNT_VALID'] .
')'
159 self::$errors = $audiencesResult->getErrorMessages();
167 $audiences = static::getAudiences($type, $accountId);
172 foreach ($audiences as &$audience)
174 $audienceStatus = $audience[
'status'];
176 $audience[
'normalizedStatus'] = $audienceStatusNormalizer->getNormalizedStatus($audienceStatus);
177 $audience[
'normalizedStatusMessage'] = $audienceStatusNormalizer->getNormalizedStatusTranslation($audienceStatus);
178 $audience[
'isEnabled'] = $audienceStatusNormalizer->isEnabled($audienceStatus);
203 $providers = static::getServiceProviders($types);
204 foreach ($providers as $type => $provider)
207 $providers[$type][
'URL_AUDIENCE_LIST'] = $audience->getUrlAudienceList();
208 $providers[$type][
'IS_SUPPORT_ACCOUNT'] = $audience->isSupportAccount();
209 $providers[$type][
'IS_SUPPORT_REMOVE_CONTACTS'] = $audience->isSupportRemoveContacts();
211 $providers[$type][
'IS_SUPPORT_MULTI_TYPE_CONTACTS'] = $audience->isSupportMultiTypeContacts();
212 $providers[$type][
'IS_SUPPORT_ADD_AUDIENCE'] = $audience->isSupportAddAudience();
213 $lookalikeAudienceParams = $audience->getLookalikeAudiencesParams();
214 $providers[$type][
'IS_SUPPORT_LOOKALIKE_AUDIENCE'] = !!$lookalikeAudienceParams;
215 $providers[$type][
'LOOKALIKE_AUDIENCE_PARAMS'] = $lookalikeAudienceParams;
216 $providers[$type][
'IS_SUPPORT_CREATE_LOOKALIKE_FROM_SEGMENTS'] = $audience::isSupportCreateLookalikeFromSegments();
230 static $audiences = array();
231 if (!isset($audiences[$config->type]))
233 if ($config->clientId)
235 $service = static::getService();
236 $service->setClientId($config->clientId);
239 $audiences[$config->type] = $audience;
243 $audience = $audiences[$config->type];
246 $audience->setAccountId($config->accountId);
247 static::$isQueueUsed ? $audience->enableQueueMode() : $audience->disableQueueMode();
248 if ($config->autoRemoveDayNumber)
250 $audience->enableQueueAutoRemove($config->autoRemoveDayNumber);
254 $audience->disableQueueAutoRemove();
257 $audienceImportResult = $audience->addContacts(
261 'type' => $config->contactType,
262 'parentId' => $config->parentId
266 self::$errors = $audienceImportResult->getErrorMessages();
267 return $audienceImportResult->isSuccess();
334 $typeList = static::getServiceTypes();
336 $providers = array();
337 foreach ($typeList as $type)
339 if ($types && !in_array($type, $types))
344 $service = static::getService();
345 $authAdapter = $service->getAuthAdapter($type);
346 $account = $service->getAccount($type);
347 $canUserMultiClients = $authAdapter->canUseMultipleClients();
349 $providers[$type] = array(
351 'HAS_AUTH' => $authAdapter->hasAuth(),
352 'AUTH_URL' => $authAdapter->getAuthUrl(),
353 'PROFILE' => $authAdapter->getToken() ? $account->getProfileCached() :
false,
354 'ENGINE_CODE' => $service::getEngineCode($type)
356 if ($canUserMultiClients)
358 $providers[$type][
'CLIENTS'] = static::getClientsProfiles($authAdapter);
359 if (empty($providers[$type][
'CLIENTS']))
361 $providers[$type][
'HAS_AUTH'] =
false;
366 if ($providers[$type][
'HAS_AUTH'] && empty($providers[$type][
'PROFILE']))
368 static::removeAuth($type);
369 if (!$canUserMultiClients)
371 $providers[$type][
'HAS_AUTH'] =
false;
419 if (!static::canUse())
426 $account = static::getService()->getAccount($type);
427 $accountsResult = $account->getList();
428 if ($accountsResult->isSuccess())
430 while ($accountData = $accountsResult->fetch())
432 $accountData = $account->normalizeListRow($accountData);
433 if ($accountData[
'ID'])
436 'id' => $accountData[
'ID'],
437 'name' => $accountData[
'NAME'] ? $accountData[
'NAME'] : $accountData[
'ID']
444 self::$errors = $accountsResult->getErrorMessages();