- WIP on tasks
This commit is contained in:
parent
7b5a1bcf97
commit
8de8aafa84
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Negundo\Client\Task;
|
namespace Negundo\Client\Task;
|
||||||
|
|
||||||
class TaskReport
|
class TaskReport implements \JsonSerializable
|
||||||
{
|
{
|
||||||
protected array $events = [];
|
protected array $events = [];
|
||||||
|
|
||||||
@ -13,6 +13,7 @@ class TaskReport
|
|||||||
public array $data = [],
|
public array $data = [],
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
|
||||||
public function addData(string $name, array $data) : static
|
public function addData(string $name, array $data) : static
|
||||||
{
|
{
|
||||||
$this->data[$name][] = $data;
|
$this->data[$name][] = $data;
|
||||||
@ -60,13 +61,24 @@ class TaskReport
|
|||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEvents() : array
|
public function getEvents(?StatusEnum $filterType = null) : array
|
||||||
{
|
{
|
||||||
return $this->events;
|
return $filterType ? array_filter($this->events, fn($e) => StatusEnum::tryFrom($e['status']) === $filterType) : $this->events;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatus() : StatusEnum
|
public function getStatus() : StatusEnum
|
||||||
{
|
{
|
||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function jsonSerialize(): mixed
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'title' => $this->getTitle(),
|
||||||
|
'message' => $this->getMessage(),
|
||||||
|
'status' => $this->getStatus(),
|
||||||
|
'events' => $this->getEvents(),
|
||||||
|
'data' => $this->getData(),
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ namespace Negundo\Client\Transport;
|
|||||||
|
|
||||||
class Curl implements TransportInterface {
|
class Curl implements TransportInterface {
|
||||||
|
|
||||||
public $timeout = 100;
|
public $timeout = 4;
|
||||||
|
|
||||||
public $throwErrors = true;
|
public $throwErrors = true;
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ class Curl implements TransportInterface {
|
|||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers );
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers );
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, '', '&'));
|
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, '', '&'));
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT_MS, $this->timeout * 200);
|
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verifySsl);
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verifySsl);
|
||||||
|
|
||||||
$exec = curl_exec($ch);
|
$exec = curl_exec($ch);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user