Commit cb6bae98 by Vladislav

Исправление типов аргументов

1 parent a0692877
Showing with 20 additions and 19 deletions
...@@ -9,13 +9,14 @@ use App\Service\Requests\DirectRequest; ...@@ -9,13 +9,14 @@ use App\Service\Requests\DirectRequest;
use App\Service\StrReplaceByVariables; use App\Service\StrReplaceByVariables;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Ramsey\Collection\Collection;
class AddKeywords extends DirectRequest class AddKeywords extends DirectRequest
{ {
protected $max_count = 1000; protected $max_count = 1000;
protected $timestamp; protected $timestamp;
/* @var array */ /* @var Collection */
protected $goalKeywords; protected $goalKeywords;
public function call($params = null) public function call($params = null)
...@@ -35,11 +36,11 @@ class AddKeywords extends DirectRequest ...@@ -35,11 +36,11 @@ class AddKeywords extends DirectRequest
$splinter = $this->sliceByKey($maxObjects, 'Keywords'); $splinter = $this->sliceByKey($maxObjects, 'Keywords');
$splinter->putParams([ $splinter->putParams([
'goalKeywords' => array_values(array_slice($this->goalKeywords, $maxObjects)), 'goalKeywords' => $this->goalKeywords->slice($maxObjects)->values(),
]); ]);
$this->putParams([ $this->putParams([
'goalKeywords' => array_values(array_slice($this->goalKeywords, 0, $maxObjects)), 'goalKeywords' => $this->goalKeywords->slice(0, $maxObjects)
]); ]);
return $splinter; return $splinter;
...@@ -98,38 +99,38 @@ class AddKeywords extends DirectRequest ...@@ -98,38 +99,38 @@ class AddKeywords extends DirectRequest
$lists = []; $lists = [];
$this->setParams([ $this->setParams([
'Keywords' => array_map(function (array $goalKeyword) use ($variables, $lists) { 'Keywords' => $this->goalKeywords->map(function ($goalKeyword) use ($variables, $lists) {
if (!isset($lists[$goalKeyword['dictionary_campaign_id']])) { if (!isset($lists[$goalKeyword->dictionary_campaign_id])) {
$list = Variable::getListVariablesByDictionaryCampaign($goalKeyword['dictionary_campaign_id'], $variables); $list = Variable::getListVariablesByDictionaryCampaign($goalKeyword->dictionary_campaign_id, $variables);
$lists[$goalKeyword['dictionary_campaign_id']] = $list; $lists[$goalKeyword->dictionary_campaign_id] = $list;
} else { } else {
$list = $lists[$goalKeyword['dictionary_campaign_id']]; $list = $lists[$goalKeyword->dictionary_campaign_id];
} }
$data = [ $data = [
'Keyword' => StrReplaceByVariables::getInstance($goalKeyword['keyword'], $list)->get(), 'Keyword' => StrReplaceByVariables::getInstance($goalKeyword->keyword, $list)->get(),
'AdGroupId' => $goalKeyword['goal_ad_group_external_id'], 'AdGroupId' => $goalKeyword->goal_ad_group_external_id,
]; ];
if ($goalKeyword['bid']) { if ($goalKeyword->bid) {
$data['Bid'] = $goalKeyword['bid']; $data['Bid'] = $goalKeyword->bid;
} }
if ($goalKeyword['context_bid']) { if ($goalKeyword->context_bid) {
$data['ContextBid'] = $goalKeyword['context_bid']; $data['ContextBid'] = $goalKeyword->context_bid;
} }
if ($goalKeyword['user_param_1']) { if ($goalKeyword->user_param_1) {
$data['UserParam1'] = $goalKeyword['user_param_1']; $data['UserParam1'] = $goalKeyword->user_param_1;
} }
if ($goalKeyword['user_param_2']) { if ($goalKeyword->user_param_2) {
$data['UserParam2'] = $goalKeyword['user_param_2']; $data['UserParam2'] = $goalKeyword->user_param_2;
} }
return $data; return $data;
}, $this->goalKeywords), }),
]); ]);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!