mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-29 00:25:37 +03:00
Make sure Attachment::show always return ResponseInterface (#590)
This commit is contained in:
parent
7705cb7666
commit
ad67b4179c
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user