|
@@ -2,7 +2,6 @@ |
|
@@ -2,7 +2,6 @@ |
|
2
|
|
2
|
|
|
3
|
namespace Lackoxygen\TiktokShop\Response;
|
3
|
namespace Lackoxygen\TiktokShop\Response;
|
|
4
|
|
4
|
|
|
5
|
-use GuzzleHttp\Psr7\Response;
|
|
|
|
6
|
use Illuminate\Support\Arr;
|
5
|
use Illuminate\Support\Arr;
|
|
7
|
use Lackoxygen\TiktokShop\Util\Json;
|
6
|
use Lackoxygen\TiktokShop\Util\Json;
|
|
8
|
|
7
|
|
|
@@ -14,18 +13,11 @@ class ResultSet |
|
@@ -14,18 +13,11 @@ class ResultSet |
|
14
|
protected array $items = [];
|
13
|
protected array $items = [];
|
|
15
|
|
14
|
|
|
16
|
/**
|
15
|
/**
|
|
17
|
- * @var Response
|
16
|
+ * @param array $items
|
|
18
|
*/
|
17
|
*/
|
|
19
|
- protected Response $response;
|
|
|
|
20
|
-
|
|
|
|
21
|
- /**
|
|
|
|
22
|
- * @param Response $response
|
|
|
|
23
|
- */
|
|
|
|
24
|
- public function __construct(Response $response)
|
18
|
+ public function __construct(array $items)
|
|
25
|
{
|
19
|
{
|
|
26
|
- $this->response = $response;
|
|
|
|
27
|
-
|
|
|
|
28
|
- $this->items = Json::unmarshal($response->getBody()->getContents());
|
20
|
+ $this->items = $items;
|
|
29
|
}
|
21
|
}
|
|
30
|
|
22
|
|
|
31
|
/**
|
23
|
/**
|
|
@@ -85,14 +77,20 @@ class ResultSet |
|
@@ -85,14 +77,20 @@ class ResultSet |
|
85
|
}
|
77
|
}
|
|
86
|
|
78
|
|
|
87
|
/**
|
79
|
/**
|
|
88
|
- * @return string
|
80
|
+ * @param $name
|
|
|
|
81
|
+ * @return $this|array|\ArrayAccess|mixed
|
|
89
|
*/
|
82
|
*/
|
|
90
|
- public function raw(): string
|
83
|
+ public function __get($name)
|
|
91
|
{
|
84
|
{
|
|
92
|
- $body = $this->response->getBody();
|
85
|
+ if (!Arr::exists($this->items, $name)) {
|
|
|
|
86
|
+ return $this->items;
|
|
|
|
87
|
+ }
|
|
|
|
88
|
+ $items = Arr::get($this->items, $name);
|
|
93
|
|
89
|
|
|
94
|
- $body->rewind();
|
90
|
+ if (is_array($items)) {
|
|
|
|
91
|
+ return new static($items);
|
|
|
|
92
|
+ }
|
|
95
|
|
93
|
|
|
96
|
- return $body->getContents();
|
94
|
+ return $items;
|
|
97
|
}
|
95
|
}
|
|
98
|
} |
96
|
} |