Update ListList now that we pass an object with QueryResponse

This commit is contained in:
Deon George 2024-08-14 22:18:57 +10:00
parent 0cc4a217bd
commit 9d81824b52
2 changed files with 4 additions and 6 deletions

View File

@ -305,7 +305,7 @@ final class API
$key = 'Item'; $key = 'Item';
$parameters['query'] = 'select * from Item'; $parameters['query'] = 'select * from Item';
return new ListList($this->execute('query',$parameters),$key); return new ListList($this->execute('query',$parameters,$key),$key);
} }
/** /**

View File

@ -144,9 +144,7 @@ class ListList extends Base implements \Countable, \ArrayAccess, \Iterator
*/ */
private function data(object $response,string $type): Collection private function data(object $response,string $type): Collection
{ {
if (! ($x=object_get($response->QueryResponse,$type))) $x = $response->{$type};
return collect();
switch (Arr::get(self::TYPES,$type)) { switch (Arr::get(self::TYPES,$type)) {
case Category::class: case Category::class:
$data = collect(Category::hydrate($x)); $data = collect(Category::hydrate($x));
@ -177,8 +175,8 @@ class ListList extends Base implements \Countable, \ArrayAccess, \Iterator
throw new \Exception(sprintf('%s:Unknown object type: %s',self::LOGKEY,$type)); throw new \Exception(sprintf('%s:Unknown object type: %s',self::LOGKEY,$type));
} }
$this->startPosition = $response->QueryResponse->startPosition; $this->startPosition = $response->startPosition;
$this->maxResults = $response->QueryResponse->maxResults; $this->maxResults = $response->maxResults;
return $data; return $data;
} }