TransportMarketingFb::send

  1. Bitrix24 API (v. 23.675.0)
  2. sender
  3. TransportMarketingFb
  4. send
  • Модуль: sender
  • Путь к файлу: ~/bitrix/modules/sender/lib/integration/seo/ads/transportmarketingfb.php
  • Класс: Bitrix\Sender\Integration\Seo\Ads\TransportMarketingFb
  • Вызов: TransportMarketingFb::send
public function send(Message\Adapter $message)
{
	$config = $message->getConfiguration();
	$clientId = $config->get('CLIENT_ID');
	$accountId = $config->get('ACCOUNT_ID');
	$duration = $config->get('DURATION');
	$audienceId = $config->get('AUDIENCE_ID');
	$status = $config->get('STATUS');

	$service = Marketing\Configurator::getService();
	$service->setClientId($clientId);

	if(!$message->getRecipientCode())
	{
		$status = $config->set('STATUS', self::SEND_STATES['AUDIENCE_UPLOADED']);
		$message->saveConfiguration($config);
	}

	if (!$audienceId && $message->getRecipientCode())
	{
		$audiences = Marketing\Configurator::createAudience(
			Marketing\Services\AdCampaignFacebook::TYPE_CODE,
			[
				'accountId' => $accountId,
				'duration' => $duration
			]
		);
		$config->set('AUDIENCE_ID', $audiences['audienceId']);
		$config->set('AUDIENCE_PHONE_ID', $audiences['phoneAudienceId']);
		$config->set('AUDIENCE_EMAIL_ID', $audiences['emailAudienceId']);

		$status = $config->set('STATUS', self::SEND_STATES['AUDIENCE_CREATED']);
		$message->saveConfiguration($config);
	}

	if($status && in_array($status, [self::SEND_STATES['AUDIENCE_CREATED'],
			self::SEND_STATES['AUDIENCE_UPLOADING']]))
	{
		return parent::send($message);
	}
}

Добавить комментарий