403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/seo/lib/marketing/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/seo/lib/marketing/service.php
<?

namespace Bitrix\Seo\Marketing;

use Bitrix\Main\Config\Option;
use Bitrix\Seo\BusinessSuite\IInternalService;
use Bitrix\Seo\Retargeting\AuthAdapter;
use Bitrix\Seo\Retargeting\IMultiClientService;
use Bitrix\Seo\Retargeting\IService;

/**
 * Class Service
 *
 * @package Bitrix\Seo\Marketing
 */
class Service implements IService, IMultiClientService, IInternalService
{
	const GROUP         = 'marketing';
	const TYPE_FACEBOOK = 'facebook';
	const TYPE_INSTAGRAM = 'instagram';
	protected $clientId;

	/**
	 * Get instance.
	 *
	 * @return static
	 */
	public static function getInstance()
	{
		static $instance = null;
		if ($instance === null)
		{
			$instance = new static();
		}

		return $instance;
	}

	/**
	 * Get engine code by type.
	 *
	 * @param string $type Type
	 *
	 * @return string
	 */
	public static function getEngineCode($type)
	{
		return static::GROUP.'.'.$type;
	}

	/**
	 * Get Account by type.
	 *
	 * @param string $type Type
	 *
	 * @return Account
	 */
	public static function getAccount($type)
	{
		static $account = null;
		if ($account === null)
		{
			$account = Account::create($type)
				->setService(static::getInstance());
		}

		return $account;
	}

	/**
	 * @param $type
	 * @param array $data
	 *
	 * @return mixed
	 */
	public static function createCampaign($type, array $data)
	{
		return AdCampaign::create($type)
			->setService(static::getInstance())
			->createCampaign($data);
	}

	/**
	 * @param $type
	 * @param array $data
	 *
	 * @return mixed
	 */
	public static function createAudience($type, array $data)
	{
		return Audience::create($type)
			->setService(static::getInstance())
			->add($data);
	}

	/**
	 * @param $type
	 * @param $accountId
	 *
	 * @return array|null
	 */
	public static function getPostList($type, $params)
	{
		return PostList::create($type)
			->setService(static::getInstance())
			->getList($params);
	}

	/**
	 * @param $type
	 *
	 * @return Audience|null
	 */
	public static function getAudience($type)
	{
		return Audience::create($type)
			->setService(static::getInstance());
	}

	/**
	 * @param $type
	 * @param $accountId
	 *
	 * @return array|null
	 */
	public static function getAudienceList($type, $accountId)
	{
		return Audience::create($type)
			->setService(static::getInstance())
			->getList($accountId);
	}

	/**
	 * @param $type
	 * @param $accountId
	 *
	 * @return array|null
	 */
	public static function getAdSetList($type, $accountId)
	{
		return AdCampaign::create($type)
			->setService(static::getInstance())
			->getAdSetList($accountId);
	}

	/**
	 * @param $type
	 * @param $adsId
	 *
	 * @return mixed
	 */
	public static function getAds($type, $adsId)
	{
		return AdCampaign::create($type)
			->setService(static::getInstance())
			->getAds($adsId);
	}

	/**
	 * @param $type
	 * @param $adsId
	 *
	 * @return mixed
	 */
	public static function searchTargetingData($type, $params)
	{
		return AdCampaign::create($type)
			->setService(static::getInstance())
			->searchTargetingData($params);
	}

	/**
	 * @param $type
	 * @param $accountId
	 *
	 * @return array|null
	 */
	public static function getCampaignList($type, $accountId)
	{
		return AdCampaign::create($type)
			->setService(static::getInstance())
			->getCampaignList($accountId);
	}

	/**
	 * Get type list.
	 *
	 * @return array
	 */
	public static function getTypes()
	{
		return [
			static::TYPE_FACEBOOK,
			static::TYPE_INSTAGRAM,
		];
	}

	/**
	 * Get auth adapter.
	 *
	 * @param string $type Type.
	 *
	 * @return AuthAdapter
	 */
	public static function getAuthAdapter($type)
	{
		return AuthAdapter::create($type)
			->setService(static::getInstance());
	}

	/**
	 * Get client id
	 * @return string
	 */
	public function getClientId()
	{
		return $this->clientId;
	}

	/**
	 * Set client id.
	 *
	 * @param string $clientId Client id.
	 *
	 * @return void
	 */
	public function setClientId($clientId)
	{
		$this->clientId = $clientId;
	}

	/**
	 * Can use multiple clients
	 * @return bool
	 * @throws \Bitrix\Main\ArgumentNullException
	 * @throws \Bitrix\Main\ArgumentOutOfRangeException
	 */
	public static function canUseMultipleClients()
	{
		return Option::get('seo', 'use_multiple_clients', true);
	}

	/**
	 * @inheritDoc
	 */
	public static function getTypeByEngine(string $engineCode): ?string
	{
		foreach (static::getTypes() as $type)
		{
			if($engineCode === static::getEngineCode($type))
			{
				return $type;
			}
		}
		return null;
	}

	/**
	 * @inheritDoc
	 */
	public static function canUseAsInternal(): bool
	{
		return true;
	}

	/**
	 * @inheritDoc
	 */
	public static function getMethodPrefix(): string
	{
		return 'marketing';
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit