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'; } }