|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Hborras\TwitterAdsSDK\TwitterAds\Campaign; |
|
4
|
|
|
|
|
5
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Resource; |
|
6
|
|
|
use Hborras\TwitterAdsSDK\TwitterAdsException; |
|
7
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Errors\NotFound; |
|
8
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Errors\Forbidden; |
|
9
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Errors\RateLimit; |
|
10
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Errors\BadRequest; |
|
11
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Errors\ServerError; |
|
12
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Errors\NotAuthorized; |
|
13
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Fields\AppListFields; |
|
14
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Errors\ServiceUnavailable; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class AppList |
|
18
|
|
|
* @package Hborras\TwitterAdsSDK\TwitterAds\Campaign |
|
19
|
|
|
*/ |
|
20
|
|
|
class AppList extends Resource |
|
21
|
|
|
{ |
|
22
|
|
|
const RESOURCE_COLLECTION = 'accounts/{account_id}/app_lists'; |
|
23
|
|
|
const RESOURCE = 'accounts/{account_id}/app_lists/{id}'; |
|
24
|
|
|
|
|
25
|
|
|
/** Read Only */ |
|
26
|
|
|
protected $id; |
|
27
|
|
|
protected $name; |
|
28
|
|
|
protected $apps; |
|
29
|
|
|
|
|
30
|
|
|
protected $properties = [ |
|
31
|
|
|
]; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param $name |
|
35
|
|
|
* @param array $ids |
|
36
|
|
|
* @return AppList |
|
37
|
|
|
* @throws TwitterAdsException |
|
38
|
|
|
* @throws BadRequest |
|
39
|
|
|
* @throws Forbidden |
|
40
|
|
|
* @throws NotAuthorized |
|
41
|
|
|
* @throws NotFound |
|
42
|
|
|
* @throws RateLimit |
|
43
|
|
|
* @throws ServerError |
|
44
|
|
|
* @throws ServiceUnavailable |
|
45
|
|
|
*/ |
|
46
|
|
|
public function create($name, $ids = []) |
|
47
|
|
|
{ |
|
48
|
|
|
if (is_array($ids)) { |
|
49
|
|
|
$ids = implode(',', $ids); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
$resource = str_replace(static::RESOURCE_REPLACE, $this->getTwitterAds()->getAccountId(), static::RESOURCE_COLLECTION); |
|
53
|
|
|
$params = $this->toParams(); |
|
54
|
|
|
$params[AppListFields::APP_STORE_IDENTIFIERS] = $ids; |
|
55
|
|
|
$params[AppListFields::NAME] = $name; |
|
56
|
|
|
$response = $this->getTwitterAds()->get($resource, $params); |
|
57
|
|
|
|
|
58
|
|
|
return $this->fromResponse($response->getBody()->data); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @return mixed |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getId() |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->id; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @return mixed |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getName() |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->name; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @return mixed |
|
79
|
|
|
*/ |
|
80
|
|
|
public function getApps() |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->apps; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|