-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
766 additions
and
494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\Exceptions; | ||
|
||
class ClientException extends MollieException {} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\Exceptions; | ||
|
||
use Mollie\Api\Http\Response; | ||
|
||
class ForbiddenException extends ApiException | ||
{ | ||
public static function fromResponse(Response $response): self | ||
{ | ||
$body = $response->json(); | ||
|
||
return new self( | ||
'Your request was understood but not allowed. ' . | ||
sprintf('Error executing API call (%d: %s): %s', 403, $body->title, $body->detail), | ||
403, | ||
$response->getPsrRequest(), | ||
$response->getPsrResponse() | ||
); | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
src/Exceptions/HttpAdapterDoesNotSupportDebuggingException.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\Exceptions; | ||
|
||
class InvalidAuthenticationException extends ClientException | ||
{ | ||
private string $token; | ||
|
||
public function __construct(string $token, string $message = '') | ||
{ | ||
$this->token = $token; | ||
parent::__construct($message ?: "Invalid authentication token: '{$token}'"); | ||
} | ||
|
||
public function getToken(): string | ||
{ | ||
return $this->token; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\Exceptions; | ||
|
||
use Mollie\Api\Http\Response; | ||
|
||
class MethodNotAllowedException extends ApiException | ||
{ | ||
public static function fromResponse(Response $response): self | ||
{ | ||
$body = $response->json(); | ||
|
||
return new self( | ||
'The HTTP method is not supported. ' . | ||
sprintf('Error executing API call (%d: %s): %s', 405, $body->title, $body->detail), | ||
405, | ||
$response->getPsrRequest(), | ||
$response->getPsrResponse() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\Exceptions; | ||
|
||
class MissingAuthenticationException extends ClientException | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct('You have not set an API key or OAuth access token. Please use setApiKey() to set the API key.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\Exceptions; | ||
|
||
class MollieException extends \Exception {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\Exceptions; | ||
|
||
use Mollie\Api\Http\Response; | ||
|
||
class NotFoundException extends ApiException | ||
{ | ||
public static function fromResponse(Response $response): self | ||
{ | ||
$body = $response->json(); | ||
|
||
return new self( | ||
'The object referenced by your API request does not exist. ' . | ||
sprintf('Error executing API call (%d: %s): %s', 404, $body->title, $body->detail), | ||
404, | ||
$response->getPsrRequest(), | ||
$response->getPsrResponse() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\Exceptions; | ||
|
||
use Psr\Http\Client\ClientExceptionInterface; | ||
use Psr\Http\Message\RequestInterface; | ||
use Throwable; | ||
|
||
class RequestException extends MollieException implements ClientExceptionInterface | ||
{ | ||
protected RequestInterface $request; | ||
|
||
public function __construct( | ||
string $message, | ||
RequestInterface $request, | ||
?Throwable $previous = null | ||
) { | ||
parent::__construct($message, 0, $previous); | ||
$this->request = $request; | ||
} | ||
|
||
public function getRequest(): RequestInterface | ||
{ | ||
return $this->request; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\Exceptions; | ||
|
||
use Mollie\Api\Http\Response; | ||
|
||
class RequestTimeoutException extends ApiException | ||
{ | ||
public static function fromResponse(Response $response): self | ||
{ | ||
$body = $response->json(); | ||
|
||
return new self( | ||
'The request took too long to complete. ' . | ||
sprintf('Error executing API call (%d: %s): %s', 408, $body->title, $body->detail), | ||
408, | ||
$response->getPsrRequest(), | ||
$response->getPsrResponse() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\Exceptions; | ||
|
||
use Psr\Http\Message\RequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
class ResponseException extends ClientException | ||
{ | ||
private ?ResponseInterface $response; | ||
private ?RequestInterface $request; | ||
private ?string $field; | ||
|
||
public function __construct( | ||
string $message, | ||
?ResponseInterface $response = null, | ||
?RequestInterface $request = null, | ||
?string $field = null | ||
) { | ||
$this->response = $response; | ||
$this->request = $request; | ||
$this->field = $field; | ||
parent::__construct($message); | ||
} | ||
|
||
public function getResponse(): ?ResponseInterface | ||
{ | ||
return $this->response; | ||
} | ||
|
||
public function getRequest(): ?RequestInterface | ||
{ | ||
return $this->request; | ||
} | ||
|
||
public function getField(): ?string | ||
{ | ||
return $this->field; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\Exceptions; | ||
|
||
use Mollie\Api\Http\Response; | ||
|
||
class ServiceUnavailableException extends ApiException | ||
{ | ||
public static function fromResponse(Response $response): self | ||
{ | ||
$body = $response->json(); | ||
|
||
return new self( | ||
'The service is temporarily unavailable. ' . | ||
sprintf('Error executing API call (%d: %s): %s', 503, $body->title, $body->detail), | ||
503, | ||
$response->getPsrRequest(), | ||
$response->getPsrResponse() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\Exceptions; | ||
|
||
use Mollie\Api\Http\Response; | ||
|
||
class TooManyRequestsException extends ApiException | ||
{ | ||
public static function fromResponse(Response $response): self | ||
{ | ||
$body = $response->json(); | ||
|
||
return new self( | ||
'Your request exceeded the rate limit. ' . | ||
sprintf('Error executing API call (%d: %s): %s', 429, $body->title, $body->detail), | ||
429, | ||
$response->getPsrRequest(), | ||
$response->getPsrResponse() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\Exceptions; | ||
|
||
use Mollie\Api\Http\Response; | ||
|
||
class UnauthorizedException extends ApiException | ||
{ | ||
public static function fromResponse(Response $response): self | ||
{ | ||
$body = $response->json(); | ||
|
||
return new self( | ||
'Your request wasn\'t executed due to failed authentication. Check your API key. ' . | ||
sprintf('Error executing API call (%d: %s): %s', 401, $body->title, $body->detail), | ||
401, | ||
$response->getPsrRequest(), | ||
$response->getPsrResponse() | ||
); | ||
} | ||
} |
Oops, something went wrong.