diff --git a/CHANGELOG.md b/CHANGELOG.md index c573bfc..681ec57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.2.0 + +- **Breaking:** all classes move from `Api\` to `Jschaedl\ApiClient\`, and the sources from + `src/Api/` to `src/`. See [UPGRADE-0.2.md](UPGRADE-0.2.md). + ## 0.1.1 - Allow `webmozart/assert` 2.x (`^1.11||^2.0`). diff --git a/README.md b/README.md index 165242a..607a35f 100644 --- a/README.md +++ b/README.md @@ -61,12 +61,12 @@ composer require jschaedl/api-client Runnable examples live in [`examples/`](examples) (Shopware 5/6, MobilePay, a generic request). ```php -use Api\Client; -use Api\Request\Encoder\JsonRequestBodyEncoder; -use Api\Request\Handler\AddHeaderHandler; -use Api\Request\Method; -use Api\Request\Request; -use Api\Response\Decoder\JsonResponseBodyDecoder; +use Jschaedl\ApiClient\Client; +use Jschaedl\ApiClient\Request\Encoder\JsonRequestBodyEncoder; +use Jschaedl\ApiClient\Request\Handler\AddHeaderHandler; +use Jschaedl\ApiClient\Request\Method; +use Jschaedl\ApiClient\Request\Request; +use Jschaedl\ApiClient\Response\Decoder\JsonResponseBodyDecoder; use Symfony\Component\HttpClient\HttpClient; use Symfony\Component\HttpClient\Psr18Client; @@ -110,7 +110,7 @@ PDF download or an HTML error page is never run through a JSON decoder unless yo ### Error handling By default the client throws on every 4xx/5xx response. All exceptions implement -`Api\Exception\ApiExceptionInterface`: +`Jschaedl\ApiClient\Exception\ApiExceptionInterface`: | Exception | When | `getCode()` | | --- | --- | --- | @@ -180,8 +180,8 @@ honoured; if it asks for longer than `maxDelay`, the request is not retried. `ma the whole sequence, waits included. ```php -use Api\RetryClient; -use Api\Retry\GenericRetryStrategy; +use Jschaedl\ApiClient\RetryClient; +use Jschaedl\ApiClient\Retry\GenericRetryStrategy; $client = new RetryClient( $client, @@ -201,11 +201,11 @@ Pass a PSR-3 `logger` to have every retry logged at info level (and every retry prevents). Entries name method and path only, never the query string or a body; status code, retry count and delay are in the context. -Waiting and the deadline go through `Api\Clock\ClockInterface` (`NativeClock` by default). To use +Waiting and the deadline go through `Jschaedl\ApiClient\Clock\ClockInterface` (`NativeClock` by default). To use a Symfony clock, e.g. the framework's `clock` service, wrap it in `SymfonyClockAdapter`: ```php -use Api\Clock\SymfonyClockAdapter; +use Jschaedl\ApiClient\Clock\SymfonyClockAdapter; $clock = new SymfonyClockAdapter($symfonyClock); // requires symfony/clock @@ -214,7 +214,7 @@ new RetryClient($client, new GenericRetryStrategy(clock: $clock), clock: $clock) ### Testing with Mocks -`Api\Testing\MockClient` answers requests from a queue and records them, which is handy for +`Jschaedl\ApiClient\Testing\MockClient` answers requests from a queue and records them, which is handy for testing code that uses a client. Error responses are thrown as `ResponseException`, like the real client does: @@ -229,7 +229,7 @@ $client = new MockClient([ self::assertCount(2, $client->requests()); ``` -`Api\Clock\MockClock` (or Symfony's `MockClock` through `SymfonyClockAdapter`) advances its time on `sleep()` instead of waiting. Pass it to `RetryClient` +`Jschaedl\ApiClient\Clock\MockClock` (or Symfony's `MockClock` through `SymfonyClockAdapter`) advances its time on `sleep()` instead of waiting. Pass it to `RetryClient` and `GenericRetryStrategy` to test retries without delays; `sleeps()` returns the waits. To test the `Client` itself without network access, wrap Symfony's `MockHttpClient` in a @@ -254,9 +254,10 @@ keys. See [Testing with Mocks](#testing-with-mocks). -**How do I upgrade from 0.0.1?** +**How do I upgrade?** -See [UPGRADE-0.1.md](UPGRADE-0.1.md). +From 0.1.x see [UPGRADE-0.2.md](UPGRADE-0.2.md) (namespace change), from 0.0.1 first see +[UPGRADE-0.1.md](UPGRADE-0.1.md). --- diff --git a/UPGRADE-0.2.md b/UPGRADE-0.2.md new file mode 100644 index 0000000..9c675b5 --- /dev/null +++ b/UPGRADE-0.2.md @@ -0,0 +1,30 @@ +# Upgrade from 0.1.x to 0.2.0 + +0.2.0 moves every class from the `Api\` namespace to `Jschaedl\ApiClient\`. Nothing else +changes: class names, sub-namespaces and behaviour stay the same. + +| 0.1.x | 0.2.0 | +| --- | --- | +| `Api\Client` | `Jschaedl\ApiClient\Client` | +| `Api\Exception\ClientException` | `Jschaedl\ApiClient\Exception\ClientException` | +| `Api\Retry\GenericRetryStrategy` | `Jschaedl\ApiClient\Retry\GenericRetryStrategy` | +| ... | ... | + +`Api\` was too generic for a library: any application or package could claim it as well. + +## Migrating + +Replace the namespace prefix in your code and config. This rewrites `use` statements (group +`use` included), fully qualified names (`\Api\...`), class names in strings and service IDs in +YAML, and leaves names like `MyApi\` or `App\ApiResource\` alone: + +```bash +grep -rlF 'Api\' src tests config \ + | xargs perl -pi -e 's/(?statusCode()); var_dump($response->body()); -} catch (Api\Exception\ApiExceptionInterface $exception) { +} catch (Jschaedl\ApiClient\Exception\ApiExceptionInterface $exception) { var_dump($exception->getMessage()); } diff --git a/examples/mobilepay.php b/examples/mobilepay.php index 67f093b..17a0657 100644 --- a/examples/mobilepay.php +++ b/examples/mobilepay.php @@ -4,14 +4,14 @@ require_once __DIR__.'/../vendor/autoload.php'; -use Api\Client; -use Api\Request\Encoder\JsonRequestBodyEncoder; -use Api\Request\Handler\AddHeaderHandler; -use Api\Request\Handler\ChainRequestHandler; -use Api\Request\Method; -use Api\Request\Request; -use Api\Response\Decoder\JsonResponseBodyDecoder; -use Api\Response\ResponseInterface; +use Jschaedl\ApiClient\Client; +use Jschaedl\ApiClient\Request\Encoder\JsonRequestBodyEncoder; +use Jschaedl\ApiClient\Request\Handler\AddHeaderHandler; +use Jschaedl\ApiClient\Request\Handler\ChainRequestHandler; +use Jschaedl\ApiClient\Request\Method; +use Jschaedl\ApiClient\Request\Request; +use Jschaedl\ApiClient\Response\Decoder\JsonResponseBodyDecoder; +use Jschaedl\ApiClient\Response\ResponseInterface; use Symfony\Component\HttpClient\Psr18Client; final class GetPaymentPointRequest extends Request diff --git a/examples/shopware5.php b/examples/shopware5.php index bd8166f..243e21e 100644 --- a/examples/shopware5.php +++ b/examples/shopware5.php @@ -5,17 +5,17 @@ require_once __DIR__.'/../vendor/autoload.php'; $psr18HttpClient = new Symfony\Component\HttpClient\Psr18Client(); -$requestBodyEncoder = new Api\Request\Encoder\JsonRequestBodyEncoder(); -$responseBodyDecoder = new Api\Response\Decoder\JsonResponseBodyDecoder(); +$requestBodyEncoder = new Jschaedl\ApiClient\Request\Encoder\JsonRequestBodyEncoder(); +$responseBodyDecoder = new Jschaedl\ApiClient\Response\Decoder\JsonResponseBodyDecoder(); -$shopware5AdminApiClient = new Api\Client( +$shopware5AdminApiClient = new Jschaedl\ApiClient\Client( $psr18HttpClient, $psr18HttpClient, $psr18HttpClient, getEnvVarValue('SHOPWARE5_API_HOST'), - requestHandler: new Api\Request\Handler\ChainRequestHandler([ - new Api\Request\Handler\AddHeaderHandler('Accept', 'application/json'), - new Api\Request\Handler\AddHeaderHandler( + requestHandler: new Jschaedl\ApiClient\Request\Handler\ChainRequestHandler([ + new Jschaedl\ApiClient\Request\Handler\AddHeaderHandler('Accept', 'application/json'), + new Jschaedl\ApiClient\Request\Handler\AddHeaderHandler( 'Authorization', 'Basic'.base64_encode(sprintf('%s:%s', getEnvVarValue('SHOPWARE5_API_USER'), getEnvVarValue('SHOPWARE5_API_KEY'))) ), @@ -25,7 +25,7 @@ ); $response = $shopware5AdminApiClient->request( - new \Api\Request\Request(\Api\Request\Method::GET, '/api/categories') + new \Jschaedl\ApiClient\Request\Request(\Jschaedl\ApiClient\Request\Method::GET, '/api/categories') ); var_dump($response->statusCode()); diff --git a/examples/shopware6.php b/examples/shopware6.php index c758050..322d812 100644 --- a/examples/shopware6.php +++ b/examples/shopware6.php @@ -2,18 +2,18 @@ declare(strict_types=1); -use Api\Client; -use Api\ClientInterface; -use Api\Request\Encoder\JsonRequestBodyEncoder; -use Api\Request\Handler\AccessToken; -use Api\Request\Handler\AccessTokenProviderInterface; -use Api\Request\Handler\AddAccessTokenHandler; -use Api\Request\Handler\AddHeaderHandler; -use Api\Request\Handler\ChainRequestHandler; -use Api\Request\Method; -use Api\Request\Request; -use Api\Response\Decoder\JsonResponseBodyDecoder; -use Api\Response\ResponseInterface; +use Jschaedl\ApiClient\Client; +use Jschaedl\ApiClient\ClientInterface; +use Jschaedl\ApiClient\Request\Encoder\JsonRequestBodyEncoder; +use Jschaedl\ApiClient\Request\Handler\AccessToken; +use Jschaedl\ApiClient\Request\Handler\AccessTokenProviderInterface; +use Jschaedl\ApiClient\Request\Handler\AddAccessTokenHandler; +use Jschaedl\ApiClient\Request\Handler\AddHeaderHandler; +use Jschaedl\ApiClient\Request\Handler\ChainRequestHandler; +use Jschaedl\ApiClient\Request\Method; +use Jschaedl\ApiClient\Request\Request; +use Jschaedl\ApiClient\Response\Decoder\JsonResponseBodyDecoder; +use Jschaedl\ApiClient\Response\ResponseInterface; use Symfony\Component\HttpClient\Psr18Client; require_once __DIR__.'/../vendor/autoload.php'; diff --git a/rector.php b/rector.php index 479c57d..56e4a23 100644 --- a/rector.php +++ b/rector.php @@ -16,7 +16,7 @@ // bug: rector ends in an error refactoring this class //__DIR__.'/src/MobilePay/AppPayment/PaymentPoints/PaymentPointState.php', // bug: rector applies FinalizeClassesWithoutChildrenRector - //__DIR__.'/src/Api/Exception/ClientException.php', + //__DIR__.'/src/Exception/ClientException.php', ]); $rectorConfig->rules([ diff --git a/src/Api/Client.php b/src/Client.php similarity index 86% rename from src/Api/Client.php rename to src/Client.php index 95c7f1f..411dbbc 100644 --- a/src/Api/Client.php +++ b/src/Client.php @@ -2,19 +2,19 @@ declare(strict_types=1); -namespace Api; - -use Api\Exception\ResponseException; -use Api\Exception\TransportException; -use Api\Request\BodyEncoderAwareRequestInterface; -use Api\Request\HeadersAwareRequestInterface; -use Api\Request\RequestBodyEncoderInterface; -use Api\Request\RequestHandlerInterface; -use Api\Request\RequestInterface; -use Api\Response\Response; -use Api\Response\ResponseBodyDecoderInterface; -use Api\Response\ResponseHandlerInterface; -use Api\Response\ResponseInterface; +namespace Jschaedl\ApiClient; + +use Jschaedl\ApiClient\Exception\ResponseException; +use Jschaedl\ApiClient\Exception\TransportException; +use Jschaedl\ApiClient\Request\BodyEncoderAwareRequestInterface; +use Jschaedl\ApiClient\Request\HeadersAwareRequestInterface; +use Jschaedl\ApiClient\Request\RequestBodyEncoderInterface; +use Jschaedl\ApiClient\Request\RequestHandlerInterface; +use Jschaedl\ApiClient\Request\RequestInterface; +use Jschaedl\ApiClient\Response\Response; +use Jschaedl\ApiClient\Response\ResponseBodyDecoderInterface; +use Jschaedl\ApiClient\Response\ResponseHandlerInterface; +use Jschaedl\ApiClient\Response\ResponseInterface; use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface as PsrClientInterface; use Psr\Http\Message\RequestFactoryInterface; diff --git a/src/Api/ClientInterface.php b/src/ClientInterface.php similarity index 55% rename from src/Api/ClientInterface.php rename to src/ClientInterface.php index d47805c..7eefdab 100644 --- a/src/Api/ClientInterface.php +++ b/src/ClientInterface.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Api; +namespace Jschaedl\ApiClient; -use Api\Exception\ApiExceptionInterface; -use Api\Exception\ResponseException; -use Api\Exception\TransportException; -use Api\Request\RequestInterface; -use Api\Response\ResponseInterface; +use Jschaedl\ApiClient\Exception\ApiExceptionInterface; +use Jschaedl\ApiClient\Exception\ResponseException; +use Jschaedl\ApiClient\Exception\TransportException; +use Jschaedl\ApiClient\Request\RequestInterface; +use Jschaedl\ApiClient\Response\ResponseInterface; interface ClientInterface { diff --git a/src/Api/ClientTest.php b/src/ClientTest.php similarity index 91% rename from src/Api/ClientTest.php rename to src/ClientTest.php index 1f79aef..bb1a99a 100644 --- a/src/Api/ClientTest.php +++ b/src/ClientTest.php @@ -2,24 +2,24 @@ declare(strict_types=1); -namespace Api; - -use Api\Exception\ClientException; -use Api\Exception\DecodingException; -use Api\Exception\ResponseException; -use Api\Exception\ServerException; -use Api\Exception\TransportException; -use Api\Request\Encoder\FormRequestBodyEncoder; -use Api\Request\Encoder\JsonRequestBodyEncoder; -use Api\Request\Handler\AddHeaderHandler; -use Api\Request\Header; -use Api\Request\Method; -use Api\Request\Request; -use Api\Request\RequestHandlerInterface; -use Api\Request\RequestInterface; -use Api\Response\Decoder\JsonResponseBodyDecoder; -use Api\Response\ResponseHandlerInterface; -use Api\Response\ResponseInterface; +namespace Jschaedl\ApiClient; + +use Jschaedl\ApiClient\Exception\ClientException; +use Jschaedl\ApiClient\Exception\DecodingException; +use Jschaedl\ApiClient\Exception\ResponseException; +use Jschaedl\ApiClient\Exception\ServerException; +use Jschaedl\ApiClient\Exception\TransportException; +use Jschaedl\ApiClient\Request\Encoder\FormRequestBodyEncoder; +use Jschaedl\ApiClient\Request\Encoder\JsonRequestBodyEncoder; +use Jschaedl\ApiClient\Request\Handler\AddHeaderHandler; +use Jschaedl\ApiClient\Request\Header; +use Jschaedl\ApiClient\Request\Method; +use Jschaedl\ApiClient\Request\Request; +use Jschaedl\ApiClient\Request\RequestHandlerInterface; +use Jschaedl\ApiClient\Request\RequestInterface; +use Jschaedl\ApiClient\Response\Decoder\JsonResponseBodyDecoder; +use Jschaedl\ApiClient\Response\ResponseHandlerInterface; +use Jschaedl\ApiClient\Response\ResponseInterface; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\UsesClass; diff --git a/src/Api/ClientsTest.php b/src/ClientsTest.php similarity index 87% rename from src/Api/ClientsTest.php rename to src/ClientsTest.php index 9471745..e90f482 100644 --- a/src/Api/ClientsTest.php +++ b/src/ClientsTest.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace Api; +namespace Jschaedl\ApiClient; -use Api\Request\Encoder\JsonRequestBodyEncoder; -use Api\Request\Handler\AddHeaderHandler; -use Api\Request\Handler\ChainRequestHandler; -use Api\Request\Header; -use Api\Request\Method; -use Api\Request\Request; -use Api\Response\Decoder\JsonResponseBodyDecoder; use GuzzleHttp\Psr7\HttpFactory; +use Jschaedl\ApiClient\Request\Encoder\JsonRequestBodyEncoder; +use Jschaedl\ApiClient\Request\Handler\AddHeaderHandler; +use Jschaedl\ApiClient\Request\Handler\ChainRequestHandler; +use Jschaedl\ApiClient\Request\Header; +use Jschaedl\ApiClient\Request\Method; +use Jschaedl\ApiClient\Request\Request; +use Jschaedl\ApiClient\Response\Decoder\JsonResponseBodyDecoder; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; diff --git a/src/Api/Clock/ClockInterface.php b/src/Clock/ClockInterface.php similarity index 87% rename from src/Api/Clock/ClockInterface.php rename to src/Clock/ClockInterface.php index 698efd0..b0e3055 100644 --- a/src/Api/Clock/ClockInterface.php +++ b/src/Clock/ClockInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Clock; +namespace Jschaedl\ApiClient\Clock; /** * A PSR-20 clock that can also wait, so retry delays and deadlines can be tested without sleeping. diff --git a/src/Api/Clock/MockClock.php b/src/Clock/MockClock.php similarity index 96% rename from src/Api/Clock/MockClock.php rename to src/Clock/MockClock.php index 855957c..8456bf0 100644 --- a/src/Api/Clock/MockClock.php +++ b/src/Clock/MockClock.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Clock; +namespace Jschaedl\ApiClient\Clock; /** * A clock for tests: sleep() advances the time instead of waiting, and every sleep is recorded. diff --git a/src/Api/Clock/MockClockTest.php b/src/Clock/MockClockTest.php similarity index 96% rename from src/Api/Clock/MockClockTest.php rename to src/Clock/MockClockTest.php index fb12706..21df25f 100644 --- a/src/Api/Clock/MockClockTest.php +++ b/src/Clock/MockClockTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Clock; +namespace Jschaedl\ApiClient\Clock; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; diff --git a/src/Api/Clock/NativeClock.php b/src/Clock/NativeClock.php similarity index 90% rename from src/Api/Clock/NativeClock.php rename to src/Clock/NativeClock.php index 454b8f3..44430e2 100644 --- a/src/Api/Clock/NativeClock.php +++ b/src/Clock/NativeClock.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Clock; +namespace Jschaedl\ApiClient\Clock; final class NativeClock implements ClockInterface { diff --git a/src/Api/Clock/SymfonyClockAdapter.php b/src/Clock/SymfonyClockAdapter.php similarity index 95% rename from src/Api/Clock/SymfonyClockAdapter.php rename to src/Clock/SymfonyClockAdapter.php index f30b68d..e1cc11a 100644 --- a/src/Api/Clock/SymfonyClockAdapter.php +++ b/src/Clock/SymfonyClockAdapter.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Clock; +namespace Jschaedl\ApiClient\Clock; use Symfony\Component\Clock\ClockInterface as SymfonyClockInterface; diff --git a/src/Api/Clock/SymfonyClockAdapterTest.php b/src/Clock/SymfonyClockAdapterTest.php similarity index 95% rename from src/Api/Clock/SymfonyClockAdapterTest.php rename to src/Clock/SymfonyClockAdapterTest.php index d3a3e39..25a6400 100644 --- a/src/Api/Clock/SymfonyClockAdapterTest.php +++ b/src/Clock/SymfonyClockAdapterTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Clock; +namespace Jschaedl\ApiClient\Clock; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; diff --git a/src/Api/Exception/ApiExceptionInterface.php b/src/Exception/ApiExceptionInterface.php similarity index 82% rename from src/Api/Exception/ApiExceptionInterface.php rename to src/Exception/ApiExceptionInterface.php index 462fdec..d6f4439 100644 --- a/src/Api/Exception/ApiExceptionInterface.php +++ b/src/Exception/ApiExceptionInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Exception; +namespace Jschaedl\ApiClient\Exception; /** * Marker for every exception thrown by this library, so callers can catch them all at once. diff --git a/src/Api/Exception/ClientException.php b/src/Exception/ClientException.php similarity index 80% rename from src/Api/Exception/ClientException.php rename to src/Exception/ClientException.php index b70f962..35df369 100644 --- a/src/Api/Exception/ClientException.php +++ b/src/Exception/ClientException.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Api\Exception; +namespace Jschaedl\ApiClient\Exception; -use Api\Request\RequestInterface; -use Api\Response\ResponseInterface; +use Jschaedl\ApiClient\Request\RequestInterface; +use Jschaedl\ApiClient\Response\ResponseInterface; /** * @see ClientExceptionTest diff --git a/src/Api/Exception/ClientExceptionTest.php b/src/Exception/ClientExceptionTest.php similarity index 81% rename from src/Api/Exception/ClientExceptionTest.php rename to src/Exception/ClientExceptionTest.php index 4f1392b..c444ed7 100644 --- a/src/Api/Exception/ClientExceptionTest.php +++ b/src/Exception/ClientExceptionTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Api\Exception; +namespace Jschaedl\ApiClient\Exception; -use Api\Request\Method; -use Api\Request\Request; -use Api\Response\Response; +use Jschaedl\ApiClient\Request\Method; +use Jschaedl\ApiClient\Request\Request; +use Jschaedl\ApiClient\Response\Response; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -33,7 +33,7 @@ public function test_it_can_be_created(): void public function test_it_throws_InvalidArgumentException_on_non_4xx_code(int $invalidCode): void { $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Class "Api\Exception\ClientException" requires a response with a 4xx status code'); + $this->expectExceptionMessage('Class "Jschaedl\ApiClient\Exception\ClientException" requires a response with a 4xx status code'); new ClientException(new Request(Method::GET, 'items'), new Response('', $invalidCode)); } diff --git a/src/Api/Exception/DecodingException.php b/src/Exception/DecodingException.php similarity index 91% rename from src/Api/Exception/DecodingException.php rename to src/Exception/DecodingException.php index 7e38315..aaf9afa 100644 --- a/src/Api/Exception/DecodingException.php +++ b/src/Exception/DecodingException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Exception; +namespace Jschaedl\ApiClient\Exception; /** * Thrown when a response body cannot be decoded. The body itself is never part of the message. diff --git a/src/Api/Exception/RequestDescription.php b/src/Exception/RequestDescription.php similarity index 85% rename from src/Api/Exception/RequestDescription.php rename to src/Exception/RequestDescription.php index 05bea42..48cda0c 100644 --- a/src/Api/Exception/RequestDescription.php +++ b/src/Exception/RequestDescription.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Api\Exception; +namespace Jschaedl\ApiClient\Exception; -use Api\Request\RequestInterface; +use Jschaedl\ApiClient\Request\RequestInterface; /** * Describes a request for exception messages as "METHOD /path". diff --git a/src/Api/Exception/ResponseException.php b/src/Exception/ResponseException.php similarity index 91% rename from src/Api/Exception/ResponseException.php rename to src/Exception/ResponseException.php index a7e59bd..9b25d00 100644 --- a/src/Api/Exception/ResponseException.php +++ b/src/Exception/ResponseException.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Api\Exception; +namespace Jschaedl\ApiClient\Exception; -use Api\Request\RequestInterface; -use Api\Response\ResponseInterface; +use Jschaedl\ApiClient\Request\RequestInterface; +use Jschaedl\ApiClient\Response\ResponseInterface; /** * Thrown when the API answered with an error status code. diff --git a/src/Api/Exception/ResponseExceptionTest.php b/src/Exception/ResponseExceptionTest.php similarity index 92% rename from src/Api/Exception/ResponseExceptionTest.php rename to src/Exception/ResponseExceptionTest.php index 0afbdf4..9be6cf5 100644 --- a/src/Api/Exception/ResponseExceptionTest.php +++ b/src/Exception/ResponseExceptionTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Api\Exception; +namespace Jschaedl\ApiClient\Exception; -use Api\Request\Method; -use Api\Request\Request; -use Api\Response\Response; +use Jschaedl\ApiClient\Request\Method; +use Jschaedl\ApiClient\Request\Request; +use Jschaedl\ApiClient\Response\Response; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\UsesClass; diff --git a/src/Api/Exception/ServerException.php b/src/Exception/ServerException.php similarity index 80% rename from src/Api/Exception/ServerException.php rename to src/Exception/ServerException.php index 251e5ab..dcc28e8 100644 --- a/src/Api/Exception/ServerException.php +++ b/src/Exception/ServerException.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Api\Exception; +namespace Jschaedl\ApiClient\Exception; -use Api\Request\RequestInterface; -use Api\Response\ResponseInterface; +use Jschaedl\ApiClient\Request\RequestInterface; +use Jschaedl\ApiClient\Response\ResponseInterface; /** * @see ServerExceptionTest diff --git a/src/Api/Exception/ServerExceptionTest.php b/src/Exception/ServerExceptionTest.php similarity index 81% rename from src/Api/Exception/ServerExceptionTest.php rename to src/Exception/ServerExceptionTest.php index feb10e2..33f8598 100644 --- a/src/Api/Exception/ServerExceptionTest.php +++ b/src/Exception/ServerExceptionTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Api\Exception; +namespace Jschaedl\ApiClient\Exception; -use Api\Request\Method; -use Api\Request\Request; -use Api\Response\Response; +use Jschaedl\ApiClient\Request\Method; +use Jschaedl\ApiClient\Request\Request; +use Jschaedl\ApiClient\Response\Response; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -33,7 +33,7 @@ public function test_it_can_be_created(): void public function test_it_throws_InvalidArgumentException_on_non_5xx_code(int $invalidCode): void { $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Class "Api\Exception\ServerException" requires a response with a 5xx status code'); + $this->expectExceptionMessage('Class "Jschaedl\ApiClient\Exception\ServerException" requires a response with a 5xx status code'); new ServerException(new Request(Method::GET, 'items'), new Response('', $invalidCode)); } diff --git a/src/Api/Exception/TransportException.php b/src/Exception/TransportException.php similarity index 93% rename from src/Api/Exception/TransportException.php rename to src/Exception/TransportException.php index d0c97d9..12c6f6b 100644 --- a/src/Api/Exception/TransportException.php +++ b/src/Exception/TransportException.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Api\Exception; +namespace Jschaedl\ApiClient\Exception; -use Api\Request\RequestInterface; +use Jschaedl\ApiClient\Request\RequestInterface; use Psr\Http\Client\RequestExceptionInterface; /** diff --git a/src/Api/Exception/TransportExceptionTest.php b/src/Exception/TransportExceptionTest.php similarity index 93% rename from src/Api/Exception/TransportExceptionTest.php rename to src/Exception/TransportExceptionTest.php index 8587250..d3a757c 100644 --- a/src/Api/Exception/TransportExceptionTest.php +++ b/src/Exception/TransportExceptionTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Api\Exception; +namespace Jschaedl\ApiClient\Exception; -use Api\Request\Method; -use Api\Request\Request; +use Jschaedl\ApiClient\Request\Method; +use Jschaedl\ApiClient\Request\Request; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\UsesClass; diff --git a/src/Api/Request/BodyEncoderAwareRequestInterface.php b/src/Request/BodyEncoderAwareRequestInterface.php similarity index 90% rename from src/Api/Request/BodyEncoderAwareRequestInterface.php rename to src/Request/BodyEncoderAwareRequestInterface.php index 4ba8695..268c02e 100644 --- a/src/Api/Request/BodyEncoderAwareRequestInterface.php +++ b/src/Request/BodyEncoderAwareRequestInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request; +namespace Jschaedl\ApiClient\Request; /** * A request that brings its own body encoder, overriding the one the client was built with diff --git a/src/Api/Request/Encoder/EncodersTest.php b/src/Request/Encoder/EncodersTest.php similarity index 96% rename from src/Api/Request/Encoder/EncodersTest.php rename to src/Request/Encoder/EncodersTest.php index 69c8dc0..b89e6f7 100644 --- a/src/Api/Request/Encoder/EncodersTest.php +++ b/src/Request/Encoder/EncodersTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request\Encoder; +namespace Jschaedl\ApiClient\Request\Encoder; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; diff --git a/src/Api/Request/Encoder/FormRequestBodyEncoder.php b/src/Request/Encoder/FormRequestBodyEncoder.php similarity index 80% rename from src/Api/Request/Encoder/FormRequestBodyEncoder.php rename to src/Request/Encoder/FormRequestBodyEncoder.php index e1c1889..ff75482 100644 --- a/src/Api/Request/Encoder/FormRequestBodyEncoder.php +++ b/src/Request/Encoder/FormRequestBodyEncoder.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Api\Request\Encoder; +namespace Jschaedl\ApiClient\Request\Encoder; -use Api\Request\RequestBodyEncoderInterface; +use Jschaedl\ApiClient\Request\RequestBodyEncoderInterface; /** * application/x-www-form-urlencoded, e.g. for OAuth token endpoints. diff --git a/src/Api/Request/Encoder/JsonRequestBodyEncoder.php b/src/Request/Encoder/JsonRequestBodyEncoder.php similarity index 82% rename from src/Api/Request/Encoder/JsonRequestBodyEncoder.php rename to src/Request/Encoder/JsonRequestBodyEncoder.php index 83ba3f3..db302b5 100644 --- a/src/Api/Request/Encoder/JsonRequestBodyEncoder.php +++ b/src/Request/Encoder/JsonRequestBodyEncoder.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Api\Request\Encoder; +namespace Jschaedl\ApiClient\Request\Encoder; -use Api\Request\RequestBodyEncoderInterface; +use Jschaedl\ApiClient\Request\RequestBodyEncoderInterface; final readonly class JsonRequestBodyEncoder implements RequestBodyEncoderInterface { diff --git a/src/Api/Request/Handler/AccessToken.php b/src/Request/Handler/AccessToken.php similarity index 88% rename from src/Api/Request/Handler/AccessToken.php rename to src/Request/Handler/AccessToken.php index 8bbf217..894cd24 100644 --- a/src/Api/Request/Handler/AccessToken.php +++ b/src/Request/Handler/AccessToken.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request\Handler; +namespace Jschaedl\ApiClient\Request\Handler; final readonly class AccessToken { diff --git a/src/Api/Request/Handler/AccessTokenProviderInterface.php b/src/Request/Handler/AccessTokenProviderInterface.php similarity index 73% rename from src/Api/Request/Handler/AccessTokenProviderInterface.php rename to src/Request/Handler/AccessTokenProviderInterface.php index c4a127a..e04d828 100644 --- a/src/Api/Request/Handler/AccessTokenProviderInterface.php +++ b/src/Request/Handler/AccessTokenProviderInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request\Handler; +namespace Jschaedl\ApiClient\Request\Handler; interface AccessTokenProviderInterface { diff --git a/src/Api/Request/Handler/AddAccessTokenHandler.php b/src/Request/Handler/AddAccessTokenHandler.php similarity index 74% rename from src/Api/Request/Handler/AddAccessTokenHandler.php rename to src/Request/Handler/AddAccessTokenHandler.php index 6348347..9548a0e 100644 --- a/src/Api/Request/Handler/AddAccessTokenHandler.php +++ b/src/Request/Handler/AddAccessTokenHandler.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Api\Request\Handler; +namespace Jschaedl\ApiClient\Request\Handler; -use Api\Request\HeadersAwareRequestInterface; -use Api\Request\RequestHandlerInterface; -use Api\Request\RequestInterface; +use Jschaedl\ApiClient\Request\HeadersAwareRequestInterface; +use Jschaedl\ApiClient\Request\RequestHandlerInterface; +use Jschaedl\ApiClient\Request\RequestInterface; final readonly class AddAccessTokenHandler implements RequestHandlerInterface { diff --git a/src/Api/Request/Handler/AddHeaderHandler.php b/src/Request/Handler/AddHeaderHandler.php similarity index 69% rename from src/Api/Request/Handler/AddHeaderHandler.php rename to src/Request/Handler/AddHeaderHandler.php index 77564bf..209247c 100644 --- a/src/Api/Request/Handler/AddHeaderHandler.php +++ b/src/Request/Handler/AddHeaderHandler.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Api\Request\Handler; +namespace Jschaedl\ApiClient\Request\Handler; -use Api\Request\HeadersAwareRequestInterface; -use Api\Request\RequestHandlerInterface; -use Api\Request\RequestInterface; +use Jschaedl\ApiClient\Request\HeadersAwareRequestInterface; +use Jschaedl\ApiClient\Request\RequestHandlerInterface; +use Jschaedl\ApiClient\Request\RequestInterface; final readonly class AddHeaderHandler implements RequestHandlerInterface { diff --git a/src/Api/Request/Handler/ChainRequestHandler.php b/src/Request/Handler/ChainRequestHandler.php similarity index 80% rename from src/Api/Request/Handler/ChainRequestHandler.php rename to src/Request/Handler/ChainRequestHandler.php index c2d6bcb..aea23eb 100644 --- a/src/Api/Request/Handler/ChainRequestHandler.php +++ b/src/Request/Handler/ChainRequestHandler.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Api\Request\Handler; +namespace Jschaedl\ApiClient\Request\Handler; -use Api\Request\RequestHandlerInterface; -use Api\Request\RequestInterface; +use Jschaedl\ApiClient\Request\RequestHandlerInterface; +use Jschaedl\ApiClient\Request\RequestInterface; use Webmozart\Assert\Assert; final readonly class ChainRequestHandler implements RequestHandlerInterface diff --git a/src/Api/Request/Header.php b/src/Request/Header.php similarity index 93% rename from src/Api/Request/Header.php rename to src/Request/Header.php index a0bec48..521742a 100644 --- a/src/Api/Request/Header.php +++ b/src/Request/Header.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request; +namespace Jschaedl\ApiClient\Request; final class Header { diff --git a/src/Api/Request/HeadersAwareRequestInterface.php b/src/Request/HeadersAwareRequestInterface.php similarity index 86% rename from src/Api/Request/HeadersAwareRequestInterface.php rename to src/Request/HeadersAwareRequestInterface.php index 47b2433..4a2c606 100644 --- a/src/Api/Request/HeadersAwareRequestInterface.php +++ b/src/Request/HeadersAwareRequestInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request; +namespace Jschaedl\ApiClient\Request; interface HeadersAwareRequestInterface extends RequestInterface { diff --git a/src/Api/Request/HeadersAwareRequestTrait.php b/src/Request/HeadersAwareRequestTrait.php similarity index 90% rename from src/Api/Request/HeadersAwareRequestTrait.php rename to src/Request/HeadersAwareRequestTrait.php index bd3eef7..1ebb50d 100644 --- a/src/Api/Request/HeadersAwareRequestTrait.php +++ b/src/Request/HeadersAwareRequestTrait.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request; +namespace Jschaedl\ApiClient\Request; trait HeadersAwareRequestTrait { diff --git a/src/Api/Request/IsDelete.php b/src/Request/IsDelete.php similarity index 84% rename from src/Api/Request/IsDelete.php rename to src/Request/IsDelete.php index ec821f2..49c1ac1 100644 --- a/src/Api/Request/IsDelete.php +++ b/src/Request/IsDelete.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request; +namespace Jschaedl\ApiClient\Request; trait IsDelete { diff --git a/src/Api/Request/IsGet.php b/src/Request/IsGet.php similarity index 84% rename from src/Api/Request/IsGet.php rename to src/Request/IsGet.php index 5c83e4a..c24e9d2 100644 --- a/src/Api/Request/IsGet.php +++ b/src/Request/IsGet.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request; +namespace Jschaedl\ApiClient\Request; trait IsGet { diff --git a/src/Api/Request/IsPatch.php b/src/Request/IsPatch.php similarity index 78% rename from src/Api/Request/IsPatch.php rename to src/Request/IsPatch.php index 20696ea..01cf2f7 100644 --- a/src/Api/Request/IsPatch.php +++ b/src/Request/IsPatch.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request; +namespace Jschaedl\ApiClient\Request; trait IsPatch { diff --git a/src/Api/Request/IsPost.php b/src/Request/IsPost.php similarity index 78% rename from src/Api/Request/IsPost.php rename to src/Request/IsPost.php index 224f54a..5405646 100644 --- a/src/Api/Request/IsPost.php +++ b/src/Request/IsPost.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request; +namespace Jschaedl\ApiClient\Request; trait IsPost { diff --git a/src/Api/Request/IsPut.php b/src/Request/IsPut.php similarity index 77% rename from src/Api/Request/IsPut.php rename to src/Request/IsPut.php index 06627f2..358ea12 100644 --- a/src/Api/Request/IsPut.php +++ b/src/Request/IsPut.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request; +namespace Jschaedl\ApiClient\Request; trait IsPut { diff --git a/src/Api/Request/Method.php b/src/Request/Method.php similarity index 93% rename from src/Api/Request/Method.php rename to src/Request/Method.php index 8cf99c6..4eb6b31 100644 --- a/src/Api/Request/Method.php +++ b/src/Request/Method.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request; +namespace Jschaedl\ApiClient\Request; enum Method: string { diff --git a/src/Api/Request/Request.php b/src/Request/Request.php similarity index 97% rename from src/Api/Request/Request.php rename to src/Request/Request.php index fa72ec9..3fa449e 100644 --- a/src/Api/Request/Request.php +++ b/src/Request/Request.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request; +namespace Jschaedl\ApiClient\Request; class Request implements HeadersAwareRequestInterface, BodyEncoderAwareRequestInterface { diff --git a/src/Api/Request/RequestBodyEncoderInterface.php b/src/Request/RequestBodyEncoderInterface.php similarity index 89% rename from src/Api/Request/RequestBodyEncoderInterface.php rename to src/Request/RequestBodyEncoderInterface.php index bb209f7..6795617 100644 --- a/src/Api/Request/RequestBodyEncoderInterface.php +++ b/src/Request/RequestBodyEncoderInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request; +namespace Jschaedl\ApiClient\Request; interface RequestBodyEncoderInterface { diff --git a/src/Api/Request/RequestHandlerInterface.php b/src/Request/RequestHandlerInterface.php similarity index 79% rename from src/Api/Request/RequestHandlerInterface.php rename to src/Request/RequestHandlerInterface.php index 3ced344..e8c8d48 100644 --- a/src/Api/Request/RequestHandlerInterface.php +++ b/src/Request/RequestHandlerInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request; +namespace Jschaedl\ApiClient\Request; interface RequestHandlerInterface { diff --git a/src/Api/Request/RequestInterface.php b/src/Request/RequestInterface.php similarity index 89% rename from src/Api/Request/RequestInterface.php rename to src/Request/RequestInterface.php index 86e8da9..da34773 100644 --- a/src/Api/Request/RequestInterface.php +++ b/src/Request/RequestInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request; +namespace Jschaedl\ApiClient\Request; interface RequestInterface { diff --git a/src/Api/Request/TraitsTest.php b/src/Request/TraitsTest.php similarity index 96% rename from src/Api/Request/TraitsTest.php rename to src/Request/TraitsTest.php index 56c72f8..a853ed8 100644 --- a/src/Api/Request/TraitsTest.php +++ b/src/Request/TraitsTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Request; +namespace Jschaedl\ApiClient\Request; use PHPUnit\Framework\Attributes\CoversTrait; use PHPUnit\Framework\Attributes\Group; diff --git a/src/Api/Response/Decoder/JsonResponseBodyDecoder.php b/src/Response/Decoder/JsonResponseBodyDecoder.php similarity index 74% rename from src/Api/Response/Decoder/JsonResponseBodyDecoder.php rename to src/Response/Decoder/JsonResponseBodyDecoder.php index 1c4b6e1..4588af6 100644 --- a/src/Api/Response/Decoder/JsonResponseBodyDecoder.php +++ b/src/Response/Decoder/JsonResponseBodyDecoder.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Api\Response\Decoder; +namespace Jschaedl\ApiClient\Response\Decoder; -use Api\Response\ResponseBodyDecoderInterface; +use Jschaedl\ApiClient\Response\ResponseBodyDecoderInterface; final class JsonResponseBodyDecoder implements ResponseBodyDecoderInterface { diff --git a/src/Api/Response/Handler/ChainResponseHandler.php b/src/Response/Handler/ChainResponseHandler.php similarity index 77% rename from src/Api/Response/Handler/ChainResponseHandler.php rename to src/Response/Handler/ChainResponseHandler.php index e142b78..24f5722 100644 --- a/src/Api/Response/Handler/ChainResponseHandler.php +++ b/src/Response/Handler/ChainResponseHandler.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Api\Response\Handler; +namespace Jschaedl\ApiClient\Response\Handler; -use Api\Request\RequestInterface; -use Api\Response\ResponseHandlerInterface; -use Api\Response\ResponseInterface; +use Jschaedl\ApiClient\Request\RequestInterface; +use Jschaedl\ApiClient\Response\ResponseHandlerInterface; +use Jschaedl\ApiClient\Response\ResponseInterface; use Webmozart\Assert\Assert; final readonly class ChainResponseHandler implements ResponseHandlerInterface diff --git a/src/Api/Response/Response.php b/src/Response/Response.php similarity index 94% rename from src/Api/Response/Response.php rename to src/Response/Response.php index 47415af..b6dd08b 100644 --- a/src/Api/Response/Response.php +++ b/src/Response/Response.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Api\Response; +namespace Jschaedl\ApiClient\Response; -use Api\Exception\DecodingException; +use Jschaedl\ApiClient\Exception\DecodingException; /** * @see ResponseTest diff --git a/src/Api/Response/ResponseBodyDecoderInterface.php b/src/Response/ResponseBodyDecoderInterface.php similarity index 86% rename from src/Api/Response/ResponseBodyDecoderInterface.php rename to src/Response/ResponseBodyDecoderInterface.php index a23dac7..9998144 100644 --- a/src/Api/Response/ResponseBodyDecoderInterface.php +++ b/src/Response/ResponseBodyDecoderInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Api\Response; +namespace Jschaedl\ApiClient\Response; interface ResponseBodyDecoderInterface { diff --git a/src/Api/Response/ResponseHandlerInterface.php b/src/Response/ResponseHandlerInterface.php similarity index 80% rename from src/Api/Response/ResponseHandlerInterface.php rename to src/Response/ResponseHandlerInterface.php index a643b93..f90c132 100644 --- a/src/Api/Response/ResponseHandlerInterface.php +++ b/src/Response/ResponseHandlerInterface.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Api\Response; +namespace Jschaedl\ApiClient\Response; -use Api\Request\RequestInterface; +use Jschaedl\ApiClient\Request\RequestInterface; /** * Runs before the client checks the status code, so a handler can turn an expected diff --git a/src/Api/Response/ResponseInterface.php b/src/Response/ResponseInterface.php similarity index 87% rename from src/Api/Response/ResponseInterface.php rename to src/Response/ResponseInterface.php index d2a4d55..b6dacce 100644 --- a/src/Api/Response/ResponseInterface.php +++ b/src/Response/ResponseInterface.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Api\Response; +namespace Jschaedl\ApiClient\Response; -use Api\Exception\DecodingException; +use Jschaedl\ApiClient\Exception\DecodingException; interface ResponseInterface { diff --git a/src/Api/Response/ResponseTest.php b/src/Response/ResponseTest.php similarity index 93% rename from src/Api/Response/ResponseTest.php rename to src/Response/ResponseTest.php index b4fe86d..15e531c 100644 --- a/src/Api/Response/ResponseTest.php +++ b/src/Response/ResponseTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Api\Response; +namespace Jschaedl\ApiClient\Response; -use Api\Exception\DecodingException; -use Api\Response\Decoder\JsonResponseBodyDecoder; +use Jschaedl\ApiClient\Exception\DecodingException; +use Jschaedl\ApiClient\Response\Decoder\JsonResponseBodyDecoder; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\UsesClass; diff --git a/src/Api/Retry/GenericRetryStrategy.php b/src/Retry/GenericRetryStrategy.php similarity index 94% rename from src/Api/Retry/GenericRetryStrategy.php rename to src/Retry/GenericRetryStrategy.php index 02f0e4f..9062f39 100644 --- a/src/Api/Retry/GenericRetryStrategy.php +++ b/src/Retry/GenericRetryStrategy.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Api\Retry; - -use Api\Clock\ClockInterface; -use Api\Clock\NativeClock; -use Api\Exception\ResponseException; -use Api\Exception\TransportException; -use Api\Request\Method; -use Api\Request\RequestInterface; +namespace Jschaedl\ApiClient\Retry; + +use Jschaedl\ApiClient\Clock\ClockInterface; +use Jschaedl\ApiClient\Clock\NativeClock; +use Jschaedl\ApiClient\Exception\ResponseException; +use Jschaedl\ApiClient\Exception\TransportException; +use Jschaedl\ApiClient\Request\Method; +use Jschaedl\ApiClient\Request\RequestInterface; use Webmozart\Assert\Assert; /** diff --git a/src/Api/Retry/GenericRetryStrategyTest.php b/src/Retry/GenericRetryStrategyTest.php similarity index 93% rename from src/Api/Retry/GenericRetryStrategyTest.php rename to src/Retry/GenericRetryStrategyTest.php index d6d1579..ce02b99 100644 --- a/src/Api/Retry/GenericRetryStrategyTest.php +++ b/src/Retry/GenericRetryStrategyTest.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace Api\Retry; - -use Api\Clock\MockClock; -use Api\Exception\ClientException; -use Api\Exception\RequestDescription; -use Api\Exception\ResponseException; -use Api\Exception\ServerException; -use Api\Exception\TransportException; -use Api\Request\Method; -use Api\Request\Request; -use Api\Response\Response; +namespace Jschaedl\ApiClient\Retry; + +use Jschaedl\ApiClient\Clock\MockClock; +use Jschaedl\ApiClient\Exception\ClientException; +use Jschaedl\ApiClient\Exception\RequestDescription; +use Jschaedl\ApiClient\Exception\ResponseException; +use Jschaedl\ApiClient\Exception\ServerException; +use Jschaedl\ApiClient\Exception\TransportException; +use Jschaedl\ApiClient\Request\Method; +use Jschaedl\ApiClient\Request\Request; +use Jschaedl\ApiClient\Response\Response; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; diff --git a/src/Api/Retry/RetryStrategyInterface.php b/src/Retry/RetryStrategyInterface.php similarity index 67% rename from src/Api/Retry/RetryStrategyInterface.php rename to src/Retry/RetryStrategyInterface.php index d2928cc..4a66c51 100644 --- a/src/Api/Retry/RetryStrategyInterface.php +++ b/src/Retry/RetryStrategyInterface.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Api\Retry; +namespace Jschaedl\ApiClient\Retry; -use Api\Exception\ResponseException; -use Api\Exception\TransportException; -use Api\Request\RequestInterface; +use Jschaedl\ApiClient\Exception\ResponseException; +use Jschaedl\ApiClient\Exception\TransportException; +use Jschaedl\ApiClient\Request\RequestInterface; interface RetryStrategyInterface { diff --git a/src/Api/RetryClient.php b/src/RetryClient.php similarity index 88% rename from src/Api/RetryClient.php rename to src/RetryClient.php index bb3043d..753df87 100644 --- a/src/Api/RetryClient.php +++ b/src/RetryClient.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace Api; - -use Api\Clock\ClockInterface; -use Api\Clock\NativeClock; -use Api\Exception\RequestDescription; -use Api\Exception\ResponseException; -use Api\Exception\TransportException; -use Api\Request\RequestInterface; -use Api\Response\ResponseInterface; -use Api\Retry\GenericRetryStrategy; -use Api\Retry\RetryStrategyInterface; +namespace Jschaedl\ApiClient; + +use Jschaedl\ApiClient\Clock\ClockInterface; +use Jschaedl\ApiClient\Clock\NativeClock; +use Jschaedl\ApiClient\Exception\RequestDescription; +use Jschaedl\ApiClient\Exception\ResponseException; +use Jschaedl\ApiClient\Exception\TransportException; +use Jschaedl\ApiClient\Request\RequestInterface; +use Jschaedl\ApiClient\Response\ResponseInterface; +use Jschaedl\ApiClient\Retry\GenericRetryStrategy; +use Jschaedl\ApiClient\Retry\RetryStrategyInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; use Webmozart\Assert\Assert; diff --git a/src/Api/RetryClientTest.php b/src/RetryClientTest.php similarity index 94% rename from src/Api/RetryClientTest.php rename to src/RetryClientTest.php index 3a1d4b8..e779d9e 100644 --- a/src/Api/RetryClientTest.php +++ b/src/RetryClientTest.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace Api; - -use Api\Clock\MockClock; -use Api\Exception\ResponseException; -use Api\Exception\ServerException; -use Api\Exception\TransportException; -use Api\Request\Method; -use Api\Request\Request; -use Api\Response\Response; -use Api\Retry\GenericRetryStrategy; -use Api\Testing\MockClient; +namespace Jschaedl\ApiClient; + +use Jschaedl\ApiClient\Clock\MockClock; +use Jschaedl\ApiClient\Exception\ResponseException; +use Jschaedl\ApiClient\Exception\ServerException; +use Jschaedl\ApiClient\Exception\TransportException; +use Jschaedl\ApiClient\Request\Method; +use Jschaedl\ApiClient\Request\Request; +use Jschaedl\ApiClient\Response\Response; +use Jschaedl\ApiClient\Retry\GenericRetryStrategy; +use Jschaedl\ApiClient\Testing\MockClient; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\UsesClass; diff --git a/src/Api/Testing/MockClient.php b/src/Testing/MockClient.php similarity index 87% rename from src/Api/Testing/MockClient.php rename to src/Testing/MockClient.php index ff26624..49fba25 100644 --- a/src/Api/Testing/MockClient.php +++ b/src/Testing/MockClient.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Api\Testing; - -use Api\ClientInterface; -use Api\Exception\ResponseException; -use Api\Request\RequestInterface; -use Api\Response\Decoder\JsonResponseBodyDecoder; -use Api\Response\Response; -use Api\Response\ResponseInterface; +namespace Jschaedl\ApiClient\Testing; + +use Jschaedl\ApiClient\ClientInterface; +use Jschaedl\ApiClient\Exception\ResponseException; +use Jschaedl\ApiClient\Request\RequestInterface; +use Jschaedl\ApiClient\Response\Decoder\JsonResponseBodyDecoder; +use Jschaedl\ApiClient\Response\Response; +use Jschaedl\ApiClient\Response\ResponseInterface; /** * A ClientInterface for testing code that uses an API client: answers each request with the diff --git a/src/Api/Testing/MockClientTest.php b/src/Testing/MockClientTest.php similarity index 81% rename from src/Api/Testing/MockClientTest.php rename to src/Testing/MockClientTest.php index af4dbb7..47234c9 100644 --- a/src/Api/Testing/MockClientTest.php +++ b/src/Testing/MockClientTest.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace Api\Testing; +namespace Jschaedl\ApiClient\Testing; -use Api\Exception\ClientException; -use Api\Exception\RequestDescription; -use Api\Exception\ResponseException; -use Api\Request\Method; -use Api\Request\Request; -use Api\Request\RequestInterface; -use Api\Response\Decoder\JsonResponseBodyDecoder; -use Api\Response\Response; +use Jschaedl\ApiClient\Exception\ClientException; +use Jschaedl\ApiClient\Exception\RequestDescription; +use Jschaedl\ApiClient\Exception\ResponseException; +use Jschaedl\ApiClient\Request\Method; +use Jschaedl\ApiClient\Request\Request; +use Jschaedl\ApiClient\Request\RequestInterface; +use Jschaedl\ApiClient\Response\Decoder\JsonResponseBodyDecoder; +use Jschaedl\ApiClient\Response\Response; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\UsesClass;