Completed
Push — master ( 2819a7...5729e4 )
by Hector
11s
created

TargetingCriteria::getTailoredAudienceExpansion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Hborras\TwitterAdsSDK\TwitterAds\Campaign;
4
5
use Hborras\TwitterAdsSDK\TwitterAds\Cursor;
6
use Hborras\TwitterAdsSDK\TwitterAds\Errors\MethodNotAllowedException;
7
use Hborras\TwitterAdsSDK\TwitterAds\Fields\TargetingCriteriaFields;
8
use Hborras\TwitterAdsSDK\TwitterAds\Resource;
9
10
class TargetingCriteria extends Resource
11
{
12
    const RESOURCE_COLLECTION = 'accounts/{account_id}/targeting_criteria';
13
    const RESOURCE            = 'accounts/{account_id}/targeting_criteria/{id}';
14
15
    /** Read Only */
16
    protected $id;
17
    protected $localized_name;
18
    protected $name;
19
    protected $created_at;
20
    protected $updated_at;
21
    protected $deleted;
22
23
    protected $properties = [
24
        TargetingCriteriaFields::LINE_ITEM_ID,
25
        TargetingCriteriaFields::TARGETING_TYPE,
26
        TargetingCriteriaFields::TARGETING_VALUE,
27
        TargetingCriteriaFields::TAILORED_AUDIENCE_EXPANSION,
28
        TargetingCriteriaFields::TAILORED_AUDIENCE_TYPE,
29
    ];
30
31
    protected $line_item_id;
32
    protected $targeting_type;
33
    protected $targeting_value;
34
    protected $tailored_audience_expansion;
35
    protected $tailored_audience_type;
36
37
    /**
38
     * @param $line_item_id
39
     * @param array $params
40
     *
41
     * @return Cursor
42
     */
43
    public function line_item_all($line_item_id, $params = [])
44
    {
45
        $params[TargetingCriteriaFields::LINE_ITEM_ID] = $line_item_id;
46
47
        $resource = str_replace(static::RESOURCE_REPLACE, $this->getTwitterAds()->getAccountId(), static::RESOURCE_COLLECTION);
48
        $request = $this->getTwitterAds()->get($resource, $params);
49
50
        return new Cursor($this, $this->getTwitterAds(), $request->getBody(), $params);
51
    }
52
53
    
54
    public function save()
55
    {
56
        if ($this->getId()) {
57
            throw new MethodNotAllowedException();
58
        } else {
59
            return parent::save();
60
        }
61
    }
62
63
    /**
64
     * @return mixed
65
     */
66
    public function getName()
67
    {
68
        return $this->name;
69
    }
70
71
    /**
72
     * @return mixed
73
     */
74
    public function getId()
75
    {
76
        return $this->id;
77
    }
78
79
    /**
80
     * @return mixed
81
     */
82
    public function getLocalizedName()
83
    {
84
        return $this->localized_name;
85
    }
86
87
    /**
88
     * @return mixed
89
     */
90
    public function getCreatedAt()
91
    {
92
        return $this->created_at;
93
    }
94
95
    /**
96
     * @return mixed
97
     */
98
    public function getUpdatedAt()
99
    {
100
        return $this->updated_at;
101
    }
102
103
    /**
104
     * @return mixed
105
     */
106
    public function getDeleted()
107
    {
108
        return $this->deleted;
109
    }
110
111
    /**
112
     * @return array
113
     */
114
    public function getProperties()
115
    {
116
        return $this->properties;
117
    }
118
119
    /**
120
     * @return mixed
121
     */
122
    public function getLineItemId()
123
    {
124
        return $this->line_item_id;
125
    }
126
127
    /**
128
     * @return mixed
129
     */
130
    public function getTargetingType()
131
    {
132
        return $this->targeting_type;
133
    }
134
135
    /**
136
     * @return mixed
137
     */
138
    public function getTargetingValue()
139
    {
140
        return $this->targeting_value;
141
    }
142
143
    /**
144
     * @return mixed
145
     */
146
    public function getTailoredAudienceExpansion()
147
    {
148
        return $this->tailored_audience_expansion;
149
    }
150
151
    /**
152
     * @return mixed
153
     */
154
    public function getTailoredAudienceType()
155
    {
156
        return $this->tailored_audience_type;
157
    }
158
159
    /**
160
     * @param array $properties
161
     */
162
    public function setProperties($properties)
163
    {
164
        $this->properties = $properties;
165
    }
166
167
    /**
168
     * @param mixed $line_item_id
169
     */
170
    public function setLineItemId($line_item_id)
171
    {
172
        $this->line_item_id = $line_item_id;
173
    }
174
175
    /**
176
     * @param mixed $targeting_type
177
     */
178
    public function setTargetingType($targeting_type)
179
    {
180
        $this->targeting_type = $targeting_type;
181
    }
182
183
    /**
184
     * @param mixed $targeting_value
185
     */
186
    public function setTargetingValue($targeting_value)
187
    {
188
        $this->targeting_value = $targeting_value;
189
    }
190
191
    /**
192
     * @param mixed $tailored_audience_expansion
193
     */
194
    public function setTailoredAudienceExpansion($tailored_audience_expansion)
195
    {
196
        $this->tailored_audience_expansion = $tailored_audience_expansion;
197
    }
198
199
    /**
200
     * @param mixed $tailored_audience_type
201
     */
202
    public function setTailoredAudienceType($tailored_audience_type)
203
    {
204
        $this->tailored_audience_type = $tailored_audience_type;
205
    }
206
}
207