-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from sitkoru/#32_add_service_keywordBids
#32 add service keyword bids
- Loading branch information
Showing
17 changed files
with
591 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
namespace directapi\services\keywordbids; | ||
|
||
|
||
use directapi\common\criterias\LimitOffset; | ||
use directapi\services\BaseService; | ||
use directapi\services\keywordbids\criterias\KeywordBidsSelectionCriteria; | ||
use directapi\services\keywordbids\enum\KeywordBidFieldEnum; | ||
use directapi\services\keywordbids\models\KeywordBidActionResult; | ||
use directapi\services\keywordbids\models\KeywordBidGetItem; | ||
use directapi\services\keywordbids\models\KeywordBidSetAutoItem; | ||
use directapi\services\keywordbids\models\KeywordBidSetItem; | ||
|
||
class KeywordBidsService extends BaseService | ||
{ | ||
/** | ||
* @param KeywordBidsSelectionCriteria $SelectionCriteria | ||
* @param KeywordBidFieldEnum[] $FieldNames | ||
* | ||
* @param string[] $SearchFieldNames | ||
* @param string[] $NetworkFieldNames | ||
* @param LimitOffset $Page | ||
* @return KeywordBidGetItem[] | ||
*/ | ||
public function get(KeywordBidsSelectionCriteria $SelectionCriteria, array $FieldNames, array $SearchFieldNames = [], array $NetworkFieldNames = [], LimitOffset $Page = null) | ||
{ | ||
$params = [ | ||
'SelectionCriteria' => $SelectionCriteria, | ||
'FieldNames' => $FieldNames | ||
]; | ||
if ($SearchFieldNames) { | ||
$params['SearchFieldNames'] = $Page; | ||
} | ||
if ($NetworkFieldNames) { | ||
$params['NetworkFieldNames'] = $Page; | ||
} | ||
if ($Page) { | ||
$params['Page'] = $Page; | ||
} | ||
return $this->doGet($params, 'KeywordBids', KeywordBidGetItem::class); | ||
} | ||
|
||
/** | ||
* @param KeywordBidSetItem[] $Bids | ||
* | ||
* @return KeywordBidActionResult[] | ||
*/ | ||
public function set(array $Bids) | ||
{ | ||
$params = [ | ||
'KeywordBids' => $Bids | ||
]; | ||
$result = $this->call('set', $params); | ||
return $this->mapArray($result->SetResults, KeywordBidActionResult::class); | ||
} | ||
|
||
/** | ||
* @param KeywordBidSetAutoItem[] $Bids | ||
* | ||
* @return KeywordBidActionResult[] | ||
*/ | ||
public function setAuto(array $Bids) | ||
{ | ||
$params = [ | ||
'KeywordBids' => $Bids | ||
]; | ||
$result = $this->call('setAuto', $params); | ||
return $this->mapArray($result->SetAutoResults, KeywordBidActionResult::class); | ||
} | ||
|
||
protected function getName() | ||
{ | ||
return 'keywordbids'; | ||
} | ||
|
||
/** | ||
* @param array $entities | ||
* @throws \ErrorException | ||
*/ | ||
public function toUpdateEntities(array $entities) | ||
{ | ||
throw new \ErrorException('Not implemented'); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/services/keywordbids/criterias/KeywordBidsSelectionCriteria.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace directapi\services\keywordbids\criterias; | ||
|
||
|
||
use directapi\components\interfaces\ICallbackValidation; | ||
use directapi\components\Model; | ||
use directapi\services\adgroups\enum\AdGroupStatusEnum; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
use Symfony\Component\Validator\Context\ExecutionContextInterface; | ||
|
||
class KeywordBidsSelectionCriteria extends Model implements ICallbackValidation | ||
{ | ||
/** | ||
* @var int[] | ||
* @Assert\Count( | ||
* max="10000" | ||
* ) | ||
*/ | ||
public $KeywordIds; | ||
|
||
/** | ||
* @var int[] | ||
* @Assert\Count( | ||
* max="1000" | ||
* ) | ||
*/ | ||
public $AdGroupIds; | ||
|
||
/** | ||
* @var int[] | ||
* @Assert\Count( | ||
* max="10" | ||
* ) | ||
*/ | ||
public $CampaignIds; | ||
|
||
/** | ||
* @var AdGroupStatusEnum[] | ||
*/ | ||
public $ServingStatuses; | ||
|
||
/** | ||
* @Assert\Callback() | ||
* @param ExecutionContextInterface $context | ||
*/ | ||
public function isValid(ExecutionContextInterface $context) | ||
{ | ||
if (!$this->CampaignIds && !$this->AdGroupIds && !$this->KeywordIds) { | ||
$context->buildViolation('Должно быть указано одно из следующих значений: CampaignIds, AdGroupIds, KeywordIds') | ||
->atPath('CampaignIds') | ||
->atPath('AdGroupIds') | ||
->atPath('KeywordIds') | ||
->addViolation(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace directapi\services\keywordbids\enum; | ||
|
||
|
||
use directapi\components\Enum; | ||
|
||
class KeywordBidFieldEnum extends Enum | ||
{ | ||
const KEYWORD_ID = 'KeywordId'; | ||
const AD_GROUP_ID = 'AdGroupId'; | ||
const CAMPAIGN_ID = 'CampaignId'; | ||
const BID = 'Bid'; | ||
const CONTEXT_BID = 'ContextBid'; | ||
const STRATEGY_PRIORITY = 'StrategyPriority'; | ||
const COMPETITORS_BIDS = 'CompetitorsBids'; | ||
const SEARCH_PRICES = 'SearchPrices'; | ||
const CONTEXT_COVERAGE = 'ContextCoverage'; | ||
const MIN_SEARCH_PRICE = 'MinSearchPrice'; | ||
const CURRENT_SEARCH_PRICE = 'CurrentSearchPrice'; | ||
const AUCTION_BIDS = 'AuctionBids'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace directapi\services\keywordbids\enum; | ||
|
||
|
||
class ServingStatusEnum | ||
{ | ||
const ELIGIBLE = 'ELIGIBLE'; | ||
const RARELY_SERVED = 'RARELY_SERVED'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace directapi\services\keywordbids\models; | ||
|
||
|
||
use directapi\components\Model; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
class AuctionKeywordBidItem extends Model | ||
{ | ||
/** | ||
* @var int Объем трафика. | ||
*/ | ||
public $TrafficVolume; | ||
|
||
/** | ||
* @var int Минимальная ставка за указанную позицию. | ||
*/ | ||
public $Bid; | ||
|
||
/** | ||
* @var int Списываемая цена для указанной позиции. | ||
*/ | ||
public $Price; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace directapi\services\keywordbids\models; | ||
|
||
|
||
use directapi\components\Model; | ||
use Symfony\Component\Validator\Context\ExecutionContextInterface; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
class BiddingRuleItem extends Model | ||
{ | ||
/** | ||
* @Assert\Valid() | ||
* @var SearchByTrafficVolume | ||
*/ | ||
public $SearchByTrafficVolume; | ||
|
||
/** | ||
* @Assert\Valid() | ||
* @var NetworkByCoverage | ||
*/ | ||
public $NetworkByCoverage; | ||
|
||
/** | ||
* @Assert\Callback() | ||
* @param ExecutionContextInterface $context | ||
*/ | ||
public function isValid(ExecutionContextInterface $context) | ||
{ | ||
if (!$this->SearchByTrafficVolume && !$this->NetworkByCoverage) { | ||
$context->buildViolation('Должно быть указано одно из следующих значений: SearchByTrafficVolume, NetworkByCoverage') | ||
->atPath('SearchByTrafficVolume') | ||
->atPath('NetworkByCoverage') | ||
->addViolation(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace directapi\services\keywordbids\models; | ||
|
||
|
||
use directapi\components\Model; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
class CoverageItem extends Model | ||
{ | ||
/** | ||
* @Assert\Valid() | ||
* @var NetworkCoverageItem[] | ||
*/ | ||
public $CoverageItems; | ||
} |
34 changes: 34 additions & 0 deletions
34
src/services/keywordbids/models/KeywordBidActionResult.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace directapi\services\keywordbids\models; | ||
|
||
use directapi\components\Model; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
class KeywordBidActionResult extends Model | ||
{ | ||
/** | ||
* @var \directapi\common\results\ExceptionNotification[] | ||
*/ | ||
public $Warnings; | ||
|
||
/** | ||
* @var \directapi\common\results\ExceptionNotification[] | ||
*/ | ||
public $Errors; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
public $CampaignId; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
public $AdGroupId; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
public $KeywordId; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace directapi\services\keywordbids\models; | ||
|
||
use directapi\common\enum\PriorityEnum; | ||
use directapi\components\Model; | ||
use directapi\services\keywordbids\enum\ServingStatusEnum; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
class KeywordBidGetItem extends Model | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
public $CampaignId; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
public $AdGroupId; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
public $KeywordId; | ||
|
||
/** | ||
* @var ServingStatusEnum | ||
*/ | ||
public $ServingStatus; | ||
|
||
/** | ||
* @var PriorityEnum | ||
*/ | ||
public $StrategyPriority; | ||
|
||
/** | ||
* @var SearchItem | ||
*/ | ||
public $Search; | ||
|
||
/** | ||
* @var NetworkItem | ||
* @Assert\Valid() | ||
*/ | ||
public $Network; | ||
} |
Oops, something went wrong.