From ad67b4179c824e15b449511f2438aa3c134c98ed Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 9 Apr 2019 20:10:33 +0200 Subject: [PATCH] Make sure Attachment::show always return ResponseInterface (#590) --- src/Api/Attachment.php | 9 ++++--- src/Model/Attachment/Attachment.php | 39 ----------------------------- 2 files changed, 6 insertions(+), 42 deletions(-) delete mode 100644 src/Model/Attachment/Attachment.php diff --git a/src/Api/Attachment.php b/src/Api/Attachment.php index 4de1d52..09bc10f 100644 --- a/src/Api/Attachment.php +++ b/src/Api/Attachment.php @@ -12,7 +12,6 @@ declare(strict_types=1); namespace Mailgun\Api; use Mailgun\Assert; -use Mailgun\Model\Attachment\Attachment as Model; use Psr\Http\Message\ResponseInterface; /** @@ -21,7 +20,7 @@ use Psr\Http\Message\ResponseInterface; class Attachment extends HttpApi { /** - * @return Model|ResponseInterface + * @return ResponseInterface */ public function show(string $url) { @@ -31,6 +30,10 @@ class Attachment extends HttpApi $response = $this->httpGet($url); - return $this->hydrateResponse($response, Model::class); + if (200 !== $response->getStatusCode()) { + $this->handleErrors($response); + } + + return $response; } } diff --git a/src/Model/Attachment/Attachment.php b/src/Model/Attachment/Attachment.php deleted file mode 100644 index d519215..0000000 --- a/src/Model/Attachment/Attachment.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ -final class Attachment implements ApiResponse -{ - private $data; - - private function __construct() - { - } - - public static function create(array $data): self - { - $new = new self(); - $new->data = $data; - - return $new; - } - - public function getData(): array - { - return $this->data; - } -}