* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ declare(strict_types=1); namespace PrestaShop\Module\PrestashopFacebook\Domain\Http; class Response { /** @var int */ private $statusCode; /** @var string */ private $body; /** @var array */ private $headers; /** * @param int $statusCode * @param string $body * @param array $headers **/ public function __construct($statusCode, $body, $headers = []) { $this->statusCode = $statusCode; $this->body = $body; $this->headers = $headers; } /** * @return int */ public function getStatusCode() { return $this->statusCode; } /** * @return array */ public function getHeaders() { return $this->headers; } public function getHeader($headerName) { return $this->headers[$headerName] ?? null; } /** * @return array */ public function getBody() { return json_decode($this->body, true); } public function isSuccessful() { return substr((string) $this->statusCode, 0, 1) == '2'; } }