diff --git a/composer.json b/composer.json index 5d5edbd98e..75e8feb127 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "benmorel/ebay-sdk-php", + "name": "xtremevision/ebay-sdk-php", "description": "An eBay SDK for PHP. Fork of dts/ebay-sdk-php with support for PHP 8.", "keywords": ["ebay", "api", "sdk"], "type": "library", diff --git a/src/Services/BaseService.php b/src/Services/BaseService.php index 05046b5ad2..695dc2ba80 100644 --- a/src/Services/BaseService.php +++ b/src/Services/BaseService.php @@ -176,6 +176,7 @@ function (ResponseInterface $res) use ($debug, $responseClass) { $response = $xmlParser->parse($xmlResponse); $response->attachment($attachment); + $response->responseHeaders($res->getHeaders()); return $response; } diff --git a/src/Types/BaseType.php b/src/Types/BaseType.php index 26269fdf58..d1b5a06eb8 100644 --- a/src/Types/BaseType.php +++ b/src/Types/BaseType.php @@ -50,6 +50,11 @@ class BaseType implements JmesPathableObjectInterface */ private $attachment; + /** + * @var array Associative array storing the httpHandler responseHeaders. + */ + private $responseheaders; + /** * @param array $values Can pass an associative array that will set the objects properties. */ @@ -62,6 +67,7 @@ public function __construct(array $values = []) $this->setValues(__CLASS__, $values); $this->attachment = ['data' => null, 'mimeType' => null]; + $this->responseheaders = ['data' => null]; } /** @@ -207,6 +213,27 @@ public function hasAttachment() return $this->attachment['data'] !== null; } + /** + * Method to get or set the object's response headers. Overrides any existing response headers. + * + * @param mixed $data If a string it is assumed to be the contents of the response headers. If an array copy its values across. + * + * @return mixed Returns the contents of the current response headers or null if none has been specified. + */ + public function responseheaders($data = null) : mixed + { + if ($data !== null) { + $this->responseheaders['data'] = json_encode($data); + } + + return $this->responseheaders; + } + + public function getResponseHeaders() + { + return json_decode($this->responseheaders['data']); + } + /** * Helper method that returns an associative array of the object's properties and values. *