|
...
|
...
|
@@ -2,7 +2,6 @@ |
|
|
|
|
|
|
|
namespace Lackoxygen\TiktokShop\Response;
|
|
|
|
|
|
|
|
use GuzzleHttp\Psr7\Response;
|
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
use Lackoxygen\TiktokShop\Util\Json;
|
|
|
|
|
|
...
|
...
|
@@ -14,18 +13,11 @@ class ResultSet |
|
|
|
protected array $items = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Response
|
|
|
|
* @param array $items
|
|
|
|
*/
|
|
|
|
protected Response $response;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Response $response
|
|
|
|
*/
|
|
|
|
public function __construct(Response $response)
|
|
|
|
public function __construct(array $items)
|
|
|
|
{
|
|
|
|
$this->response = $response;
|
|
|
|
|
|
|
|
$this->items = Json::unmarshal($response->getBody()->getContents());
|
|
|
|
$this->items = $items;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -85,14 +77,20 @@ class ResultSet |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
* @param $name
|
|
|
|
* @return $this|array|\ArrayAccess|mixed
|
|
|
|
*/
|
|
|
|
public function raw(): string
|
|
|
|
public function __get($name)
|
|
|
|
{
|
|
|
|
$body = $this->response->getBody();
|
|
|
|
if (!Arr::exists($this->items, $name)) {
|
|
|
|
return $this->items;
|
|
|
|
}
|
|
|
|
$items = Arr::get($this->items, $name);
|
|
|
|
|
|
|
|
$body->rewind();
|
|
|
|
if (is_array($items)) {
|
|
|
|
return new static($items);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $body->getContents();
|
|
|
|
return $items;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|