diff --git a/src/DirectApiService.php b/src/DirectApiService.php index 8aae2d0..5fa1ddb 100644 --- a/src/DirectApiService.php +++ b/src/DirectApiService.php @@ -18,6 +18,7 @@ use directapi\services\campaigns\CampaignsService; use directapi\services\changes\ChangesService; use directapi\services\clients\ClientsService; +use directapi\services\keywordbids\KeywordBidsService; use directapi\services\keywords\KeywordsService; use directapi\services\reports\ReportsService; use directapi\services\retargetinglists\RetargetingListsService; @@ -70,6 +71,11 @@ class DirectApiService */ private $bidsService; + /** + * @var KeywordBidsService + */ + private $keywordBidsService; + /** * @var CampaignsService */ @@ -192,6 +198,17 @@ public function getBidsService() return $this->bidsService; } + /** + * @return KeywordBidsService + */ + public function getKeywordBidsService() + { + if (!$this->keywordBidsService) { + $this->keywordBidsService = new KeywordBidsService($this); + } + return $this->keywordBidsService; + } + /** * @return CampaignsService */ diff --git a/src/services/keywordbids/KeywordBidsService.php b/src/services/keywordbids/KeywordBidsService.php new file mode 100644 index 0000000..820214b --- /dev/null +++ b/src/services/keywordbids/KeywordBidsService.php @@ -0,0 +1,85 @@ + $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'); + } +} \ No newline at end of file diff --git a/src/services/keywordbids/criterias/KeywordBidsSelectionCriteria.php b/src/services/keywordbids/criterias/KeywordBidsSelectionCriteria.php new file mode 100644 index 0000000..c0fd7e6 --- /dev/null +++ b/src/services/keywordbids/criterias/KeywordBidsSelectionCriteria.php @@ -0,0 +1,57 @@ +CampaignIds && !$this->AdGroupIds && !$this->KeywordIds) { + $context->buildViolation('Должно быть указано одно из следующих значений: CampaignIds, AdGroupIds, KeywordIds') + ->atPath('CampaignIds') + ->atPath('AdGroupIds') + ->atPath('KeywordIds') + ->addViolation(); + } + } +} \ No newline at end of file diff --git a/src/services/keywordbids/enum/KeywordBidFieldEnum.php b/src/services/keywordbids/enum/KeywordBidFieldEnum.php new file mode 100644 index 0000000..03e6837 --- /dev/null +++ b/src/services/keywordbids/enum/KeywordBidFieldEnum.php @@ -0,0 +1,22 @@ +SearchByTrafficVolume && !$this->NetworkByCoverage) { + $context->buildViolation('Должно быть указано одно из следующих значений: SearchByTrafficVolume, NetworkByCoverage') + ->atPath('SearchByTrafficVolume') + ->atPath('NetworkByCoverage') + ->addViolation(); + } + } +} \ No newline at end of file diff --git a/src/services/keywordbids/models/CoverageItem.php b/src/services/keywordbids/models/CoverageItem.php new file mode 100644 index 0000000..2104206 --- /dev/null +++ b/src/services/keywordbids/models/CoverageItem.php @@ -0,0 +1,16 @@ +CampaignId && !$this->AdGroupId && !$this->KeywordId) { + $context->buildViolation('Должно быть указано одно из следующих значений: CampaignId, AdGroupId, KeywordId') + ->atPath('CampaignId') + ->atPath('AdGroupId') + ->atPath('KeywordId') + ->addViolation(); + } + } +} \ No newline at end of file diff --git a/src/services/keywordbids/models/KeywordBidSetItem.php b/src/services/keywordbids/models/KeywordBidSetItem.php new file mode 100644 index 0000000..c75e182 --- /dev/null +++ b/src/services/keywordbids/models/KeywordBidSetItem.php @@ -0,0 +1,64 @@ +CampaignId && !$this->AdGroupId && !$this->KeywordId) { + $context->buildViolation('Должно быть указано одно из следующих значений: CampaignId, AdGroupId, KeywordId') + ->atPath('CampaignId') + ->atPath('AdGroupId') + ->atPath('KeywordId') + ->addViolation(); + } + if (!$this->SearchBid && !$this->NetworkBid && !$this->StrategyPriority) { + $context->buildViolation('Должно быть указано одно из следующих значений: SearchBid, NetworkBid, StrategyPriority') + ->atPath('SearchBid') + ->atPath('NetworkBid') + ->atPath('StrategyPriority') + ->addViolation(); + } + } +} \ No newline at end of file diff --git a/src/services/keywordbids/models/NetworkByCoverage.php b/src/services/keywordbids/models/NetworkByCoverage.php new file mode 100644 index 0000000..894aed4 --- /dev/null +++ b/src/services/keywordbids/models/NetworkByCoverage.php @@ -0,0 +1,33 @@ +