Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Письменов Дмитрий Иванович
/
yourroomads
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit be040e48
authored
Jun 22, 2021
by
Евгений
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Улучшение #19474
Синхронизация фраз и групп
1 parent
6a102696
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
3 deletions
app/Console/Commands/AdGroupsAdd.php
app/Jobs/ProcessCallAPI.php
app/Service/API/YandexDirect.php
app/Service/Handlers/DirectHandler.php
app/Service/Requests/Direct/AddAdGroups.php
app/Console/Commands/AdGroupsAdd.php
View file @
be040e4
...
...
@@ -46,7 +46,6 @@ class AdGroupsAdd extends Command
->
get
();
foreach
(
$tokens
as
$token
)
{
$token
->
load
([
'dictionaryCampaignsEnabledForExternalSynchronized.groupsForNotExternal'
=>
function
(
HasMany
$query
)
{
return
$query
->
has
(
'group'
);
...
...
app/Jobs/ProcessCallAPI.php
View file @
be040e4
...
...
@@ -60,11 +60,13 @@ class ProcessCallAPI implements ShouldQueue
}
}
$response
=
$api
->
execute
();
$handler
=
AdsHandler
::
getInstance
(
$this
->
api
);
$handler
->
checkError
(
$response
);
$limits
->
acceptRezerv
(
$this
->
limitId
,
new
HeaderLimits
(
$response
->
headers
()));
//TODO: обработать результат.
// если не хватило баллов на все что хотели запросить, то в очередь отправляем новый запрос на получение новых данных
AdsHandler
::
getInstance
(
$this
->
api
)
->
handle
(
$response
);
$handler
->
handle
(
$response
);
}
catch
(
\Exception
$e
)
{
//TODO: надо отдельно выделить ошибки вызовов, за которые списываются баллы
//https://yandex.ru/dev/direct/doc/dg/concepts/errors.html
...
...
app/Service/API/YandexDirect.php
View file @
be040e4
...
...
@@ -3,6 +3,7 @@ namespace App\Service\API;
use
Illuminate\Http\Client\Response
;
use
Illuminate\Support\Facades\Http
;
use
Illuminate\Support\Facades\Log
;
class
YandexDirect
extends
API
{
private
$url
=
'https://oauth.yandex.ru/token'
;
...
...
@@ -42,9 +43,12 @@ class YandexDirect extends API{
public
function
execute
()
:
Response
{
return
Http
::
withBody
(
$this
->
request
->
getBody
(),
'none'
)
// Log::debug($this->request->getBody());
$result
=
Http
::
withBody
(
$this
->
request
->
getBody
(),
'none'
)
->
withHeaders
(
$this
->
request
->
getHeaders
())
->
withToken
(
$this
->
request
->
getToken
()
->
token
)
->
post
(
$this
->
request
->
getUrl
());
// Log::debug($result->json());
return
$result
;
}
}
app/Service/Handlers/DirectHandler.php
View file @
be040e4
...
...
@@ -12,4 +12,11 @@ class DirectHandler extends AdsHandler
{
$this
->
response
=
$response
->
json
();
}
public
function
checkError
(
$response
){
$this
->
parse
(
$response
);
if
(
$this
->
response
[
'error'
]){
throw
new
\Exception
(
$this
->
response
[
'error'
][
'error_detail'
]);
}
}
}
app/Service/Requests/Direct/AddAdGroups.php
View file @
be040e4
...
...
@@ -23,6 +23,7 @@ class AddAdGroups extends DirectRequest
public
function
call
(
$params
=
null
)
{
$this
->
requestPrepare
(
$params
);
Log
::
debug
(
$this
->
getParams
());
$process
=
new
ProcessCallLimitedAPI
(
$this
);
dispatch
(
$process
)
->
onQueue
(
'limits'
);
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment