Skip to content

Commit

Permalink
Merge pull request #16 from danrichards/single-page-cursors
Browse files Browse the repository at this point in the history
Fixes issue with single page cursored endpoint
  • Loading branch information
forgiv authored Aug 3, 2020
2 parents bdd967e + 9bafc62 commit f44a786
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Shopify.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,13 @@ public function get($query = [], $append = '')
// If response has Link header, parse it and set the cursors
if ($response->hasHeader('Link')) {
$this->cursors = static::parseLinkHeader($response->getHeader('Link')[0]);
}
// If we don't have Link on a cursored endpoint then it was the only page. Set cursors to null to avoid breaking next.
elseif (in_array($api, self::$cursored_enpoints, true)) {
$this->cursors = [
'prev' => null,
'next' => null,
];
}

$data = json_decode($response->getBody()->getContents(), true);
Expand Down

0 comments on commit f44a786

Please sign in to comment.