Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit c710c7f

Browse files
authored
Merge pull request #95 from hborras/v9
Easy and small changes
2 parents 36148e0 + d4de4c7 commit c710c7f

File tree

5 files changed

+55
-78
lines changed

5 files changed

+55
-78
lines changed

examples/analytics.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@
4343
echo "\t" . $j . ': ' . $lineItem->getId() . ' ' . $lineItem->getName() . ' ' . PHP_EOL;
4444
echo "\t\tBid: " . ($lineItem->getBidAmountLocalMicro() / 1000000) . PHP_EOL;
4545
echo "\t\tObjective: " . $lineItem->getObjective() . PHP_EOL;
46-
echo "\t\tCharge By: " . $lineItem->getChargeBy() . PHP_EOL;
47-
echo "\t\tBid Unit: " . $lineItem->getBidUnit() . PHP_EOL;
48-
echo "\t\tOptimization: " . $lineItem->getOptimization() . PHP_EOL;
49-
echo "\t\tBid Type: " . $lineItem->getBidType() . PHP_EOL;
46+
echo "\t\tCharge By: " . $lineItem->getPayBy() . PHP_EOL;
47+
echo "\t\tBid Strategy: " . $lineItem->getBidStrategy() . PHP_EOL;
5048
$targetingCriterias = $lineItem->getTargetingCriteria();
5149
/** @var TwitterAds\Campaign\TargetingCriteria $targetingCriteria */
5250
foreach ($targetingCriterias as $targetingCriteria) {
@@ -146,4 +144,4 @@ function dateRanges($startTime, $endTime)
146144
}
147145

148146
return $dates;
149-
}
147+
}

examples/analytics_async.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@
4343
echo "\t" . $j . ': ' . $lineItem->getId() . ' ' . $lineItem->getName() . ' ' . PHP_EOL;
4444
echo "\t\tBid: " . ($lineItem->getBidAmountLocalMicro() / 1000000) . PHP_EOL;
4545
echo "\t\tObjective: " . $lineItem->getObjective() . PHP_EOL;
46-
echo "\t\tCharge By: " . $lineItem->getChargeBy() . PHP_EOL;
47-
echo "\t\tBid Unit: " . $lineItem->getBidUnit() . PHP_EOL;
48-
echo "\t\tOptimization: " . $lineItem->getOptimization() . PHP_EOL;
49-
echo "\t\tBid Type: " . $lineItem->getBidType() . PHP_EOL;
46+
echo "\t\tCharge By: " . $lineItem->getPayBy() . PHP_EOL;
47+
echo "\t\tBid Strategy: " . $lineItem->getBidStrategy() . PHP_EOL;
5048
$targetingCriterias = $lineItem->getTargetingCriteria();
5149
/** @var TwitterAds\Campaign\TargetingCriteria $targetingCriteria */
5250
foreach ($targetingCriterias as $targetingCriteria) {
@@ -100,7 +98,7 @@
10098
}
10199
}
102100
}
103-
101+
104102
} catch (TwitterAdsException $e) {
105103
print_r($e->getErrors());
106104
}
@@ -157,4 +155,4 @@ function dateRanges($startTime, $endTime)
157155
}
158156

159157
return $dates;
160-
}
158+
}

src/TwitterAds.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class TwitterAds extends Config
2222
{
23-
const API_VERSION = '8';
23+
const API_VERSION = '9';
2424
const API_REST_VERSION = '1.1';
2525
const API_HOST = 'https://ads-api.twitter.com';
2626
const API_HOST_SANDBOX = 'https://ads-api-sandbox.twitter.com';

src/TwitterAds/Campaign/LineItem.php

Lines changed: 42 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
namespace Hborras\TwitterAdsSDK\TwitterAds\Campaign;
44

5-
use Hborras\TwitterAdsSDK\TwitterAds\Cursor;
6-
use Hborras\TwitterAdsSDK\TwitterAdsException;
75
use Hborras\TwitterAdsSDK\TwitterAds\Analytics;
86
use Hborras\TwitterAdsSDK\TwitterAds\Analytics\Job;
9-
use Hborras\TwitterAdsSDK\TwitterAds\Errors\BadRequest;
10-
use Hborras\TwitterAdsSDK\TwitterAds\Fields\LineItemFields;
117
use Hborras\TwitterAdsSDK\TwitterAds\Creative\PromotedTweet;
8+
use Hborras\TwitterAdsSDK\TwitterAds\Cursor;
9+
use Hborras\TwitterAdsSDK\TwitterAds\Errors\BadRequest;
1210
use Hborras\TwitterAdsSDK\TwitterAds\Fields\AnalyticsFields;
11+
use Hborras\TwitterAdsSDK\TwitterAds\Fields\LineItemFields;
12+
use Hborras\TwitterAdsSDK\TwitterAdsException;
1313

1414
/**
1515
* Class LineItem
@@ -34,7 +34,7 @@ class LineItem extends Analytics
3434
LineItemFields::CAMPAIGN_ID,
3535
LineItemFields::BID_AMOUNT_LOCAL_MICRO,
3636
LineItemFields::NAME,
37-
LineItemFields::BID_TYPE,
37+
LineItemFields::BID_STRATEGY,
3838
LineItemFields::AUTOMATICALLY_SELECT_BID,
3939
LineItemFields::PRODUCT_TYPE,
4040
LineItemFields::PLACEMENTS,
@@ -45,9 +45,8 @@ class LineItem extends Analytics
4545
LineItemFields::START_TIME,
4646
LineItemFields::END_TIME,
4747
LineItemFields::PRIMARY_WEB_EVENT_TAG,
48-
LineItemFields::OPTIMIZATION,
49-
LineItemFields::BID_UNIT,
50-
LineItemFields::CHARGE_BY,
48+
LineItemFields::PAY_BY,
49+
LineItemFields::GOAL,
5150
LineItemFields::ADVERTISER_DOMAIN,
5251
LineItemFields::ADVERTISER_USER_ID,
5352
LineItemFields::CATEGORIES
@@ -57,7 +56,7 @@ class LineItem extends Analytics
5756
protected $campaign_id;
5857
protected $bid_amount_local_micro;
5958
protected $name;
60-
protected $bid_type;
59+
protected $bid_strategy;
6160
protected $automatically_select_bid;
6261
protected $product_type;
6362
protected $placements;
@@ -68,9 +67,8 @@ class LineItem extends Analytics
6867
protected $start_time;
6968
protected $end_time;
7069
protected $primary_web_event_tag;
71-
protected $optimization;
72-
protected $bid_unit;
73-
protected $charge_by;
70+
protected $pay_by;
71+
protected $goal;
7472
protected $advertiser_domain;
7573
protected $tracking_tags;
7674
protected $advertiser_user_id;
@@ -91,10 +89,18 @@ class LineItem extends Analytics
9189
public function getPromotedTweets($params = [])
9290
{
9391
$params[LineItemFields::LINE_ITEM_IDS] = $this->getId();
94-
$promotedTweetClass = new PromotedTweet();
92+
$promotedTweetClass = new PromotedTweet();
9593
return $promotedTweetClass->loadResource('', $params);
9694
}
9795

96+
/**
97+
* @return mixed
98+
*/
99+
public function getId()
100+
{
101+
return $this->id;
102+
}
103+
98104
/**
99105
* @param $metricGroups
100106
* @param array $params
@@ -140,14 +146,6 @@ public function getTargetingCriteria($id = '', $params = [])
140146
return $cursor;
141147
}
142148

143-
/**
144-
* @return mixed
145-
*/
146-
public function getId()
147-
{
148-
return $this->id;
149-
}
150-
151149
/**
152150
* @return mixed
153151
*/
@@ -231,17 +229,17 @@ public function setName($name)
231229
/**
232230
* @return mixed
233231
*/
234-
public function getBidType()
232+
public function getBidStrategy()
235233
{
236-
return $this->bid_type;
234+
return $this->bid_strategy;
237235
}
238236

239237
/**
240-
* @param mixed $bid_type
238+
* @param mixed $bid_strategy
241239
*/
242-
public function setBidType($bid_type)
240+
public function setBidStrategy($bidStrategy)
243241
{
244-
$this->bid_type = $bid_type;
242+
$this->bid_strategy = $bidStrategy;
245243
}
246244

247245
/**
@@ -252,14 +250,6 @@ public function getAutomaticallySelectdBid()
252250
return $this->automatically_select_bid;
253251
}
254252

255-
/**
256-
* @param mixed $automatically_select_bid
257-
*/
258-
public function setAutomaticallySelectBid($automatically_select_bid)
259-
{
260-
$this->automatically_select_bid = $automatically_select_bid;
261-
}
262-
263253
/**
264254
* @return mixed
265255
*/
@@ -407,49 +397,33 @@ public function setPrimaryWebEventTag($primary_web_event_tag)
407397
/**
408398
* @return mixed
409399
*/
410-
public function getOptimization()
400+
public function getPayBy()
411401
{
412-
return $this->optimization;
402+
return $this->pay_by;
413403
}
414404

415405
/**
416-
* @param mixed $optimization
406+
* @param mixed $pay_by
417407
*/
418-
public function setOptimization($optimization)
408+
public function setPayBy($pay_by)
419409
{
420-
$this->optimization = $optimization;
410+
$this->pay_by = $pay_by;
421411
}
422412

423413
/**
424414
* @return mixed
425415
*/
426-
public function getBidUnit()
416+
public function getGoal()
427417
{
428-
return $this->bid_unit;
418+
return $this->goal;
429419
}
430420

431421
/**
432-
* @param mixed $bid_unit
422+
* @param mixed $goal
433423
*/
434-
public function setBidUnit($bid_unit)
424+
public function setGoal($goal)
435425
{
436-
$this->bid_unit = $bid_unit;
437-
}
438-
439-
/**
440-
* @return mixed
441-
*/
442-
public function getChargeBy()
443-
{
444-
return $this->charge_by;
445-
}
446-
447-
/**
448-
* @param mixed $charge_by
449-
*/
450-
public function setChargeBy($charge_by)
451-
{
452-
$this->charge_by = $charge_by;
426+
$this->goal = $goal;
453427
}
454428

455429
/**
@@ -516,6 +490,14 @@ public function getAutomaticallySelectBid()
516490
return $this->automatically_select_bid;
517491
}
518492

493+
/**
494+
* @param mixed $automatically_select_bid
495+
*/
496+
public function setAutomaticallySelectBid($automatically_select_bid)
497+
{
498+
$this->automatically_select_bid = $automatically_select_bid;
499+
}
500+
519501
/**
520502
* @return mixed
521503
*/

src/TwitterAds/Fields/LineItemFields.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class LineItemFields
1515
const CAMPAIGN_ID = 'campaign_id';
1616
const BID_AMOUNT_LOCAL_MICRO = 'bid_amount_local_micro';
1717
const NAME = 'name';
18-
const BID_TYPE = 'bid_type';
18+
const BID_STRATEGY = 'bid_strategy';
1919
const AUTOMATICALLY_SELECT_BID = 'automatically_select_bid';
2020
const PRODUCT_TYPE = 'product_type';
2121
const PLACEMENTS = 'placements';
@@ -25,9 +25,8 @@ class LineItemFields
2525
const START_TIME = 'start_time';
2626
const END_TIME = 'end_time';
2727
const PRIMARY_WEB_EVENT_TAG = 'primary_web_event_tag';
28-
const OPTIMIZATION = 'optimization';
29-
const BID_UNIT = 'bid_unit';
30-
const CHARGE_BY = 'charge_by';
28+
const GOAL = 'goal';
29+
const PAY_BY = 'pay_by';
3130
const ADVERTISER_DOMAIN = 'advertiser_domain';
3231
const ADVERTISER_USER_ID = 'advertiser_user_id';
3332
const WITH_DELETED = 'with_deleted';
@@ -42,7 +41,7 @@ class LineItemFields
4241
const LOOKALIKE_EXPANSION = 'lookalike_expansion';
4342
const WITH_DRAFT = 'with_draft';
4443

45-
const CAMPAIGN_IDS = 'campaign_ids';
44+
const CAMPAIGN_IDS = 'campaign_ids';
4645
const FUNDING_INSTRUMENT_IDS = 'funding_instrument_ids';
47-
const LINE_ITEM_IDS = 'line_item_ids';
46+
const LINE_ITEM_IDS = 'line_item_ids';
4847
}

0 commit comments

Comments
 (0)