Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
service.php
1<?
2
4
10
17{
18 const GROUP = 'marketing';
19 const TYPE_FACEBOOK = 'facebook';
20 const TYPE_INSTAGRAM = 'instagram';
21 protected $clientId;
22
28 public static function getInstance()
29 {
30 static $instance = null;
31 if ($instance === null)
32 {
33 $instance = new static();
34 }
35
36 return $instance;
37 }
38
46 public static function getEngineCode($type)
47 {
48 return static::GROUP.'.'.$type;
49 }
50
58 public static function getAccount($type)
59 {
60 static $account = null;
61 if ($account === null)
62 {
63 $account = Account::create($type)
64 ->setService(static::getInstance());
65 }
66
67 return $account;
68 }
69
76 public static function createCampaign($type, array $data)
77 {
78 return AdCampaign::create($type)
79 ->setService(static::getInstance())
80 ->createCampaign($data);
81 }
82
89 public static function createAudience($type, array $data)
90 {
91 return Audience::create($type)
92 ->setService(static::getInstance())
93 ->add($data);
94 }
95
102 public static function getPostList($type, $params)
103 {
104 return PostList::create($type)
105 ->setService(static::getInstance())
106 ->getList($params);
107 }
108
114 public static function getAudience($type)
115 {
116 return Audience::create($type)
117 ->setService(static::getInstance());
118 }
119
126 public static function getAudienceList($type, $accountId)
127 {
128 return Audience::create($type)
129 ->setService(static::getInstance())
130 ->getList($accountId);
131 }
132
139 public static function getAdSetList($type, $accountId)
140 {
141 return AdCampaign::create($type)
142 ->setService(static::getInstance())
143 ->getAdSetList($accountId);
144 }
145
152 public static function getAds($type, $adsId)
153 {
154 return AdCampaign::create($type)
155 ->setService(static::getInstance())
156 ->getAds($adsId);
157 }
158
165 public static function searchTargetingData($type, $params)
166 {
167 return AdCampaign::create($type)
168 ->setService(static::getInstance())
169 ->searchTargetingData($params);
170 }
171
178 public static function getCampaignList($type, $accountId)
179 {
180 return AdCampaign::create($type)
181 ->setService(static::getInstance())
182 ->getCampaignList($accountId);
183 }
184
190 public static function getTypes()
191 {
192 return [
193 static::TYPE_FACEBOOK,
194 static::TYPE_INSTAGRAM,
195 ];
196 }
197
205 public static function getAuthAdapter($type)
206 {
207 return AuthAdapter::create($type)
208 ->setService(static::getInstance());
209 }
210
215 public function getClientId()
216 {
217 return $this->clientId;
218 }
219
227 public function setClientId($clientId)
228 {
229 $this->clientId = $clientId;
230 }
231
238 public static function canUseMultipleClients()
239 {
240 return Option::get('seo', 'use_multiple_clients', true);
241 }
242
246 public static function getTypeByEngine(string $engineCode): ?string
247 {
248 foreach (static::getTypes() as $type)
249 {
250 if($engineCode === static::getEngineCode($type))
251 {
252 return $type;
253 }
254 }
255 return null;
256 }
257
261 public static function canUseAsInternal(): bool
262 {
263 return true;
264 }
265
269 public static function getMethodPrefix(): string
270 {
271 return 'marketing';
272 }
273}
static createAudience($type, array $data)
Definition service.php:89
static createCampaign($type, array $data)
Definition service.php:76
static getEngineCode($type)
Definition service.php:46
static getAdSetList($type, $accountId)
Definition service.php:139
static getAudienceList($type, $accountId)
Definition service.php:126
static getTypeByEngine(string $engineCode)
Definition service.php:246
static getAds($type, $adsId)
Definition service.php:152
static getCampaignList($type, $accountId)
Definition service.php:178
static getPostList($type, $params)
Definition service.php:102
static searchTargetingData($type, $params)
Definition service.php:165
static getAuthAdapter($type)
Definition service.php:205