Make sure Attachment::show always return ResponseInterface (#590)

This commit is contained in:
Tobias Nyholm 2019-04-09 20:10:33 +02:00 committed by GitHub
parent 7705cb7666
commit ad67b4179c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 42 deletions

View File

@ -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;
}
}

View File

@ -1,39 +0,0 @@
<?php
declare(strict_types=1);
/*
* Copyright (C) 2013 Mailgun
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace Mailgun\Model\Attachment;
use Mailgun\Model\ApiResponse;
/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
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;
}
}