cct-marketing / rest-exception-handler
An exception handler used to handle and parse all errors from the rest lib requests
Installs: 6 636
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ~7.4|~8.0
- guzzlehttp/guzzle: ~6.5|~7.0
Requires (Dev)
- phpunit/phpunit: ^9.0
README
An exception handler using the decorator pattern to wrap the client requests from the REST lib and parse the server responses in correctly correctly form format exceptions based on api format
Installation
composer require cct-marketing/rest-execption-handler
Usage
use CCT\Component\Rest\AbstractClient; use CCT\Component\Rest\Config; class RESTClient extends AbstractClient { /** * @return ScrapeRequest */ public function myAPI(): MyRequest { $config = clone $this->config; $modelClass = TestModel::class; $serializer = $this->getBuiltSerializer($config); if ($this->shouldUseDefaultResponseTransformers() && null !== $serializer) { $this->applyDefaultResponseTransformers($config, $serializer, $modelClass); } return $this->createRequestInstance(TestRequest::class, $config, null); } }