Skip to content

Commit

Permalink
fix: error handling, reportDetailByPeriod method argument list, null …
Browse files Browse the repository at this point in the history
…dateTime
  • Loading branch information
mike-trueh committed Dec 28, 2021
1 parent 3e54efb commit e343a7a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"sdk"
],
"license": "MIT",
"version": "0.0.2",
"version": "0.0.3",
"authors": [
{
"name": "Mikhail Kryzhanovskiy",
Expand Down
4 changes: 2 additions & 2 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ protected function requestCurl(string $url, array $params = [], string $method =

$decodedResponse = json_decode($response, true);

if ($errors = $decodedResponse['errors'])
throw new RequestException('Ошибка запроса: ' . implode('; ', $errors));
if (isset($decodedResponse['errors']))
throw new RequestException('Ошибка запроса: ' . implode('; ', $decodedResponse['errors']));

return $decodedResponse;
}
Expand Down
10 changes: 5 additions & 5 deletions src/WbStatSDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public function getToken(): string
/**
* Задать дату для запросов
*
* @param DateTime $dateTime
* @param DateTime|null $dateTime
* @return $this
*/
public function setDate(DateTime $dateTime): WbStatSDK
public function setDate(DateTime $dateTime = null): WbStatSDK
{
$this->dateTime = $dateTime;

Expand Down Expand Up @@ -115,15 +115,15 @@ public function sales(DateTime $dateTime = null, int $flag = 0)
/**
* Отчет о продажах по реализации
*
* @param DateTime|null $dateTime Начальная дата периода
* @param DateTime|null $dateTo Конечная дата периода
* @param DateTime $dateTo Конечная дата периода
* @param int $limit Максимальное количество строк отчета получаемых в результате вызова API. Рекомендуем загружать отчет небольшими частями, например, по 100 000 строк на один вызов
* @param int $rrdid Уникальный идентификатор строки отчета. Необходим для получения отчета частями
* @param DateTime|null $dateTime Начальная дата периода
* @return mixed
* @throws RequestException
* @throws WbStatException
*/
public function reportDetailByPeriod(DateTime $dateTime = null, DateTime $dateTo = null, int $limit = 1000, int $rrdid = 0)
public function reportDetailByPeriod(DateTime $dateTo, int $limit = 1000, int $rrdid = 0, DateTime $dateTime = null)
{
return $this->request('reportDetailByPeriod', ['dateFrom' => $dateTime ?? $this->dateTime ?? null, 'dateTo' => $dateTo, 'limit' => $limit, 'rrdid' => $rrdid,]);
}
Expand Down

0 comments on commit e343a7a

Please sign in to comment.