Skip to content

Commit

Permalink
Added AggregationType request parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
schulzefelix committed Apr 11, 2021
1 parent 26e9b65 commit 9a55418
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

All Notable changes to `laravel-search-console` will be documented in this file.
## [1.7.1] - 2021-04-11
- Add 'AggregationType' request and response parameter

## [1.7.0] - 2021-04-11
- Add 'dataState' request and response parameter

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ $sites = SearchConsole::setAccessToken($token)->listSites();
[['dimension' => 'query', 'operator' => 'notContains', 'expression' => 'cheesecake']],
1000,
'web',
'all'
'all',
'auto'
);
```

Expand All @@ -130,7 +131,7 @@ public function public function listSites(): Collection

### Retrieve Search Analytics Data
```php
public function searchAnalyticsQuery(string $siteUrl, Period $period, array $dimensions = [], array $filters = [], int $rows = 1000, string $searchType = 'web', string $dataState = 'final'): Collection
public function searchAnalyticsQuery(string $siteUrl, Period $period, array $dimensions = [], array $filters = [], int $rows = 1000, string $searchType = 'web', string $dataState = 'final', string $aggregationType = 'auto'): Collection
```

### Check Access Token
Expand Down
2 changes: 1 addition & 1 deletion src/ExponentialBackoff.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function execute(callable $function, array $arguments = [])
}
}

if ($exception->getCode() == 401 || $exception->getCode() == 403) {
if ($exception->getCode() >= 400 && $exception->getCode() <= 499) {
break;
}

Expand Down
4 changes: 3 additions & 1 deletion src/SearchConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,19 @@ public function listSites()
* @param int $rows
* @param string $searchType
* @param string $dataState
* @param string $aggregationType
* @return Collection
* @throws \Exception
*/
public function searchAnalyticsQuery(string $siteUrl, Period $period, array $dimensions = [], array $filters = [], int $rows = 1000, string $searchType = 'web', string $dataState = 'final')
public function searchAnalyticsQuery(string $siteUrl, Period $period, array $dimensions = [], array $filters = [], int $rows = 1000, string $searchType = 'web', string $dataState = 'final', string $aggregationType = 'auto')
{
$request = new Google_Service_Webmasters_SearchAnalyticsQueryRequest();
$request->setStartDate($period->startDate->toDateString());
$request->setEndDate($period->endDate->toDateString());
$request->setSearchType($searchType);
$request->setDimensions($dimensions);
$request->setDataState($dataState);
$request->setAggregationType($aggregationType);
$request = $this->applyFilters($request, $filters);

return $this->client->performQuery($siteUrl, $rows, $request);
Expand Down
1 change: 1 addition & 0 deletions src/SearchConsoleClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function performQuery($siteUrl, $rows, $request): Collection
$item['position'] = $row->getPosition();
$item['searchType'] = $request->getSearchType();
$item['dataState'] = $request->getDataState();
$item['aggregationType'] = $request->getAggregationType();

$dataRows->put($uniqueHash, $item);
}
Expand Down

0 comments on commit 9a55418

Please sign in to comment.