Skip to content

Add support for cursor based pagination (again) #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/CurlRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class CurlRequest
*/
public static $lastHttpCode;

/**
* HTTP response headers of last executed request
*
* @var array
*/
public static $lastHttpResponseHeaders = array();

/**
* Initialize the curl resource
Expand Down Expand Up @@ -170,7 +176,9 @@ protected static function processRequest($ch)
// close curl resource to free up system resources
curl_close($ch);

self::$lastHttpResponseHeaders = $response->getHeaders();

return $response->getBody();
}

}
10 changes: 10 additions & 0 deletions lib/ShopifyResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ abstract class ShopifyResource
*/
protected $httpHeaders = array();

/**
* HTTP response headers of last executed request
*
* @var array
*/
public static $lastHttpResponseHeaders = array();

/**
* The base URL of the API Resource (excluding the '.json' extension).
*
Expand Down Expand Up @@ -511,6 +518,8 @@ protected function castString($array)
*/
public function processResponse($responseArray, $dataKey = null)
{
self::$lastHttpResponseHeaders = CurlRequest::$lastHttpResponseHeaders;

if ($responseArray === null) {
//Something went wrong, Checking HTTP Codes
$httpOK = 200; //Request Successful, OK.
Expand Down Expand Up @@ -569,6 +578,7 @@ public function getLink($responseHeaders, $type='next'){
}
}
}

return null;
}

Expand Down