From 0ac41e503cd6328d12d4d1e85d3824c3113655f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=B6r=C3=9F?= Date: Wed, 18 Sep 2024 12:53:10 +0200 Subject: [PATCH 01/13] feat: improve system --- src/Dtos/OnOfficeRequest.php | 31 +++ src/Dtos/OnOfficeResponse.php | 24 ++ src/Dtos/OnOfficeResponsePage.php | 69 +++++ src/Exceptions/StrayRequestException.php | 21 ++ src/Facades/ActivityRepository.php | 19 +- src/Facades/AddressRepository.php | 19 +- src/Facades/BaseRepository.php | 98 +++++++ src/Facades/EstateRepository.php | 19 +- src/Facades/FieldRepository.php | 19 +- src/Facades/FileRepository.php | 21 +- src/Facades/MarketplaceRepository.php | 19 +- src/Facades/RelationRepository.php | 19 +- src/Facades/SearchCriteriaRepository.php | 19 +- src/Facades/SettingRepository.php | 19 +- .../Testing/ActivityRepositoryFake.php | 20 -- src/Facades/Testing/AddressRepositoryFake.php | 20 -- src/Facades/Testing/EstateRepositoryFake.php | 29 --- src/Facades/Testing/FakeResponses.php | 17 -- src/Facades/Testing/FieldRepositoryFake.php | 20 -- src/Facades/Testing/FileRepositoryFake.php | 20 -- .../Testing/MarketplaceRepositoryFake.php | 20 -- .../Testing/RelationRepositoryFake.php | 20 -- .../Testing/SearchCriteriaRepositoryFake.php | 20 -- src/Facades/Testing/SettingRepositoryFake.php | 47 ---- src/Query/ActionBuilder.php | 29 +-- src/Query/ActivityBuilder.php | 108 ++++---- src/Query/AddressBuilder.php | 161 ++++++------ src/Query/Builder.php | 185 +++++++++++-- src/Query/Concerns/BuilderInterface.php | 20 ++ src/Query/EstateBuilder.php | 67 +++-- src/Query/EstateFileBuilder.php | 90 ++++--- src/Query/FieldBuilder.php | 56 ++-- src/Query/ImprintBuilder.php | 30 +-- src/Query/MarketplaceBuilder.php | 13 +- src/Query/RegionBuilder.php | 52 ++-- src/Query/RelationBuilder.php | 44 ++-- src/Query/SearchCriteriaBuilder.php | 13 +- src/Query/Testing/ActionBuilderFake.php | 7 - src/Query/Testing/ActivityBuilderFake.php | 51 ---- src/Query/Testing/AddressBuilderFake.php | 49 ---- src/Query/Testing/BaseFake.php | 101 -------- src/Query/Testing/EstateBuilderFake.php | 18 -- src/Query/Testing/EstateFileBuilderFake.php | 20 -- src/Query/Testing/FieldBuilderFake.php | 26 -- src/Query/Testing/ImprintBuilderFake.php | 7 - src/Query/Testing/MarketplaceBuilderFake.php | 22 -- src/Query/Testing/RegionBuilderFake.php | 7 - src/Query/Testing/RelationBuilderFake.php | 21 -- .../Testing/SearchCriteriaBuilderFake.php | 7 - src/Query/Testing/UploadBuilderFake.php | 52 ---- src/Query/Testing/UserBuilderFake.php | 7 - src/Query/UploadBuilder.php | 22 +- src/Query/UserBuilder.php | 82 +++--- src/Repositories/ActivityRepository.php | 14 +- src/Repositories/AddressRepository.php | 14 +- src/Repositories/BaseRepository.php | 243 ++++++++++++++++++ src/Repositories/EstateRepository.php | 17 +- src/Repositories/FieldRepository.php | 14 +- src/Repositories/FileRepository.php | 18 +- src/Repositories/MarketplaceRepository.php | 14 +- src/Repositories/RelationRepository.php | 14 +- src/Repositories/SearchCriteriaRepository.php | 14 +- src/Repositories/SettingRepository.php | 20 +- src/Services/OnOfficeService.php | 30 ++- tests/Dtos/OnOfficeResponsePageTest.php | 69 +++++ tests/Dtos/OnOfficeResponseTest.php | 27 ++ tests/Query/AcitvityBuilderTest.php | 26 -- tests/Query/AddressBuilderTest.php | 60 +---- tests/Query/BuilderTest.php | 28 +- tests/Query/EstateBuilderTest.php | 27 -- tests/Query/EstateFileBuilderTest.php | 25 -- tests/Query/FieldBuilderTest.php | 29 +-- tests/Query/ImprintBuilderTest.php | 22 -- tests/Query/MarketplaceBuilderTest.php | 19 -- tests/Query/RegionBuilderTest.php | 22 -- tests/Query/RelationBuilderTest.php | 57 ++-- tests/Query/UploadBuilderTest.php | 13 +- tests/Query/UserBuilderTest.php | 27 -- tests/Repositories/ActivityRepositoryTest.php | 49 ++++ tests/Repositories/AddressRepositoryTest.php | 48 ++++ tests/Repositories/BaseRepositoryTest.php | 202 +++++++++++++++ .../Repositories/EstateFileRepositoryTest.php | 53 ++++ tests/Repositories/EstateRepositoryTest.php | 51 ++++ tests/Repositories/FieldRepositoryTest.php | 52 ++++ tests/Repositories/ImprintRepositoryTest.php | 55 ++++ .../MarketplaceRepositoryTest.php | 46 ++++ tests/Repositories/RegionRepositoryTest.php | 57 ++++ tests/Repositories/RelationRepositoryTest.php | 61 +++++ .../SearchCriteriaRepositoryTest.php | 54 ++++ tests/Repositories/UploadRepositoryTest.php | 57 ++++ tests/Repositories/UserRepositoryTest.php | 57 ++++ tests/Services/OnOfficeServiceTest.php | 10 +- tests/Stubs/GetSearchCriteriaResponse.php | 51 ++++ tests/Testing/AddressRepositoryFakeTest.php | 57 ---- tests/Testing/EstateRepositoryFakeTest.php | 212 --------------- tests/Testing/FileRepositoryFakeTest.php | 113 -------- .../Testing/MarketplaceRepositoryFakeTest.php | 39 --- 97 files changed, 2247 insertions(+), 1956 deletions(-) create mode 100644 src/Dtos/OnOfficeRequest.php create mode 100644 src/Dtos/OnOfficeResponse.php create mode 100644 src/Dtos/OnOfficeResponsePage.php create mode 100644 src/Exceptions/StrayRequestException.php create mode 100644 src/Facades/BaseRepository.php delete mode 100644 src/Facades/Testing/ActivityRepositoryFake.php delete mode 100644 src/Facades/Testing/AddressRepositoryFake.php delete mode 100644 src/Facades/Testing/EstateRepositoryFake.php delete mode 100644 src/Facades/Testing/FakeResponses.php delete mode 100644 src/Facades/Testing/FieldRepositoryFake.php delete mode 100644 src/Facades/Testing/FileRepositoryFake.php delete mode 100644 src/Facades/Testing/MarketplaceRepositoryFake.php delete mode 100644 src/Facades/Testing/RelationRepositoryFake.php delete mode 100644 src/Facades/Testing/SearchCriteriaRepositoryFake.php delete mode 100644 src/Facades/Testing/SettingRepositoryFake.php create mode 100644 src/Query/Concerns/BuilderInterface.php delete mode 100644 src/Query/Testing/ActionBuilderFake.php delete mode 100644 src/Query/Testing/ActivityBuilderFake.php delete mode 100644 src/Query/Testing/AddressBuilderFake.php delete mode 100644 src/Query/Testing/BaseFake.php delete mode 100644 src/Query/Testing/EstateBuilderFake.php delete mode 100644 src/Query/Testing/EstateFileBuilderFake.php delete mode 100644 src/Query/Testing/FieldBuilderFake.php delete mode 100644 src/Query/Testing/ImprintBuilderFake.php delete mode 100644 src/Query/Testing/MarketplaceBuilderFake.php delete mode 100644 src/Query/Testing/RegionBuilderFake.php delete mode 100644 src/Query/Testing/RelationBuilderFake.php delete mode 100644 src/Query/Testing/SearchCriteriaBuilderFake.php delete mode 100644 src/Query/Testing/UploadBuilderFake.php delete mode 100644 src/Query/Testing/UserBuilderFake.php create mode 100644 src/Repositories/BaseRepository.php create mode 100644 tests/Dtos/OnOfficeResponsePageTest.php create mode 100644 tests/Dtos/OnOfficeResponseTest.php delete mode 100644 tests/Query/AcitvityBuilderTest.php delete mode 100644 tests/Query/EstateBuilderTest.php delete mode 100644 tests/Query/EstateFileBuilderTest.php delete mode 100644 tests/Query/ImprintBuilderTest.php delete mode 100644 tests/Query/MarketplaceBuilderTest.php delete mode 100644 tests/Query/RegionBuilderTest.php delete mode 100644 tests/Query/UserBuilderTest.php create mode 100644 tests/Repositories/ActivityRepositoryTest.php create mode 100644 tests/Repositories/AddressRepositoryTest.php create mode 100644 tests/Repositories/BaseRepositoryTest.php create mode 100644 tests/Repositories/EstateFileRepositoryTest.php create mode 100644 tests/Repositories/EstateRepositoryTest.php create mode 100644 tests/Repositories/FieldRepositoryTest.php create mode 100644 tests/Repositories/ImprintRepositoryTest.php create mode 100644 tests/Repositories/MarketplaceRepositoryTest.php create mode 100644 tests/Repositories/RegionRepositoryTest.php create mode 100644 tests/Repositories/RelationRepositoryTest.php create mode 100644 tests/Repositories/SearchCriteriaRepositoryTest.php create mode 100644 tests/Repositories/UploadRepositoryTest.php create mode 100644 tests/Repositories/UserRepositoryTest.php create mode 100644 tests/Stubs/GetSearchCriteriaResponse.php delete mode 100644 tests/Testing/AddressRepositoryFakeTest.php delete mode 100644 tests/Testing/EstateRepositoryFakeTest.php delete mode 100644 tests/Testing/FileRepositoryFakeTest.php delete mode 100644 tests/Testing/MarketplaceRepositoryFakeTest.php diff --git a/src/Dtos/OnOfficeRequest.php b/src/Dtos/OnOfficeRequest.php new file mode 100644 index 0000000..60940c5 --- /dev/null +++ b/src/Dtos/OnOfficeRequest.php @@ -0,0 +1,31 @@ + $this->actionId->value, + 'resourceType' => $this->resourceType->value, + 'resourceId' => $this->resourceId, + 'identifier' => $this->identifier, + 'parameters' => $this->parameters, + ]; + } +} diff --git a/src/Dtos/OnOfficeResponse.php b/src/Dtos/OnOfficeResponse.php new file mode 100644 index 0000000..987c7f3 --- /dev/null +++ b/src/Dtos/OnOfficeResponse.php @@ -0,0 +1,24 @@ +pages->shift(); + } + + public function isEmpty(): bool + { + return $this->pages->isEmpty(); + } +} diff --git a/src/Dtos/OnOfficeResponsePage.php b/src/Dtos/OnOfficeResponsePage.php new file mode 100644 index 0000000..0a561df --- /dev/null +++ b/src/Dtos/OnOfficeResponsePage.php @@ -0,0 +1,69 @@ +recordFactories + ->map(fn (BaseFactory $recordFactory) => $recordFactory->toArray()) + ->all(); + + return [ + 'status' => [ + 'code' => $this->status, + 'errorcode' => $this->errorCode, + 'message' => $this->message, + ], + 'response' => [ + 'results' => [ + [ + 'actionid' => $this->actionId->value, + 'resourceid' => (string) ($this->resourceId instanceof OnOfficeResourceId + ? $this->resourceId->value + : $this->resourceId), + 'resourcetype' => (string) ($this->resourceType instanceof OnOfficeResourceType + ? $this->resourceType->value + : $this->resourceType), + 'cacheable' => $this->cacheable, + 'identifier' => $this->identifier, + 'data' => [ + 'meta' => [ + 'cntabsolute' => $this->countAbsolute === -1 ? count($records) : $this->countAbsolute, + ], + 'records' => $records, + ], + 'status' => [ + 'errorcode' => $this->errorCodeResult, + 'message' => $this->messageResult, + ], + ], + ], + ], + ]; + } +} diff --git a/src/Exceptions/StrayRequestException.php b/src/Exceptions/StrayRequestException.php new file mode 100644 index 0000000..cbc8c6a --- /dev/null +++ b/src/Exceptions/StrayRequestException.php @@ -0,0 +1,21 @@ +request = $request; + } +} diff --git a/src/Facades/ActivityRepository.php b/src/Facades/ActivityRepository.php index f9bf7b5..cc035e4 100644 --- a/src/Facades/ActivityRepository.php +++ b/src/Facades/ActivityRepository.php @@ -4,26 +4,27 @@ namespace Katalam\OnOfficeAdapter\Facades; -use Illuminate\Support\Facades\Facade; -use Katalam\OnOfficeAdapter\Facades\Testing\ActivityRepositoryFake; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; +use Katalam\OnOfficeAdapter\Repositories\ActivityRepository as RootRepository; use Katalam\OnOfficeAdapter\Query\ActivityBuilder; /** - * @see \Katalam\OnOfficeAdapter\Repositories\ActivityRepository + * @see RootRepository * * @method static ActivityBuilder query() */ -class ActivityRepository extends Facade +class ActivityRepository extends BaseRepository { - public static function fake(array ...$fakeResponses): ActivityRepositoryFake + public static function fake(OnOfficeResponsePage|OnOfficeResponse|array|null $stubCallables): RootRepository { - static::swap($fake = new ActivityRepositoryFake(...$fakeResponses)); - - return $fake; + return tap(static::getFacadeRoot(), static function (RootRepository $fake) use ($stubCallables) { + $fake->fake($stubCallables); + }); } protected static function getFacadeAccessor(): string { - return \Katalam\OnOfficeAdapter\Repositories\ActivityRepository::class; + return RootRepository::class; } } diff --git a/src/Facades/AddressRepository.php b/src/Facades/AddressRepository.php index 05dfe53..cc32a4c 100644 --- a/src/Facades/AddressRepository.php +++ b/src/Facades/AddressRepository.php @@ -4,26 +4,27 @@ namespace Katalam\OnOfficeAdapter\Facades; -use Illuminate\Support\Facades\Facade; -use Katalam\OnOfficeAdapter\Facades\Testing\AddressRepositoryFake; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; use Katalam\OnOfficeAdapter\Query\AddressBuilder; +use Katalam\OnOfficeAdapter\Repositories\AddressRepository as RootRepository; /** - * @see \Katalam\OnOfficeAdapter\Repositories\AddressRepository + * @see RootRepository * * @method static AddressBuilder query() */ -class AddressRepository extends Facade +class AddressRepository extends BaseRepository { - public static function fake(array ...$fakeResponses): AddressRepositoryFake + public static function fake(OnOfficeResponsePage|OnOfficeResponse|array|null $stubCallables): RootRepository { - static::swap($fake = new AddressRepositoryFake(...$fakeResponses)); - - return $fake; + return tap(static::getFacadeRoot(), static function (RootRepository $fake) use ($stubCallables) { + $fake->fake($stubCallables); + }); } protected static function getFacadeAccessor(): string { - return \Katalam\OnOfficeAdapter\Repositories\AddressRepository::class; + return RootRepository::class; } } diff --git a/src/Facades/BaseRepository.php b/src/Facades/BaseRepository.php new file mode 100644 index 0000000..d73af2e --- /dev/null +++ b/src/Facades/BaseRepository.php @@ -0,0 +1,98 @@ +fake($stubCallables); + }); + } + + protected static function getFacadeAccessor(): string + { + return RootRepository::class; + } + + public static function response(array $pages = []): OnOfficeResponse + { + return static::getFacadeRoot()->response($pages); + } + + public static function page( + OnOfficeAction $actionId = OnOfficeAction::Read, + OnOfficeResourceType|string $resourceType = OnOfficeResourceType::Estate, + array $recordFactories = [], + int $status = 200, + int $errorCode = 0, + string $message = 'OK', + OnOfficeResourceId|string|int $resourceId = OnOfficeResourceId::None, + bool $cacheable = true, + string|int $identifier = '', + int $countAbsolute = 0, + int $errorCodeResult = 0, + string $messageResult = 'OK', + ): OnOfficeResponsePage { + return static::getFacadeRoot()->page( + $actionId, + $resourceType, + $recordFactories, + $status, + $errorCode, + $message, + $resourceId, + $cacheable, + $identifier, + $countAbsolute, + $errorCodeResult, + $messageResult, + ); + } + + public static function preventStrayRequests(bool $value = true): RootRepository + { + return static::getFacadeRoot()->preventStrayRequests($value); + } + + public static function record(bool $recording = true): RootRepository + { + return static::getFacadeRoot()->record($recording); + } + + public static function stopRecording(): RootRepository + { + return static::getFacadeRoot()->stopRecording(); + } + + public static function assertSent(?callable $callback = null): void + { + static::getFacadeRoot()->assertSent($callback); + } + + public static function assertNotSent(?callable $callback = null): void + { + static::getFacadeRoot()->assertNotSent($callback); + } + + public static function assertSentCount(int $count): void + { + static::getFacadeRoot()->assertSentCount($count); + } +} diff --git a/src/Facades/EstateRepository.php b/src/Facades/EstateRepository.php index 7a62bf5..0e63a07 100644 --- a/src/Facades/EstateRepository.php +++ b/src/Facades/EstateRepository.php @@ -4,28 +4,29 @@ namespace Katalam\OnOfficeAdapter\Facades; -use Illuminate\Support\Facades\Facade; -use Katalam\OnOfficeAdapter\Facades\Testing\EstateRepositoryFake; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; use Katalam\OnOfficeAdapter\Query\EstateBuilder; use Katalam\OnOfficeAdapter\Query\EstateFileBuilder; +use Katalam\OnOfficeAdapter\Repositories\EstateRepository as RootRepository; /** - * @see \Katalam\OnOfficeAdapter\Repositories\EstateRepository + * @see RootRepository * * @method static EstateBuilder query() * @method static EstateFileBuilder files(int $estateId) */ -class EstateRepository extends Facade +class EstateRepository extends BaseRepository { - public static function fake(array ...$fakeResponses): EstateRepositoryFake + public static function fake(OnOfficeResponsePage|OnOfficeResponse|array|null $stubCallables): RootRepository { - static::swap($fake = new EstateRepositoryFake(...$fakeResponses)); - - return $fake; + return tap(static::getFacadeRoot(), static function (RootRepository $fake) use ($stubCallables) { + $fake->fake($stubCallables); + }); } protected static function getFacadeAccessor(): string { - return \Katalam\OnOfficeAdapter\Repositories\EstateRepository::class; + return RootRepository::class; } } diff --git a/src/Facades/FieldRepository.php b/src/Facades/FieldRepository.php index d13d9a3..bfa6808 100644 --- a/src/Facades/FieldRepository.php +++ b/src/Facades/FieldRepository.php @@ -4,26 +4,27 @@ namespace Katalam\OnOfficeAdapter\Facades; -use Illuminate\Support\Facades\Facade; -use Katalam\OnOfficeAdapter\Facades\Testing\FieldRepositoryFake; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; use Katalam\OnOfficeAdapter\Query\FieldBuilder; +use Katalam\OnOfficeAdapter\Repositories\FieldRepository as RootRepository; /** - * @see \Katalam\OnOfficeAdapter\Repositories\FieldRepository + * @see RootRepository * * @method static FieldBuilder query() */ -class FieldRepository extends Facade +class FieldRepository extends BaseRepository { - public static function fake(array ...$fakeResponses): FieldRepositoryFake + public static function fake(OnOfficeResponsePage|OnOfficeResponse|array|null $stubCallables): RootRepository { - static::swap($fake = new FieldRepositoryFake(...$fakeResponses)); - - return $fake; + return tap(static::getFacadeRoot(), static function (RootRepository $fake) use ($stubCallables) { + $fake->fake($stubCallables); + }); } protected static function getFacadeAccessor(): string { - return \Katalam\OnOfficeAdapter\Repositories\FieldRepository::class; + return RootRepository::class; } } diff --git a/src/Facades/FileRepository.php b/src/Facades/FileRepository.php index ff4f0b0..d0cc475 100644 --- a/src/Facades/FileRepository.php +++ b/src/Facades/FileRepository.php @@ -4,26 +4,27 @@ namespace Katalam\OnOfficeAdapter\Facades; -use Illuminate\Support\Facades\Facade; -use Katalam\OnOfficeAdapter\Facades\Testing\FileRepositoryFake; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; use Katalam\OnOfficeAdapter\Query\UploadBuilder; +use Katalam\OnOfficeAdapter\Repositories\FileRepository as RootRepository; /** - * @see \Katalam\OnOfficeAdapter\Repositories\SettingRepository + * @see RootRepository * - * @method static UploadBuilder upload() + * @method static UploadBuilder query() */ -class FileRepository extends Facade +class FileRepository extends BaseRepository { - public static function fake(array ...$fakeResponses): FileRepositoryFake + public static function fake(OnOfficeResponsePage|OnOfficeResponse|array|null $stubCallables): RootRepository { - static::swap($fake = new FileRepositoryFake(...$fakeResponses)); - - return $fake; + return tap(static::getFacadeRoot(), static function (RootRepository $fake) use ($stubCallables) { + $fake->fake($stubCallables); + }); } protected static function getFacadeAccessor(): string { - return \Katalam\OnOfficeAdapter\Repositories\FileRepository::class; + return RootRepository::class; } } diff --git a/src/Facades/MarketplaceRepository.php b/src/Facades/MarketplaceRepository.php index e9d145f..63f828a 100644 --- a/src/Facades/MarketplaceRepository.php +++ b/src/Facades/MarketplaceRepository.php @@ -4,26 +4,27 @@ namespace Katalam\OnOfficeAdapter\Facades; -use Illuminate\Support\Facades\Facade; -use Katalam\OnOfficeAdapter\Facades\Testing\MarketplaceRepositoryFake; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; use Katalam\OnOfficeAdapter\Query\MarketplaceBuilder; +use Katalam\OnOfficeAdapter\Repositories\MarketplaceRepository as RootRepository; /** - * @see \Katalam\OnOfficeAdapter\Repositories\MarketplaceRepository + * @see RootRepository * * @method static MarketplaceBuilder query() */ -class MarketplaceRepository extends Facade +class MarketplaceRepository extends BaseRepository { - public static function fake(array ...$fakeResponses): MarketplaceRepositoryFake + public static function fake(OnOfficeResponsePage|OnOfficeResponse|array|null $stubCallables): RootRepository { - static::swap($fake = new MarketplaceRepositoryFake(...$fakeResponses)); - - return $fake; + return tap(static::getFacadeRoot(), static function (RootRepository $fake) use ($stubCallables) { + $fake->fake($stubCallables); + }); } protected static function getFacadeAccessor(): string { - return \Katalam\OnOfficeAdapter\Repositories\MarketplaceRepository::class; + return RootRepository::class; } } diff --git a/src/Facades/RelationRepository.php b/src/Facades/RelationRepository.php index 272ed8b..1ffbb04 100644 --- a/src/Facades/RelationRepository.php +++ b/src/Facades/RelationRepository.php @@ -4,26 +4,27 @@ namespace Katalam\OnOfficeAdapter\Facades; -use Illuminate\Support\Facades\Facade; -use Katalam\OnOfficeAdapter\Facades\Testing\RelationRepositoryFake; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; use Katalam\OnOfficeAdapter\Query\RelationBuilder; +use Katalam\OnOfficeAdapter\Repositories\RelationRepository as RootRepository; /** - * @see \Katalam\OnOfficeAdapter\Repositories\RelationRepository + * @see RootRepository * * @method static RelationBuilder query() */ -class RelationRepository extends Facade +class RelationRepository extends BaseRepository { - public static function fake(array ...$fakeResponses): RelationRepositoryFake + public static function fake(OnOfficeResponsePage|OnOfficeResponse|array|null $stubCallables): RootRepository { - static::swap($fake = new RelationRepositoryFake(...$fakeResponses)); - - return $fake; + return tap(static::getFacadeRoot(), static function (RootRepository $fake) use ($stubCallables) { + $fake->fake($stubCallables); + }); } protected static function getFacadeAccessor(): string { - return \Katalam\OnOfficeAdapter\Repositories\RelationRepository::class; + return RootRepository::class; } } diff --git a/src/Facades/SearchCriteriaRepository.php b/src/Facades/SearchCriteriaRepository.php index 90b0251..0dffdef 100644 --- a/src/Facades/SearchCriteriaRepository.php +++ b/src/Facades/SearchCriteriaRepository.php @@ -4,26 +4,27 @@ namespace Katalam\OnOfficeAdapter\Facades; -use Illuminate\Support\Facades\Facade; -use Katalam\OnOfficeAdapter\Facades\Testing\SearchCriteriaRepositoryFake; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; use Katalam\OnOfficeAdapter\Query\SearchCriteriaBuilder; +use Katalam\OnOfficeAdapter\Repositories\SearchCriteriaRepository as RootRepository; /** - * @see \Katalam\OnOfficeAdapter\Repositories\SearchCriteriaRepository + * @see RootRepository * * @method static SearchCriteriaBuilder query() */ -class SearchCriteriaRepository extends Facade +class SearchCriteriaRepository extends BaseRepository { - public static function fake(array ...$fakeResponses): SearchCriteriaRepositoryFake + public static function fake(OnOfficeResponsePage|OnOfficeResponse|array|null $stubCallables): RootRepository { - static::swap($fake = new SearchCriteriaRepositoryFake(...$fakeResponses)); - - return $fake; + return tap(static::getFacadeRoot(), static function (RootRepository $fake) use ($stubCallables) { + $fake->fake($stubCallables); + }); } protected static function getFacadeAccessor(): string { - return \Katalam\OnOfficeAdapter\Repositories\SearchCriteriaRepository::class; + return RootRepository::class; } } diff --git a/src/Facades/SettingRepository.php b/src/Facades/SettingRepository.php index 4c1476e..8799e03 100644 --- a/src/Facades/SettingRepository.php +++ b/src/Facades/SettingRepository.php @@ -4,32 +4,33 @@ namespace Katalam\OnOfficeAdapter\Facades; -use Illuminate\Support\Facades\Facade; -use Katalam\OnOfficeAdapter\Facades\Testing\SettingRepositoryFake; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; use Katalam\OnOfficeAdapter\Query\ActionBuilder; use Katalam\OnOfficeAdapter\Query\ImprintBuilder; use Katalam\OnOfficeAdapter\Query\RegionBuilder; use Katalam\OnOfficeAdapter\Query\UserBuilder; +use Katalam\OnOfficeAdapter\Repositories\SettingRepository as RootRepository; /** - * @see \Katalam\OnOfficeAdapter\Repositories\SettingRepository + * @see RootRepository * * @method static UserBuilder users() * @method static RegionBuilder regions() * @method static ImprintBuilder imprint() * @method static ActionBuilder actions() */ -class SettingRepository extends Facade +class SettingRepository extends BaseRepository { - public static function fake(array ...$fakeResponses): SettingRepositoryFake + public static function fake(OnOfficeResponsePage|OnOfficeResponse|array|null $stubCallables): RootRepository { - static::swap($fake = new SettingRepositoryFake(...$fakeResponses)); - - return $fake; + return tap(static::getFacadeRoot(), static function (RootRepository $fake) use ($stubCallables) { + $fake->fake($stubCallables); + }); } protected static function getFacadeAccessor(): string { - return \Katalam\OnOfficeAdapter\Repositories\SettingRepository::class; + return RootRepository::class; } } diff --git a/src/Facades/Testing/ActivityRepositoryFake.php b/src/Facades/Testing/ActivityRepositoryFake.php deleted file mode 100644 index a398386..0000000 --- a/src/Facades/Testing/ActivityRepositoryFake.php +++ /dev/null @@ -1,20 +0,0 @@ -fakeResponses); - } -} diff --git a/src/Facades/Testing/AddressRepositoryFake.php b/src/Facades/Testing/AddressRepositoryFake.php deleted file mode 100644 index 43f12c2..0000000 --- a/src/Facades/Testing/AddressRepositoryFake.php +++ /dev/null @@ -1,20 +0,0 @@ -fakeResponses); - } -} diff --git a/src/Facades/Testing/EstateRepositoryFake.php b/src/Facades/Testing/EstateRepositoryFake.php deleted file mode 100644 index 9763c2b..0000000 --- a/src/Facades/Testing/EstateRepositoryFake.php +++ /dev/null @@ -1,29 +0,0 @@ -fakeResponses); - } - - /** - * Returns a new fake estate files builder instance. - */ - public function files(): EstateFileBuilderFake - { - return new EstateFileBuilderFake($this->fakeResponses); - } -} diff --git a/src/Facades/Testing/FakeResponses.php b/src/Facades/Testing/FakeResponses.php deleted file mode 100644 index ded2b5e..0000000 --- a/src/Facades/Testing/FakeResponses.php +++ /dev/null @@ -1,17 +0,0 @@ -fakeResponses = collect($fakeResponses); - } -} diff --git a/src/Facades/Testing/FieldRepositoryFake.php b/src/Facades/Testing/FieldRepositoryFake.php deleted file mode 100644 index 4809d17..0000000 --- a/src/Facades/Testing/FieldRepositoryFake.php +++ /dev/null @@ -1,20 +0,0 @@ -fakeResponses); - } -} diff --git a/src/Facades/Testing/FileRepositoryFake.php b/src/Facades/Testing/FileRepositoryFake.php deleted file mode 100644 index da6428f..0000000 --- a/src/Facades/Testing/FileRepositoryFake.php +++ /dev/null @@ -1,20 +0,0 @@ -fakeResponses); - } -} diff --git a/src/Facades/Testing/MarketplaceRepositoryFake.php b/src/Facades/Testing/MarketplaceRepositoryFake.php deleted file mode 100644 index 3510fb2..0000000 --- a/src/Facades/Testing/MarketplaceRepositoryFake.php +++ /dev/null @@ -1,20 +0,0 @@ -fakeResponses); - } -} diff --git a/src/Facades/Testing/RelationRepositoryFake.php b/src/Facades/Testing/RelationRepositoryFake.php deleted file mode 100644 index ef0f386..0000000 --- a/src/Facades/Testing/RelationRepositoryFake.php +++ /dev/null @@ -1,20 +0,0 @@ -fakeResponses); - } -} diff --git a/src/Facades/Testing/SearchCriteriaRepositoryFake.php b/src/Facades/Testing/SearchCriteriaRepositoryFake.php deleted file mode 100644 index 42697e0..0000000 --- a/src/Facades/Testing/SearchCriteriaRepositoryFake.php +++ /dev/null @@ -1,20 +0,0 @@ -fakeResponses); - } -} diff --git a/src/Facades/Testing/SettingRepositoryFake.php b/src/Facades/Testing/SettingRepositoryFake.php deleted file mode 100644 index 66439f1..0000000 --- a/src/Facades/Testing/SettingRepositoryFake.php +++ /dev/null @@ -1,47 +0,0 @@ -fakeResponses); - } - - /** - * Returns a new fake region builder instance. - */ - public function regions(): RegionBuilderFake - { - return new RegionBuilderFake($this->fakeResponses); - } - - /** - * Returns a new fake imprint builder instance. - */ - public function imprint(): ImprintBuilderFake - { - return new ImprintBuilderFake($this->fakeResponses); - } - - /** - * Returns a new fake actions builder instance. - */ - public function actions(): ActionBuilderFake - { - return new ActionBuilderFake($this->fakeResponses); - } -} diff --git a/src/Query/ActionBuilder.php b/src/Query/ActionBuilder.php index c832a87..2d221f3 100644 --- a/src/Query/ActionBuilder.php +++ b/src/Query/ActionBuilder.php @@ -5,12 +5,12 @@ namespace Katalam\OnOfficeAdapter\Query; use Illuminate\Support\Collection; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; use Katalam\OnOfficeAdapter\Query\Concerns\NonFilterable; use Katalam\OnOfficeAdapter\Query\Concerns\NonOrderable; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; class ActionBuilder extends Builder { @@ -18,23 +18,20 @@ class ActionBuilder extends Builder use NonFilterable; use NonOrderable; - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - + /** + * @throws OnOfficeException + */ public function get(): Collection { - return $this->onOfficeService->requestAll(/** - * @throws OnOfficeException - */ function () { - return $this->onOfficeService->requestApi( - OnOfficeAction::Get, - OnOfficeResourceType::ActionTypes, - parameters: [ - ...$this->customParameters, - ] - ); - }, pageSize: $this->limit, offset: $this->offset, take: $this->take); + $request = new OnOfficeRequest( + OnOfficeAction::Get, + OnOfficeResourceType::ActionTypes, + parameters: [ + ...$this->customParameters, + ] + ); + + return $this->requestAll($request); } /** diff --git a/src/Query/ActivityBuilder.php b/src/Query/ActivityBuilder.php index f536aaf..7e225ce 100644 --- a/src/Query/ActivityBuilder.php +++ b/src/Query/ActivityBuilder.php @@ -5,11 +5,13 @@ namespace Katalam\OnOfficeAdapter\Query; use Illuminate\Support\Collection; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; use Katalam\OnOfficeAdapter\Query\Concerns\RecordIds; use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Throwable; class ActivityBuilder extends Builder { @@ -17,71 +19,62 @@ class ActivityBuilder extends Builder public string $estateOrAddress = 'estate'; - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - + /** + * @throws OnOfficeException + */ public function get(): Collection { $orderBy = $this->getOrderBy(); - $sortBy = data_get(array_keys($orderBy), 0); - $sortOrder = data_get($orderBy, 0); + $request = new OnOfficeRequest( + OnOfficeAction::Read, + OnOfficeResourceType::Activity, + parameters: [ + $this->estateOrAddress => $this->recordIds, + OnOfficeService::DATA => $this->columns, + OnOfficeService::FILTER => $this->getFilters(), + OnOfficeService::SORTBY => data_get(array_keys($orderBy), 0), + OnOfficeService::SORTORDER => data_get($orderBy, 0), + ...$this->customParameters, + ] + ); - return $this->onOfficeService->requestAll(/** - * @throws OnOfficeException - */ function (int $pageSize, int $offset) use ($sortOrder, $sortBy) { - return $this->onOfficeService->requestApi( - OnOfficeAction::Read, - OnOfficeResourceType::Activity, - parameters: [ - $this->estateOrAddress => $this->recordIds, - OnOfficeService::DATA => $this->columns, - OnOfficeService::FILTER => $this->getFilters(), - OnOfficeService::LISTLIMIT => $pageSize, - OnOfficeService::LISTOFFSET => $offset, - OnOfficeService::SORTBY => $sortBy, - OnOfficeService::SORTORDER => $sortOrder, - ...$this->customParameters, - ] - ); - }, pageSize: $this->limit, offset: $this->offset, take: $this->take); + return $this->requestAll($request); } /** - * @throws OnOfficeException + * @throws Throwable */ public function first(): ?array { $orderBy = $this->getOrderBy(); - $sortBy = data_get(array_keys($orderBy), 0); - $sortOrder = data_get($orderBy, 0); - - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Read, OnOfficeResourceType::Activity, parameters: [ $this->estateOrAddress => $this->recordIds, OnOfficeService::DATA => $this->columns, OnOfficeService::FILTER => $this->getFilters(), - OnOfficeService::LISTLIMIT => $this->limit, + OnOfficeService::LISTLIMIT => $this->limit > 0 ? $this->limit : $this->pageSize, OnOfficeService::LISTOFFSET => $this->offset, - OnOfficeService::SORTBY => $sortBy, - OnOfficeService::SORTORDER => $sortOrder, + OnOfficeService::SORTBY => data_get(array_keys($orderBy), 0), + OnOfficeService::SORTORDER => data_get($orderBy, 0), ...$this->customParameters, ] ); - return $response->json('response.results.0.data.records.0'); + return $this->requestApi($request) + ->json('response.results.0.data.records.0'); + } /** - * @throws OnOfficeException + * @throws Throwable */ public function find(int $id): array { - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Get, OnOfficeResourceType::Activity, $id, @@ -91,9 +84,13 @@ public function find(int $id): array ] ); - return $response->json('response.results.0.data.records.0'); + return $this->requestApi($request) + ->json('response.results.0.data.records.0'); } + /** + * @throws OnOfficeException + */ public function each(callable $callback): void { $orderBy = $this->getOrderBy(); @@ -101,24 +98,20 @@ public function each(callable $callback): void $sortBy = data_get(array_keys($orderBy), 0); $sortOrder = data_get($orderBy, 0); - $this->onOfficeService->requestAllChunked(/** - * @throws OnOfficeException - */ function (int $pageSize, int $offset) use ($sortOrder, $sortBy) { - return $this->onOfficeService->requestApi( - OnOfficeAction::Read, - OnOfficeResourceType::Activity, - parameters: [ - $this->estateOrAddress => $this->recordIds, - OnOfficeService::DATA => $this->columns, - OnOfficeService::FILTER => $this->getFilters(), - OnOfficeService::LISTLIMIT => $pageSize, - OnOfficeService::LISTOFFSET => $offset, - OnOfficeService::SORTBY => $sortBy, - OnOfficeService::SORTORDER => $sortOrder, - ...$this->customParameters, - ] - ); - }, $callback, pageSize: $this->limit, offset: $this->offset, take: $this->take); + $request = new OnOfficeRequest( + OnOfficeAction::Read, + OnOfficeResourceType::Activity, + parameters: [ + $this->estateOrAddress => $this->recordIds, + OnOfficeService::DATA => $this->columns, + OnOfficeService::FILTER => $this->getFilters(), + OnOfficeService::SORTBY => $sortBy, + OnOfficeService::SORTORDER => $sortOrder, + ...$this->customParameters, + ], + ); + + $this->requestAllChunked($request, $callback); } /** @@ -130,7 +123,7 @@ public function modify(int $id): bool } /** - * @throws OnOfficeException + * @throws Throwable */ public function create(array $data): array { @@ -138,13 +131,14 @@ public function create(array $data): array $this->estateOrAddress => $this->recordIds, ]); - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Create, OnOfficeResourceType::Activity, parameters: $data, ); - return $response->json('response.results.0.data.records.0'); + return $this->requestApi($request) + ->json('response.results.0.data.records.0'); } public function estate(): static diff --git a/src/Query/AddressBuilder.php b/src/Query/AddressBuilder.php index f1d4d16..9b8cf40 100644 --- a/src/Query/AddressBuilder.php +++ b/src/Query/AddressBuilder.php @@ -5,6 +5,7 @@ namespace Katalam\OnOfficeAdapter\Query; use Illuminate\Support\Collection; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceId; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; @@ -12,16 +13,16 @@ use Katalam\OnOfficeAdapter\Query\Concerns\Input; use Katalam\OnOfficeAdapter\Query\Concerns\RecordIds; use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Throwable; class AddressBuilder extends Builder { use Input; use RecordIds; - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - + /** + * @throws OnOfficeException + */ public function get(): Collection { $orderBy = $this->getOrderBy(); @@ -29,60 +30,55 @@ public function get(): Collection $sortBy = data_get(array_keys($orderBy), 0); $sortOrder = data_get($orderBy, 0); - return $this->onOfficeService->requestAll(/** - * @throws OnOfficeException - */ function (int $pageSize, int $offset) use ($sortOrder, $sortBy) { - return $this->onOfficeService->requestApi( - OnOfficeAction::Read, - OnOfficeResourceType::Address, - parameters: [ - OnOfficeService::RECORDIDS => $this->recordIds, - OnOfficeService::DATA => $this->columns, - OnOfficeService::FILTER => $this->getFilters(), - OnOfficeService::LISTLIMIT => $pageSize, - OnOfficeService::LISTOFFSET => $offset, - OnOfficeService::SORTBY => $sortBy, - OnOfficeService::SORTORDER => $sortOrder, - ...$this->customParameters, - ] - ); - }, pageSize: $this->limit, offset: $this->offset, take: $this->take); + $request = new OnOfficeRequest( + OnOfficeAction::Read, + OnOfficeResourceType::Address, + parameters: [ + OnOfficeService::RECORDIDS => $this->recordIds, + OnOfficeService::DATA => $this->columns, + OnOfficeService::FILTER => $this->getFilters(), + OnOfficeService::SORTBY => $sortBy, + OnOfficeService::SORTORDER => $sortOrder, + ...$this->customParameters, + ], + ); + + return $this->requestAll($request); } /** * @throws OnOfficeException + * @throws Throwable */ public function first(): ?array { $orderBy = $this->getOrderBy(); - $sortBy = data_get(array_keys($orderBy), 0); - $sortOrder = data_get($orderBy, 0); - - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Read, OnOfficeResourceType::Address, parameters: [ OnOfficeService::RECORDIDS => $this->recordIds, OnOfficeService::DATA => $this->columns, OnOfficeService::FILTER => $this->getFilters(), - OnOfficeService::LISTLIMIT => $this->limit, + OnOfficeService::LISTLIMIT => $this->limit > 0 ? $this->limit : $this->pageSize, OnOfficeService::LISTOFFSET => $this->offset, - OnOfficeService::SORTBY => $sortBy, - OnOfficeService::SORTORDER => $sortOrder, + OnOfficeService::SORTBY => data_get(array_keys($orderBy), 0), + OnOfficeService::SORTORDER => data_get($orderBy, 0), ...$this->customParameters, ] ); - return $response->json('response.results.0.data.records.0'); + return $this->requestApi($request) + ->json('response.results.0.data.records.0'); } /** - * @throws OnOfficeException + * @throws Throwable */ public function find(int $id): array { - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Read, OnOfficeResourceType::Address, $id, @@ -92,9 +88,13 @@ public function find(int $id): array ] ); - return $response->json('response.results.0.data.records.0'); + return $this->requestApi($request) + ->json('response.results.0.data.records.0'); } + /** + * @throws OnOfficeException + */ public function each(callable $callback): void { $orderBy = $this->getOrderBy(); @@ -102,67 +102,62 @@ public function each(callable $callback): void $sortBy = data_get(array_keys($orderBy), 0); $sortOrder = data_get($orderBy, 0); - $this->onOfficeService->requestAllChunked(/** - * @throws OnOfficeException - */ function (int $pageSize, int $offset) use ($sortOrder, $sortBy) { - return $this->onOfficeService->requestApi( - OnOfficeAction::Read, - OnOfficeResourceType::Address, - parameters: [ - OnOfficeService::RECORDIDS => $this->recordIds, - OnOfficeService::DATA => $this->columns, - OnOfficeService::FILTER => $this->getFilters(), - OnOfficeService::LISTLIMIT => $pageSize, - OnOfficeService::LISTOFFSET => $offset, - OnOfficeService::SORTBY => $sortBy, - OnOfficeService::SORTORDER => $sortOrder, - ...$this->customParameters, - ] - ); - }, $callback, pageSize: $this->limit, offset: $this->offset, take: $this->take); + $request = new OnOfficeRequest( + OnOfficeAction::Read, + OnOfficeResourceType::Address, + parameters: [ + OnOfficeService::RECORDIDS => $this->recordIds, + OnOfficeService::DATA => $this->columns, + OnOfficeService::FILTER => $this->getFilters(), + OnOfficeService::SORTBY => $sortBy, + OnOfficeService::SORTORDER => $sortOrder, + ...$this->customParameters, + ], + ); + + $this->requestAllChunked($request, $callback); } /** - * @throws OnOfficeException + * @throws Throwable */ public function modify(int $id): bool { - $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Modify, OnOfficeResourceType::Address, $id, parameters: $this->modifies, ); + $this->requestApi($request); + return true; } /** - * @throws OnOfficeException + * @throws Throwable */ public function count(): int { $orderBy = $this->getOrderBy(); - $sortBy = data_get(array_keys($orderBy), 0); - $sortOrder = data_get($orderBy, 0); - - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Read, OnOfficeResourceType::Address, parameters: [ OnOfficeService::RECORDIDS => $this->recordIds, OnOfficeService::DATA => $this->columns, OnOfficeService::FILTER => $this->getFilters(), - OnOfficeService::LISTLIMIT => $this->limit, - OnOfficeService::LISTOFFSET => $this->offset, - OnOfficeService::SORTBY => $sortBy, - OnOfficeService::SORTORDER => $sortOrder, + OnOfficeService::LISTLIMIT => $this->limit > 0 ? $this->limit : $this->pageSize, + OnOfficeService::SORTBY => data_get(array_keys($orderBy), 0), + OnOfficeService::SORTORDER => data_get($orderBy, 0), ...$this->customParameters, ] ); - return $response->json('response.results.0.data.meta.cntabsolute', 0); + return $this->requestApi($request) + ->json('response.results.0.data.meta.cntabsolute', 0); } public function addCountryIsoCodeType(string $countryIsoCodeType): static @@ -173,37 +168,37 @@ public function addCountryIsoCodeType(string $countryIsoCodeType): static } /** - * @throws OnOfficeException + * @throws Throwable */ public function create(array $data): array { - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Create, OnOfficeResourceType::Address, parameters: $data, ); - return $response->json('response.results.0.data.records.0'); + return $this->requestApi($request) + ->json('response.results.0.data.records.0'); } + /** + * @throws OnOfficeException + */ public function search(): Collection { - return $this->onOfficeService->requestAll(/** - * @throws OnOfficeException - */ function (int $pageSize, int $offset) { - return $this->onOfficeService->requestApi( - OnOfficeAction::Get, - OnOfficeResourceType::Search, - OnOfficeResourceId::Address, - parameters: [ - OnOfficeService::INPUT => $this->input, - OnOfficeService::SORTBY => data_get(array_keys($this->orderBy), 0), - OnOfficeService::SORTORDER => data_get($this->orderBy, 0), - OnOfficeService::LISTLIMIT => $pageSize, - OnOfficeService::LISTOFFSET => $offset, - ...$this->customParameters, - ], - ); - }, pageSize: $this->limit, offset: $this->offset, take: $this->take); + $request = new OnOfficeRequest( + OnOfficeAction::Get, + OnOfficeResourceType::Search, + OnOfficeResourceId::Address, + parameters: [ + OnOfficeService::INPUT => $this->input, + OnOfficeService::SORTBY => data_get(array_keys($this->orderBy), 0), + OnOfficeService::SORTORDER => data_get($this->orderBy, 0), + ...$this->customParameters, + ], + ); + + return $this->requestAll($request); } } diff --git a/src/Query/Builder.php b/src/Query/Builder.php index 4d6cf76..dec8595 100644 --- a/src/Query/Builder.php +++ b/src/Query/Builder.php @@ -4,12 +4,23 @@ namespace Katalam\OnOfficeAdapter\Query; +use GuzzleHttp\Psr7\Response as Psr7Response; +use Illuminate\Http\Client\Response; use Illuminate\Support\Arr; use Illuminate\Support\Collection; use Illuminate\Support\Str; use Illuminate\Support\Traits\Conditionable; - -abstract class Builder +use JsonException; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; +use Katalam\OnOfficeAdapter\Exceptions\StrayRequestException; +use Katalam\OnOfficeAdapter\Query\Concerns\BuilderInterface; +use Katalam\OnOfficeAdapter\Repositories\BaseRepository; +use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Throwable; + +abstract class Builder implements BuilderInterface { use Conditionable; @@ -29,14 +40,14 @@ abstract class Builder public array $modifies = []; /** - * The limit for the query. + * The limit for the result. */ - public int $limit = 500; + public int $limit = -1; /** - * The take for the number of results. + * The page size for the result. */ - public int $take = -1; + public int $pageSize = 500; /** * An array of columns to order by. @@ -49,11 +60,149 @@ abstract class Builder */ public int $offset = 0; - /* + /** * An array of custom parameters. */ public array $customParameters = []; + /** + * The stub callables that will be used to fake the responses. + */ + protected Collection $stubCallables; + + /** + * Indicates that an exception should be thrown + * if a request is made without a stub callable. + */ + protected bool $preventStrayRequests = false; + + /** + * The OnOffice service. + */ + protected OnOfficeService $onOfficeService; + + /** + * The repository that created the builder. + */ + protected BaseRepository $repository; + + public function __construct() {} + + protected function getOnOfficeService(): OnOfficeService + { + return $this->onOfficeService ?? $this->createOnOfficeService(); + } + + protected function createOnOfficeService(): OnOfficeService + { + return app(OnOfficeService::class); + } + + public function setRepository(BaseRepository $repository): static + { + $this->repository = $repository; + + return $this; + } + + public function stub(Collection $stubCallable): self + { + $this->stubCallables = $stubCallable; + + return $this; + } + + public function preventStrayRequests(bool $value = true): static + { + $this->preventStrayRequests = $value; + + return $this; + } + + /** + * @throws OnOfficeException + * @throws Throwable + */ + public function requestApi(OnOfficeRequest $request): Response + { + $response = $this->getStubCallable($request); + + if (is_null($response)) { + throw_if($this->preventStrayRequests, new StrayRequestException(request: $request)); + + $response = $this->getOnOfficeService()->requestApi( + $request->actionId, + $request->resourceType, + $request->resourceId, + $request->identifier, + $request->parameters, + ); + } + + $this->repository->recordRequestResponsePair($request, $response->json()); + + return $response; + } + + /** + * @throws OnOfficeException + */ + protected function requestAll(OnOfficeRequest $request): Collection + { + return $this->getOnOfficeService()->requestAll(/** + * @throws OnOfficeException + * @throws Throwable + */ function (int $pageSize, int $offset) use ($request) { + $parameter = $request->parameters; + data_set($parameter, OnOfficeService::LISTLIMIT, $pageSize); + data_set($parameter, OnOfficeService::LISTOFFSET, $offset); + + return $this->requestApi($request); + }, pageSize: $this->pageSize, offset: $this->offset, limit: $this->limit); + } + + /** + * @throws OnOfficeException + */ + protected function requestAllChunked(OnOfficeRequest $request, callable $callback): void + { + $this->getOnOfficeService()->requestAllChunked(/** + * @throws OnOfficeException + * @throws Throwable + */ function (int $pageSize, int $offset) use ($request) { + $parameter = $request->parameters; + data_set($parameter, OnOfficeService::LISTLIMIT, $pageSize); + data_set($parameter, OnOfficeService::LISTOFFSET, $offset); + + return $this->requestApi($request); + }, $callback, pageSize: $this->pageSize, offset: $this->offset, limit: $this->limit); + } + + /** + * @throws JsonException + */ + protected function getStubCallable(OnOfficeRequest $request): ?Response + { + $response = ($this->stubCallables ?? collect())->first(); + + ($this->stubCallables ?? collect())->shift(); + + if (is_null($response)) { + return null; + } + + /** @var OnOfficeResponse $response */ + if ($response->isEmpty()) { + return null; + } + + $response = $response->shift()->toResponse(); + + $response = new Psr7Response(200, [], json_encode($response, JSON_THROW_ON_ERROR)); + + return new Response($response); + } + public function select(array|string $columns = ['ID']): static { $this->columns = Arr::wrap($columns); @@ -106,23 +255,21 @@ public function offset(int $value): static /** * Be aware that the limit is capped at 500. - * Be aware that the limit will change the page size of the result. - * Not the number of results. */ public function limit(int $value): static { - $this->limit = max(0, $value); + $this->limit = max(-1, $value); return $this; } /** - * Be aware that the take will change the number of results. - * Be aware that the take will not change the page size of the result. + * Be aware that the page size is capped at 500. */ - public function take(int $value): static + public function pageSize(int $value): static { - $this->take = max(-1, $value); + $this->pageSize = min(500, $value); + $this->pageSize = max(1, $this->pageSize); return $this; } @@ -179,14 +326,4 @@ public function parameters(array $parameters): static return $this; } - - abstract public function get(): Collection; - - abstract public function first(): ?array; - - abstract public function find(int $id): array; - - abstract public function each(callable $callback): void; - - abstract public function modify(int $id): bool; } diff --git a/src/Query/Concerns/BuilderInterface.php b/src/Query/Concerns/BuilderInterface.php new file mode 100644 index 0000000..b37f71f --- /dev/null +++ b/src/Query/Concerns/BuilderInterface.php @@ -0,0 +1,20 @@ +onOfficeService->requestAll(/** - * @throws OnOfficeException - */ function (int $pageSize, int $offset) { - return $this->onOfficeService->requestApi( - OnOfficeAction::Read, - OnOfficeResourceType::Estate, - parameters: [ - OnOfficeService::DATA => $this->columns, - OnOfficeService::FILTER => $this->getFilters(), - OnOfficeService::LISTLIMIT => $pageSize, - OnOfficeService::LISTOFFSET => $offset, - OnOfficeService::SORTBY => $this->getOrderBy(), - ...$this->customParameters, - ] - ); - }, pageSize: $this->limit, offset: $this->offset, take: $this->take); + $request = new OnOfficeRequest( + OnOfficeAction::Read, + OnOfficeResourceType::Estate, + parameters: [ + OnOfficeService::DATA => $this->columns, + OnOfficeService::FILTER => $this->getFilters(), + OnOfficeService::SORTBY => $this->getOrderBy(), + ...$this->customParameters, + ] + ); + + return $this->requestAll($request); } /** @@ -75,24 +71,23 @@ public function find(int $id): array return $response->json('response.results.0.data.records.0'); } + /** + * @throws OnOfficeException + */ public function each(callable $callback): void { - $this->onOfficeService->requestAllChunked(/** - * @throws OnOfficeException - */ function (int $pageSize, int $offset) { - return $this->onOfficeService->requestApi( - OnOfficeAction::Read, - OnOfficeResourceType::Estate, - parameters: [ - OnOfficeService::DATA => $this->columns, - OnOfficeService::FILTER => $this->getFilters(), - OnOfficeService::LISTLIMIT => $pageSize, - OnOfficeService::LISTOFFSET => $offset, - OnOfficeService::SORTBY => $this->getOrderBy(), - ...$this->customParameters, - ] - ); - }, $callback, pageSize: $this->limit, offset: $this->offset, take: $this->take); + $request = new OnOfficeRequest( + OnOfficeAction::Read, + OnOfficeResourceType::Estate, + parameters: [ + OnOfficeService::DATA => $this->columns, + OnOfficeService::FILTER => $this->getFilters(), + OnOfficeService::SORTBY => $this->getOrderBy(), + ...$this->customParameters, + ] + ); + + $this->requestAllChunked($request, $callback); } /** diff --git a/src/Query/EstateFileBuilder.php b/src/Query/EstateFileBuilder.php index 2ba799f..21b0eb6 100644 --- a/src/Query/EstateFileBuilder.php +++ b/src/Query/EstateFileBuilder.php @@ -5,48 +5,50 @@ namespace Katalam\OnOfficeAdapter\Query; use Illuminate\Support\Collection; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceId; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Throwable; class EstateFileBuilder extends Builder { public int $estateId; public function __construct( - private readonly OnOfficeService $onOfficeService, int $estateId, ) { $this->estateId = $estateId; + + parent::__construct(); } + /** + * @throws OnOfficeException + */ public function get(): Collection { - return $this->onOfficeService->requestAll(/** - * @throws OnOfficeException - */ function (int $pageSize, int $offset) { - return $this->onOfficeService->requestApi( - OnOfficeAction::Get, - OnOfficeResourceType::File, - OnOfficeResourceId::Estate, - parameters: [ - 'estateid' => $this->estateId, - OnOfficeService::LISTLIMIT => $pageSize, - OnOfficeService::LISTOFFSET => $offset, - ...$this->customParameters, - ], - ); - }, pageSize: $this->limit, offset: $this->offset, take: $this->take); + $request = new OnOfficeRequest( + OnOfficeAction::Get, + OnOfficeResourceType::File, + OnOfficeResourceId::Estate, + parameters: [ + 'estateid' => $this->estateId, + ...$this->customParameters, + ], + ); + + return $this->requestAll($request); } /** - * @throws OnOfficeException + * @throws Throwable */ public function first(): ?array { - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Get, OnOfficeResourceType::File, OnOfficeResourceId::Estate, @@ -56,15 +58,16 @@ public function first(): ?array ], ); - return $response->json('response.results.0.data.records.0'); + return $this->requestApi($request) + ->json('response.results.0.data.records.0'); } /** - * @throws OnOfficeException + * @throws Throwable */ public function find(int $id): array { - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Get, OnOfficeResourceType::File, OnOfficeResourceId::Estate, @@ -75,6 +78,8 @@ public function find(int $id): array ], ); + $response = $this->requestApi($request); + $result = $response->json('response.results.0.data.records.0'); if (! $result) { @@ -84,27 +89,26 @@ public function find(int $id): array return $result; } + /** + * @throws OnOfficeException + */ public function each(callable $callback): void { - $this->onOfficeService->requestAllChunked(/** - * @throws OnOfficeException - */ function (int $pageSize, int $offset) { - return $this->onOfficeService->requestApi( - OnOfficeAction::Get, - OnOfficeResourceType::File, - OnOfficeResourceId::Estate, - parameters: [ - 'estateid' => $this->estateId, - OnOfficeService::LISTLIMIT => $pageSize, - OnOfficeService::LISTOFFSET => $offset, - ...$this->customParameters, - ], - ); - }, $callback, pageSize: $this->limit, offset: $this->offset, take: $this->take); + $request = new OnOfficeRequest( + OnOfficeAction::Get, + OnOfficeResourceType::File, + OnOfficeResourceId::Estate, + parameters: [ + 'estateid' => $this->estateId, + ...$this->customParameters, + ], + ); + + $this->requestAllChunked($request, $callback); } /** - * @throws OnOfficeException + * @throws Throwable */ public function modify(int $id): bool { @@ -114,21 +118,22 @@ public function modify(int $id): bool 'relationtype' => 'estate', ]); - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Modify, OnOfficeResourceType::FileRelation, parameters: $parameters, ); - return $response->json('response.results.0.data.records.0.elements.success') === 'success'; + return $this->requestApi($request) + ->json('response.results.0.data.records.0.elements.success') === 'success'; } /** - * @throws OnOfficeException + * @throws Throwable */ public function delete(int $id): bool { - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Delete, OnOfficeResourceType::FileRelation, parameters: [ @@ -139,6 +144,7 @@ public function delete(int $id): bool ], ); - return $response->json('response.results.0.data.records.0.elements.success') === 'success'; + return $this->requestApi($request) + ->json('response.results.0.data.records.0.elements.success') === 'success'; } } diff --git a/src/Query/FieldBuilder.php b/src/Query/FieldBuilder.php index 447660d..7e6959e 100644 --- a/src/Query/FieldBuilder.php +++ b/src/Query/FieldBuilder.php @@ -6,33 +6,30 @@ use Illuminate\Support\Arr; use Illuminate\Support\Collection; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; class FieldBuilder extends Builder { public array $modules = []; - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - + /** + * @throws OnOfficeException + */ public function get(): Collection { - return $this->onOfficeService->requestAll(/** - * @throws OnOfficeException - */ function () { - return $this->onOfficeService->requestApi( - OnOfficeAction::Get, - OnOfficeResourceType::Fields, - parameters: [ - 'modules' => $this->modules, - ...$this->customParameters, - ], - ); - }); + $request = new OnOfficeRequest( + OnOfficeAction::Get, + OnOfficeResourceType::Fields, + parameters: [ + 'modules' => $this->modules, + ...$this->customParameters, + ], + ); + + return $this->requestAll($request); } /** @@ -60,20 +57,21 @@ public function find(int $id): array throw new OnOfficeException('Not implemented in onOffice'); } + /** + * @throws OnOfficeException + */ public function each(callable $callback): void { - $this->onOfficeService->requestAllChunked(/** - * @throws OnOfficeException - */ function () { - return $this->onOfficeService->requestApi( - OnOfficeAction::Get, - OnOfficeResourceType::Fields, - parameters: [ - 'modules' => $this->modules, - ...$this->customParameters, - ], - ); - }, $callback); + $request = new OnOfficeRequest( + OnOfficeAction::Get, + OnOfficeResourceType::Fields, + parameters: [ + 'modules' => $this->modules, + ...$this->customParameters, + ], + ); + + $this->requestAllChunked($request, $callback); } public function withModules(array|string $modules): static diff --git a/src/Query/ImprintBuilder.php b/src/Query/ImprintBuilder.php index 26a40cd..6a402d7 100644 --- a/src/Query/ImprintBuilder.php +++ b/src/Query/ImprintBuilder.php @@ -5,6 +5,7 @@ namespace Katalam\OnOfficeAdapter\Query; use Illuminate\Support\Collection; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; @@ -18,24 +19,21 @@ class ImprintBuilder extends Builder use NonFilterable; use NonOrderable; - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - + /** + * @throws OnOfficeException + */ public function get(): Collection { - return $this->onOfficeService->requestAll(/** - * @throws OnOfficeException - */ function () { - return $this->onOfficeService->requestApi( - OnOfficeAction::Read, - OnOfficeResourceType::Impressum, - parameters: [ - OnOfficeService::DATA => $this->columns, - ...$this->customParameters, - ] - ); - }, pageSize: $this->limit, offset: $this->offset, take: $this->take); + $request = new OnOfficeRequest( + OnOfficeAction::Read, + OnOfficeResourceType::Impressum, + parameters: [ + OnOfficeService::DATA => $this->columns, + ...$this->customParameters, + ] + ); + + return $this->requestAll($request); } /** diff --git a/src/Query/MarketplaceBuilder.php b/src/Query/MarketplaceBuilder.php index ea51e50..6b73a07 100644 --- a/src/Query/MarketplaceBuilder.php +++ b/src/Query/MarketplaceBuilder.php @@ -5,17 +5,15 @@ namespace Katalam\OnOfficeAdapter\Query; use Illuminate\Support\Collection; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Throwable; class MarketplaceBuilder extends Builder { - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - /** * @throws OnOfficeException */ @@ -25,13 +23,13 @@ public function get(): Collection } /** - * @throws OnOfficeException + * @throws Throwable */ public function unlockProvider( string $parameterCacheId, string $extendedClaim, ): bool { - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Do, OnOfficeResourceType::UnlockProvider, parameters: [ @@ -41,7 +39,8 @@ public function unlockProvider( ] ); - return $response->json('response.results.0.data.records.0.elements.success') === 'success'; + return $this->requestApi($request) + ->json('response.results.0.data.records.0.elements.success') === 'success'; } /** diff --git a/src/Query/RegionBuilder.php b/src/Query/RegionBuilder.php index a084c2b..11f1bd1 100644 --- a/src/Query/RegionBuilder.php +++ b/src/Query/RegionBuilder.php @@ -5,13 +5,14 @@ namespace Katalam\OnOfficeAdapter\Query; use Illuminate\Support\Collection; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; use Katalam\OnOfficeAdapter\Query\Concerns\NonFilterable; use Katalam\OnOfficeAdapter\Query\Concerns\NonOrderable; use Katalam\OnOfficeAdapter\Query\Concerns\NonSelectable; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Throwable; class RegionBuilder extends Builder { @@ -20,35 +21,33 @@ class RegionBuilder extends Builder use NonOrderable; use NonSelectable; - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - + /** + * @throws OnOfficeException + */ public function get(): Collection { - return $this->onOfficeService->requestAll(/** - * @throws OnOfficeException - */ function () { - return $this->onOfficeService->requestApi( - OnOfficeAction::Get, - OnOfficeResourceType::Regions, - ...$this->customParameters, - ); - }, pageSize: $this->limit, offset: $this->offset, take: $this->take); + $request = new OnOfficeRequest( + OnOfficeAction::Get, + OnOfficeResourceType::Regions, + ...$this->customParameters, + ); + + return $this->requestAll($request); } /** - * @throws OnOfficeException + * @throws Throwable */ public function first(): ?array { - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Get, OnOfficeResourceType::Regions, ...$this->customParameters, ); - return $response->json('response.results.0.data.records.0'); + return $this->requestApi($request) + ->json('response.results.0.data.records.0'); } /** @@ -59,17 +58,18 @@ public function find(int $id): array throw new OnOfficeException('Method not implemented'); } + /** + * @throws OnOfficeException + */ public function each(callable $callback): void { - $this->onOfficeService->requestAllChunked(/** - * @throws OnOfficeException - */ function () { - return $this->onOfficeService->requestApi( - OnOfficeAction::Get, - OnOfficeResourceType::Regions, - ...$this->customParameters, - ); - }, $callback, pageSize: $this->limit, offset: $this->offset, take: $this->take); + $request = new OnOfficeRequest( + OnOfficeAction::Get, + OnOfficeResourceType::Regions, + ...$this->customParameters, + ); + + $this->requestAllChunked($request, $callback); } /** diff --git a/src/Query/RelationBuilder.php b/src/Query/RelationBuilder.php index 168d63f..d4f3b0e 100644 --- a/src/Query/RelationBuilder.php +++ b/src/Query/RelationBuilder.php @@ -5,6 +5,7 @@ namespace Katalam\OnOfficeAdapter\Query; use Illuminate\Support\Collection; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; @@ -13,6 +14,7 @@ use Katalam\OnOfficeAdapter\Query\Concerns\NonSelectable; use Katalam\OnOfficeAdapter\Query\Concerns\RelationTypes; use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Throwable; class RelationBuilder extends Builder { @@ -22,26 +24,23 @@ class RelationBuilder extends Builder use NonSelectable; use RelationTypes; - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - + /** + * @throws OnOfficeException + */ public function get(): Collection { - $records = $this->onOfficeService->requestAll(/** - * @throws OnOfficeException - */ function () { - return $this->onOfficeService->requestApi( - OnOfficeAction::Get, - OnOfficeResourceType::IdsFromRelation, - parameters: [ - OnOfficeService::RELATIONTYPE => $this->relationType, - OnOfficeService::PARENTIDS => $this->parentIds, - OnOfficeService::CHILDIDS => $this->childIds, - ...$this->customParameters, - ], - ); - }, pageSize: $this->limit, offset: $this->offset, take: $this->take); + $request = new OnOfficeRequest( + OnOfficeAction::Get, + OnOfficeResourceType::IdsFromRelation, + parameters: [ + OnOfficeService::RELATIONTYPE => $this->relationType, + OnOfficeService::PARENTIDS => $this->parentIds, + OnOfficeService::CHILDIDS => $this->childIds, + ...$this->customParameters, + ], + ); + + $records = $this->requestAll($request); // $records is always an array containing a single element return collect(data_get($records->first(), 'elements')); @@ -63,6 +62,9 @@ public function find(int $id): array throw new OnOfficeException('Not implemented in onOffice'); } + /** + * @throws OnOfficeException + */ public function each(callable $callback): void { $records = $this->get(); @@ -79,11 +81,11 @@ public function modify(int $id): bool } /** - * @throws OnOfficeException + * @throws Throwable */ public function create(): bool { - $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Create, OnOfficeResourceType::Relation, parameters: [ @@ -94,6 +96,8 @@ public function create(): bool ], ); + $this->requestApi($request); + return true; } } diff --git a/src/Query/SearchCriteriaBuilder.php b/src/Query/SearchCriteriaBuilder.php index dc71246..fc1a75b 100644 --- a/src/Query/SearchCriteriaBuilder.php +++ b/src/Query/SearchCriteriaBuilder.php @@ -6,19 +6,17 @@ use Illuminate\Support\Arr; use Illuminate\Support\Collection; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Throwable; class SearchCriteriaBuilder extends Builder { private string $mode = 'internal'; - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - /** * @throws OnOfficeException */ @@ -36,11 +34,11 @@ public function first(): ?array } /** - * @throws OnOfficeException + * @throws Throwable */ public function find(int|array $id): array { - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Get, OnOfficeResourceType::SearchCriteria, parameters: [ @@ -50,7 +48,8 @@ public function find(int|array $id): array ], ); - return $response->json('response.results.0.data.records.0', []); + return $this->requestApi($request) + ->json('response.results.0.data.records.0', []); } /** diff --git a/src/Query/Testing/ActionBuilderFake.php b/src/Query/Testing/ActionBuilderFake.php deleted file mode 100644 index 2eca33d..0000000 --- a/src/Query/Testing/ActionBuilderFake.php +++ /dev/null @@ -1,7 +0,0 @@ -get()->first(); - } - - public function estate(): static - { - $this->estateOrAddress = 'estateid'; - - return $this; - } - - public function address(): static - { - $this->estateOrAddress = 'addressid'; - - return $this; - } - - public function recordIdsAsEstate(): static - { - $this->estate(); - - return $this; - } - - public function recordIdsAsAddress(): static - { - $this->address(); - - return $this; - } -} diff --git a/src/Query/Testing/AddressBuilderFake.php b/src/Query/Testing/AddressBuilderFake.php deleted file mode 100644 index b9f1d36..0000000 --- a/src/Query/Testing/AddressBuilderFake.php +++ /dev/null @@ -1,49 +0,0 @@ -fakeResponses->shift(); - throw_if($nextRequest === null, new Exception('No more fake responses')); - - return collect($nextRequest)->flatten()->count(); - } - - public function addCountryIsoCodeType(string $countryIsoCodeType): self - { - return $this; - } - - /** - * @throws Throwable - */ - public function create(array $data): array - { - return $this->get()->first(); - } - - /** - * @throws Throwable - */ - public function search(): Collection - { - return $this->get(); - } -} diff --git a/src/Query/Testing/BaseFake.php b/src/Query/Testing/BaseFake.php deleted file mode 100644 index a396237..0000000 --- a/src/Query/Testing/BaseFake.php +++ /dev/null @@ -1,101 +0,0 @@ -fakeResponses->isEmpty(), new Exception('No more fake responses')); - - $nextRequest = $this->fakeResponses->shift(); - - return collect($nextRequest) - ->flatten() - ->map(function (BaseFactory|OnOfficeException|null $factory) { - if ($factory instanceof OnOfficeException) { - throw $factory; - } - - return $factory?->toArray(); - }); - } - - /** - * @throws Throwable - */ - public function first(): ?array - { - return $this->get()->first(); - } - - /** - * @throws Throwable - */ - public function find(int $id): array - { - return $this->get() - ->first(fn (array $record) => $record['id'] === $id) ?? []; - } - - /** - * @throws Throwable - */ - public function each(callable $callback): void - { - throw_if($this->fakeResponses->isEmpty(), new Exception('No more fake responses')); - - $nextRequest = $this->fakeResponses->shift(); - - collect($nextRequest) - ->each(function (array $factories) use ($callback) { - $records = collect($factories) - ->map(function (BaseFactory|OnOfficeException|null $factory) { - if ($factory instanceof OnOfficeException) { - throw $factory; - } - - return $factory?->toArray(); - }) - ->toArray(); - - $callback($records); - }); - } - - /** - * @throws Throwable - */ - public function modify(int $id): bool - { - throw_if($this->fakeResponses->isEmpty(), new Exception('No more fake responses')); - - $nextRequest = $this->fakeResponses->shift(); - - $first = collect($nextRequest) - ->flatten() - ->first(); - - if ($first instanceof OnOfficeException) { - throw $first; - } - - return $first; - } -} diff --git a/src/Query/Testing/EstateBuilderFake.php b/src/Query/Testing/EstateBuilderFake.php deleted file mode 100644 index 304d0de..0000000 --- a/src/Query/Testing/EstateBuilderFake.php +++ /dev/null @@ -1,18 +0,0 @@ -get()->first(); - } -} diff --git a/src/Query/Testing/EstateFileBuilderFake.php b/src/Query/Testing/EstateFileBuilderFake.php deleted file mode 100644 index 33c4936..0000000 --- a/src/Query/Testing/EstateFileBuilderFake.php +++ /dev/null @@ -1,20 +0,0 @@ -get()->first(); - - return data_get($record, 'elements.success') === 'success'; - } -} diff --git a/src/Query/Testing/FieldBuilderFake.php b/src/Query/Testing/FieldBuilderFake.php deleted file mode 100644 index 2deb277..0000000 --- a/src/Query/Testing/FieldBuilderFake.php +++ /dev/null @@ -1,26 +0,0 @@ -get()->first(); - } -} diff --git a/src/Query/Testing/ImprintBuilderFake.php b/src/Query/Testing/ImprintBuilderFake.php deleted file mode 100644 index ed22161..0000000 --- a/src/Query/Testing/ImprintBuilderFake.php +++ /dev/null @@ -1,7 +0,0 @@ -get()->first(); - - return data_get($record, 'elements.success') === 'success'; - } -} diff --git a/src/Query/Testing/RegionBuilderFake.php b/src/Query/Testing/RegionBuilderFake.php deleted file mode 100644 index 2c62c75..0000000 --- a/src/Query/Testing/RegionBuilderFake.php +++ /dev/null @@ -1,7 +0,0 @@ -get()->first(); - } -} diff --git a/src/Query/Testing/SearchCriteriaBuilderFake.php b/src/Query/Testing/SearchCriteriaBuilderFake.php deleted file mode 100644 index cb9090e..0000000 --- a/src/Query/Testing/SearchCriteriaBuilderFake.php +++ /dev/null @@ -1,7 +0,0 @@ -uploadInBlocks > 0) { - $blocks = str_split($fileContent, $this->uploadInBlocks); - - $iMax = count($blocks); - for ($i = 0; $i < $iMax; $i++) { - $record = $this->get()->first(); - } - } else { - $record = $this->get()->first(); - } - - return data_get($record, 'elements.tmpUploadId'); - } - - /** - * @throws Throwable - */ - public function link(string $tmpUploadId, array $data = []): array - { - return $this->get()->first(); - } - - /** - * @throws Throwable - */ - public function saveAndLink(string $fileContent, array $data = []): array - { - $tmpUploadId = $this->save($fileContent); - - return $this->link($tmpUploadId, $data); - } -} diff --git a/src/Query/Testing/UserBuilderFake.php b/src/Query/Testing/UserBuilderFake.php deleted file mode 100644 index d7ceac3..0000000 --- a/src/Query/Testing/UserBuilderFake.php +++ /dev/null @@ -1,7 +0,0 @@ - */ public function save(string $fileContent): string { @@ -89,7 +87,7 @@ public function save(string $fileContent): string $continueData = ['tmpUploadId' => $tmpUploadId]; } - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Do, OnOfficeResourceType::UploadFile, parameters: [ @@ -99,7 +97,8 @@ public function save(string $fileContent): string ], ); - $tmpUploadId = $response->json('response.results.0.data.records.0.elements.tmpUploadId'); + $tmpUploadId = $this->requestApi($request) + ->json('response.results.0.data.records.0.elements.tmpUploadId'); }); return $tmpUploadId; @@ -108,7 +107,7 @@ public function save(string $fileContent): string /** * Returns the linked file data. * - * @throws OnOfficeException + * @throws Throwable */ public function link(string $tmpUploadId, array $data = []): array { @@ -116,20 +115,21 @@ public function link(string $tmpUploadId, array $data = []): array 'tmpUploadId' => $tmpUploadId, ]); - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Do, OnOfficeResourceType::UploadFile, parameters: $data, ); - return $response->json('response.results.0.data.records.0'); + return $this->requestApi($request) + ->json('response.results.0.data.records.0'); } /** * File content as base64-encoded binary data. * Returns the linked file data. * - * @throws OnOfficeException + * @throws Throwable */ public function saveAndLink(string $fileContent, array $data = []): array { diff --git a/src/Query/UserBuilder.php b/src/Query/UserBuilder.php index d0a4f63..4b1a48c 100644 --- a/src/Query/UserBuilder.php +++ b/src/Query/UserBuilder.php @@ -5,43 +5,40 @@ namespace Katalam\OnOfficeAdapter\Query; use Illuminate\Support\Collection; +use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Throwable; class UserBuilder extends Builder { - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - + /** + * @throws OnOfficeException + */ public function get(): Collection { - return $this->onOfficeService->requestAll(/** - * @throws OnOfficeException - */ function (int $pageSize, int $offset) { - return $this->onOfficeService->requestApi( - OnOfficeAction::Read, - OnOfficeResourceType::User, - parameters: [ - OnOfficeService::DATA => $this->columns, - OnOfficeService::FILTER => $this->getFilters(), - OnOfficeService::LISTLIMIT => $pageSize, - OnOfficeService::LISTOFFSET => $offset, - OnOfficeService::SORTBY => $this->getOrderBy(), - ...$this->customParameters, - ], - ); - }, pageSize: $this->limit, offset: $this->offset, take: $this->take); + $request = new OnOfficeRequest( + OnOfficeAction::Read, + OnOfficeResourceType::User, + parameters: [ + OnOfficeService::DATA => $this->columns, + OnOfficeService::FILTER => $this->getFilters(), + OnOfficeService::SORTBY => $this->getOrderBy(), + ...$this->customParameters, + ], + ); + + return $this->requestAll($request); } /** - * @throws OnOfficeException + * @throws Throwable */ public function first(): ?array { - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Read, OnOfficeResourceType::User, parameters: [ @@ -54,15 +51,16 @@ public function first(): ?array ] ); - return $response->json('response.results.0.data.records.0'); + return $this->requestApi($request) + ->json('response.results.0.data.records.0'); } /** - * @throws OnOfficeException + * @throws Throwable */ public function find(int $id): array { - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Get, OnOfficeResourceType::User, $id, @@ -72,27 +70,27 @@ public function find(int $id): array ] ); - return $response->json('response.results.0.data.records.0'); + return $this->requestApi($request) + ->json('response.results.0.data.records.0'); } + /** + * @throws OnOfficeException + */ public function each(callable $callback): void { - $this->onOfficeService->requestAllChunked(/** - * @throws OnOfficeException - */ function (int $pageSize, int $offset) { - return $this->onOfficeService->requestApi( - OnOfficeAction::Read, - OnOfficeResourceType::User, - parameters: [ - OnOfficeService::DATA => $this->columns, - OnOfficeService::FILTER => $this->getFilters(), - OnOfficeService::LISTLIMIT => $pageSize, - OnOfficeService::LISTOFFSET => $offset, - OnOfficeService::SORTBY => $this->getOrderBy(), - ...$this->customParameters, - ] - ); - }, $callback, pageSize: $this->limit, offset: $this->offset, take: $this->take); + $request = new OnOfficeRequest( + OnOfficeAction::Read, + OnOfficeResourceType::User, + parameters: [ + OnOfficeService::DATA => $this->columns, + OnOfficeService::FILTER => $this->getFilters(), + OnOfficeService::SORTBY => $this->getOrderBy(), + ...$this->customParameters, + ] + ); + + $this->requestAllChunked($request, $callback); } /** diff --git a/src/Repositories/ActivityRepository.php b/src/Repositories/ActivityRepository.php index f82b193..5e4ed10 100644 --- a/src/Repositories/ActivityRepository.php +++ b/src/Repositories/ActivityRepository.php @@ -5,19 +5,11 @@ namespace Katalam\OnOfficeAdapter\Repositories; use Katalam\OnOfficeAdapter\Query\ActivityBuilder; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; -class ActivityRepository +class ActivityRepository extends BaseRepository { - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - - /** - * Returns a new address builder instance. - */ - public function query(): ActivityBuilder + protected function createBuilder(): ActivityBuilder { - return new ActivityBuilder($this->onOfficeService); + return new ActivityBuilder; } } diff --git a/src/Repositories/AddressRepository.php b/src/Repositories/AddressRepository.php index 547f5bb..2f1e035 100644 --- a/src/Repositories/AddressRepository.php +++ b/src/Repositories/AddressRepository.php @@ -5,19 +5,11 @@ namespace Katalam\OnOfficeAdapter\Repositories; use Katalam\OnOfficeAdapter\Query\AddressBuilder; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; -class AddressRepository +class AddressRepository extends BaseRepository { - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - - /** - * Returns a new address builder instance. - */ - public function query(): AddressBuilder + protected function createBuilder(): AddressBuilder { - return new AddressBuilder($this->onOfficeService); + return new AddressBuilder; } } diff --git a/src/Repositories/BaseRepository.php b/src/Repositories/BaseRepository.php new file mode 100644 index 0000000..c389f70 --- /dev/null +++ b/src/Repositories/BaseRepository.php @@ -0,0 +1,243 @@ +stubCallables = new Collection; + } + + public function fake(OnOfficeResponsePage|OnOfficeResponse|array|null $responses): static + { + $this->record(); + + if (is_null($responses)) { + $responses = $this->response(); + } + + if (is_array($responses)) { + foreach ($responses as $fake) { + if ($fake instanceof OnOfficeResponse) { + $this->stubCallables->push($fake); + } elseif ($fake instanceof OnOfficeResponsePage || is_array($fake)) { + $this->stubCallables->push(new OnOfficeResponse(collect(Arr::wrap($fake)))); + } + } + + return $this; + } + + if ($responses instanceof OnOfficeResponse) { + $this->stubCallables->push($responses); + } + + if ($responses instanceof OnOfficeResponsePage) { + $this->stubCallables->push(new OnOfficeResponse(collect([$responses]))); + } + + return $this; + } + + public function response(array $pages = []): OnOfficeResponse + { + if ($pages === []) { + $pages = [$this->page()]; + } + + return new OnOfficeResponse(collect($pages)); + } + + public function page( + OnOfficeAction $actionId = OnOfficeAction::Read, + OnOfficeResourceType|string $resourceType = OnOfficeResourceType::Estate, + array $recordFactories = [], + int $status = 200, + int $errorCode = 0, + string $message = 'OK', + OnOfficeResourceId|string|int $resourceId = OnOfficeResourceId::None, + bool $cacheable = true, + string|int $identifier = '', + int $countAbsolute = 0, + int $errorCodeResult = 0, + string $messageResult = 'OK', + ): OnOfficeResponsePage { + return new OnOfficeResponsePage( + $actionId, + $resourceType, + collect($recordFactories), + $status, + $errorCode, + $message, + $resourceId, + $cacheable, + $identifier, + $countAbsolute, + $errorCodeResult, + $messageResult, + ); + } + + public function query(): Builder + { + return tap($this->createBuilder(), function (Builder $builder) { + $builder + ->stub($this->stubCallables) + ->preventStrayRequests($this->preventStrayRequests) + ->setRepository($this); + }); + } + + protected function createBuilder(): Builder + { + return new class extends Builder + { + public function get(): Collection + { + throw new RuntimeException('Not implemented'); + } + + public function first(): ?array + { + throw new RuntimeException('Not implemented'); + } + + public function find(int $id): array + { + throw new RuntimeException('Not implemented'); + } + + public function each(callable $callback): void + { + throw new RuntimeException('Not implemented'); + } + + public function modify(int $id): bool + { + throw new RuntimeException('Not implemented'); + } + }; + } + + /** + * Create a new builder instance from the given class. + * The parameters will be passed to the builder's constructor. + */ + protected function createBuilderFromClass(string $class, ...$parameter): Builder + { + return tap(new $class(...$parameter), function (Builder $builder) { + $builder + ->stub($this->stubCallables) + ->preventStrayRequests($this->preventStrayRequests) + ->setRepository($this); + }); + } + + public function preventStrayRequests(bool $value = true): static + { + $this->preventStrayRequests = $value; + + return $this; + } + + public function allowStrayRequests(): static + { + return $this->preventStrayRequests(false); + } + + public function record(bool $recording = true): static + { + $this->recording = $recording; + + return $this; + } + + public function stopRecording(): static + { + return $this->record(false); + } + + public function recordRequestResponsePair(OnOfficeRequest $request, array $response): static + { + if ($this->recording) { + $this->recorded[] = [$request, $response]; + } + + return $this; + } + + /** + * Get a collection of the request / response pairs matching the given truth test. + */ + public function recorded(?callable $callback = null): Collection + { + if (empty($this->recorded)) { + return collect(); + } + + $callback = $callback ?: static function () { + return true; + }; + + return collect($this->recorded)->filter(function (array $pair) use ($callback) { + return $callback($pair[0], $pair[1]); + }); + } + + public function assertSent(?callable $callback = null): void + { + PHPUnit::assertTrue( + $this->recorded($callback)->isNotEmpty(), + 'An expected request was not recorded.' + ); + } + + public function assertNotSent(?callable $callback = null): void + { + PHPUnit::assertTrue( + $this->recorded($callback)->isEmpty(), + 'An unexpected request was recorded.' + ); + } + + public function assertSentCount(int $count): void + { + PHPUnit::assertCount($count, $this->recorded()); + } +} diff --git a/src/Repositories/EstateRepository.php b/src/Repositories/EstateRepository.php index 968fa0d..4a4173e 100644 --- a/src/Repositories/EstateRepository.php +++ b/src/Repositories/EstateRepository.php @@ -6,20 +6,12 @@ use Katalam\OnOfficeAdapter\Query\EstateBuilder; use Katalam\OnOfficeAdapter\Query\EstateFileBuilder; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; -class EstateRepository +class EstateRepository extends BaseRepository { - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - - /** - * Returns a new estate builder instance. - */ - public function query(): EstateBuilder + protected function createBuilder(): EstateBuilder { - return new EstateBuilder($this->onOfficeService); + return new EstateBuilder; } /** @@ -27,6 +19,7 @@ public function query(): EstateBuilder */ public function files(int $estateId): EstateFileBuilder { - return new EstateFileBuilder($this->onOfficeService, $estateId); + /** @var EstateFileBuilder */ + return $this->createBuilderFromClass(EstateFileBuilder::class, $estateId); } } diff --git a/src/Repositories/FieldRepository.php b/src/Repositories/FieldRepository.php index 5251919..2784896 100644 --- a/src/Repositories/FieldRepository.php +++ b/src/Repositories/FieldRepository.php @@ -5,19 +5,11 @@ namespace Katalam\OnOfficeAdapter\Repositories; use Katalam\OnOfficeAdapter\Query\FieldBuilder; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; -class FieldRepository +class FieldRepository extends BaseRepository { - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - - /** - * Returns a new field builder instance. - */ - public function query(): FieldBuilder + protected function createBuilder(): FieldBuilder { - return new FieldBuilder($this->onOfficeService); + return new FieldBuilder; } } diff --git a/src/Repositories/FileRepository.php b/src/Repositories/FileRepository.php index b94d3ec..eed96d1 100644 --- a/src/Repositories/FileRepository.php +++ b/src/Repositories/FileRepository.php @@ -4,20 +4,18 @@ namespace Katalam\OnOfficeAdapter\Repositories; +use Katalam\OnOfficeAdapter\Query\Builder; use Katalam\OnOfficeAdapter\Query\UploadBuilder; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; -class FileRepository +class FileRepository extends BaseRepository { - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} + public function upload(): Builder + { + return $this->query(); + } - /** - * Returns a new upload builder instance. - */ - public function upload(): UploadBuilder + protected function createBuilder(): UploadBuilder { - return new UploadBuilder($this->onOfficeService); + return new UploadBuilder; } } diff --git a/src/Repositories/MarketplaceRepository.php b/src/Repositories/MarketplaceRepository.php index ca41beb..a2c3102 100644 --- a/src/Repositories/MarketplaceRepository.php +++ b/src/Repositories/MarketplaceRepository.php @@ -5,19 +5,11 @@ namespace Katalam\OnOfficeAdapter\Repositories; use Katalam\OnOfficeAdapter\Query\MarketplaceBuilder; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; -class MarketplaceRepository +class MarketplaceRepository extends BaseRepository { - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - - /** - * Returns a new marketplace builder instance. - */ - public function query(): MarketplaceBuilder + protected function createBuilder(): MarketplaceBuilder { - return new MarketplaceBuilder($this->onOfficeService); + return new MarketplaceBuilder; } } diff --git a/src/Repositories/RelationRepository.php b/src/Repositories/RelationRepository.php index 2402456..c6bb595 100644 --- a/src/Repositories/RelationRepository.php +++ b/src/Repositories/RelationRepository.php @@ -5,19 +5,11 @@ namespace Katalam\OnOfficeAdapter\Repositories; use Katalam\OnOfficeAdapter\Query\RelationBuilder; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; -class RelationRepository +class RelationRepository extends BaseRepository { - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - - /** - * Returns a new relation builder instance. - */ - public function query(): RelationBuilder + protected function createBuilder(): RelationBuilder { - return new RelationBuilder($this->onOfficeService); + return new RelationBuilder; } } diff --git a/src/Repositories/SearchCriteriaRepository.php b/src/Repositories/SearchCriteriaRepository.php index 9cac7e8..430d4f3 100644 --- a/src/Repositories/SearchCriteriaRepository.php +++ b/src/Repositories/SearchCriteriaRepository.php @@ -5,19 +5,11 @@ namespace Katalam\OnOfficeAdapter\Repositories; use Katalam\OnOfficeAdapter\Query\SearchCriteriaBuilder; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; -class SearchCriteriaRepository +class SearchCriteriaRepository extends BaseRepository { - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - - /** - * Returns a new user builder instance. - */ - public function query(): SearchCriteriaBuilder + protected function createBuilder(): SearchCriteriaBuilder { - return new SearchCriteriaBuilder($this->onOfficeService); + return new SearchCriteriaBuilder; } } diff --git a/src/Repositories/SettingRepository.php b/src/Repositories/SettingRepository.php index ae071c4..d2be05b 100644 --- a/src/Repositories/SettingRepository.php +++ b/src/Repositories/SettingRepository.php @@ -5,23 +5,20 @@ namespace Katalam\OnOfficeAdapter\Repositories; use Katalam\OnOfficeAdapter\Query\ActionBuilder; +use Katalam\OnOfficeAdapter\Query\Builder; use Katalam\OnOfficeAdapter\Query\ImprintBuilder; use Katalam\OnOfficeAdapter\Query\RegionBuilder; use Katalam\OnOfficeAdapter\Query\UserBuilder; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; -class SettingRepository +class SettingRepository extends BaseRepository { - public function __construct( - private readonly OnOfficeService $onOfficeService, - ) {} - /** * Returns a new user builder instance. */ public function users(): UserBuilder { - return new UserBuilder($this->onOfficeService); + /** @var UserBuilder */ + return $this->createBuilderFromClass(UserBuilder::class); } /** @@ -29,7 +26,8 @@ public function users(): UserBuilder */ public function regions(): RegionBuilder { - return new RegionBuilder($this->onOfficeService); + /** @var RegionBuilder */ + return $this->createBuilderFromClass(RegionBuilder::class); } /* @@ -37,7 +35,8 @@ public function regions(): RegionBuilder */ public function imprint(): ImprintBuilder { - return new ImprintBuilder($this->onOfficeService); + /** @var ImprintBuilder */ + return $this->createBuilderFromClass(ImprintBuilder::class); } /* @@ -45,6 +44,7 @@ public function imprint(): ImprintBuilder */ public function actions(): ActionBuilder { - return new ActionBuilder($this->onOfficeService); + /** @var ActionBuilder */ + return $this->createBuilderFromClass(ActionBuilder::class); } } diff --git a/src/Services/OnOfficeService.php b/src/Services/OnOfficeService.php index 51cdcfe..3bbe227 100644 --- a/src/Services/OnOfficeService.php +++ b/src/Services/OnOfficeService.php @@ -114,6 +114,8 @@ public function requestApi( * With a max page calculation based on * the total count of records, * of the first request. + * + * @throws OnOfficeException */ public function requestAll( callable $request, @@ -121,16 +123,20 @@ public function requestAll( string $countPath = 'response.results.0.data.meta.cntabsolute', int $pageSize = 500, int $offset = 0, - int $take = -1, + int $limit = -1, ): Collection { $maxPage = 0; - $data = collect(); + $data = new Collection; do { try { $response = $request($pageSize, $offset); } catch (OnOfficeException $exception) { Log::error("{$exception->getMessage()} - {$exception->getCode()}"); + if ($maxPage === 0) { + throw $exception; + } + return $data; } @@ -152,8 +158,8 @@ public function requestAll( // and we have more records than the take parameter, // we break the loop and return the data except the // records that are more than the take parameter - if ($take > -1 && $data->count() > $take) { - $data = $data->take($take); + if ($limit > -1 && $data->count() > $limit) { + $data = $data->take($limit); break; } @@ -172,6 +178,8 @@ public function requestAll( * * The request will not return a collection containing the records, * but will call the given callback function with the records of each page. + * + * @throws OnOfficeException */ public function requestAllChunked( callable $request, @@ -180,7 +188,7 @@ public function requestAllChunked( string $countPath = 'response.results.0.data.meta.cntabsolute', int $pageSize = 500, int $offset = 0, - int $take = -1, + int $limit = -1, ): void { $maxPage = 0; $elementCount = 0; @@ -190,6 +198,10 @@ public function requestAllChunked( } catch (OnOfficeException $exception) { Log::error("{$exception->getMessage()} - {$exception->getCode()}"); + if ($maxPage === 0) { + throw $exception; + } + return; } @@ -203,8 +215,8 @@ public function requestAllChunked( // if the take parameter is set, // and we have more records than the take parameter, // we set the countAbsolute to the take parameter - if ($take > -1 && $countAbsolute > $take) { - $countAbsolute = $take; + if ($limit > -1 && $countAbsolute > $limit) { + $countAbsolute = $limit; } $maxPage = ceil($countAbsolute / $pageSize); @@ -217,8 +229,8 @@ public function requestAllChunked( // will be the same as the take parameter $elements = $response->json($resultPath); $elementCount += count($elements ?? []); - if ($take > -1 && $elementCount > $take) { - $elements = array_slice($elements, 0, $take - $elementCount); + if ($limit > -1 && $elementCount > $limit) { + $elements = array_slice($elements, 0, $limit - $elementCount); } $callback($elements); diff --git a/tests/Dtos/OnOfficeResponsePageTest.php b/tests/Dtos/OnOfficeResponsePageTest.php new file mode 100644 index 0000000..36f5571 --- /dev/null +++ b/tests/Dtos/OnOfficeResponsePageTest.php @@ -0,0 +1,69 @@ +push(EstateFactory::make()->id(4)); + + $page = new OnOfficeResponsePage( + OnOfficeAction::Read, + OnOfficeResourceType::Estate, + $recordFactories, + 201, + 1, + 'foo', + OnOfficeResourceId::Estate, + false, + '21', + 1, + 2, + 'nar', + ); + + $response = $page->toResponse(); + + expect($response)->toBeArray() + ->toBe([ + 'status' => [ + 'code' => 201, + 'errorcode' => 1, + 'message' => 'foo', + ], + 'response' => [ + 'results' => [ + [ + 'actionid' => OnOfficeAction::Read->value, + 'resourceid' => OnOfficeResourceId::Estate->value, + 'resourcetype' => OnOfficeResourceType::Estate->value, + 'cacheable' => false, + 'identifier' => '21', + 'data' => [ + 'meta' => [ + 'cntabsolute' => 1, + ], + 'records' => [ + [ + 'id' => 4, + 'type' => 'estate', + 'elements' => [], + ], + ], + ], + 'status' => [ + 'errorcode' => 2, + 'message' => 'nar', + ], + ], + ], + ], + ]); +}); diff --git a/tests/Dtos/OnOfficeResponseTest.php b/tests/Dtos/OnOfficeResponseTest.php new file mode 100644 index 0000000..122b434 --- /dev/null +++ b/tests/Dtos/OnOfficeResponseTest.php @@ -0,0 +1,27 @@ +push(EstateFactory::make()->id(4)); + + $page = new OnOfficeResponsePage( + OnOfficeAction::Read, + OnOfficeResourceType::Estate, + $recordFactories, + ); + + $response = new OnOfficeResponse(collect([$page])); + + expect($response->shift())->toBeInstanceOf(OnOfficeResponsePage::class) + ->and($response->isEmpty())->toBeTrue(); +}); diff --git a/tests/Query/AcitvityBuilderTest.php b/tests/Query/AcitvityBuilderTest.php deleted file mode 100644 index 060473c..0000000 --- a/tests/Query/AcitvityBuilderTest.php +++ /dev/null @@ -1,26 +0,0 @@ - Http::sequence([ - ReadActivityResponse::make(activityId: 1, count: 1500), - ReadActivityResponse::make(activityId: 2, count: 1500), - ReadActivityResponse::make(activityId: 3, count: 1500), - ]), - ]); - - $activities = ActivityRepository::query() - ->get(); - - expect($activities) - ->toHaveCount(3) - ->and($activities->first()['id'])->toBe(1) - ->and($activities->last()['id'])->toBe(3); -}); diff --git a/tests/Query/AddressBuilderTest.php b/tests/Query/AddressBuilderTest.php index 9511c7f..85c32f2 100644 --- a/tests/Query/AddressBuilderTest.php +++ b/tests/Query/AddressBuilderTest.php @@ -3,35 +3,17 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\AddressRepository; +use Katalam\OnOfficeAdapter\Facades\EstateRepository; use Katalam\OnOfficeAdapter\Query\AddressBuilder; +use Katalam\OnOfficeAdapter\Repositories\AddressRepository; use Katalam\OnOfficeAdapter\Services\OnOfficeService; use Katalam\OnOfficeAdapter\Tests\Stubs\CreateAddressResponse; use Katalam\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; -it('works', function () { - Http::preventStrayRequests(); - Http::fake([ - '*' => Http::sequence([ - // Each response will have 600 estates to simulate pagination - ReadAddressResponse::make(addressId: 1, count: 1500), - ReadAddressResponse::make(addressId: 2, count: 1500), - ReadAddressResponse::make(addressId: 3, count: 1500), - ]), - ]); - - $addresses = AddressRepository::query() - ->get(); - - expect($addresses) - ->toHaveCount(3) - ->and($addresses->first()['id'])->toBe(1) - ->and($addresses->last()['id'])->toBe(3); -}); - describe('recordIds', function () { it('should set the recordIds property to the given recordIds', function () { - $builder = new AddressBuilder(app(OnOfficeService::class)); + $builder = new AddressBuilder; + $builder->setRepository(app(AddressRepository::class)); $builder->recordIds([1]); @@ -39,7 +21,8 @@ }); it('should wrap the given recordIds in an array if it is a int', function () { - $builder = new AddressBuilder(app(OnOfficeService::class)); + $builder = new AddressBuilder; + $builder->setRepository(app(AddressRepository::class)); $builder->recordIds(1); @@ -47,7 +30,8 @@ }); it('should return the builder instance', function () { - $builder = new AddressBuilder(app(OnOfficeService::class)); + $builder = new AddressBuilder; + $builder->setRepository(app(AddressRepository::class)); $result = $builder->recordIds([1]); @@ -55,7 +39,8 @@ }); it('should add the given recordId to the recordIds property', function () { - $builder = new AddressBuilder(app(OnOfficeService::class)); + $builder = new AddressBuilder; + $builder->setRepository(app(AddressRepository::class)); $builder->recordIds([1]); $builder->addRecordIds([2]); @@ -64,7 +49,8 @@ }); it('should wrap the given recordId in an array if it is a int', function () { - $builder = new AddressBuilder(app(OnOfficeService::class)); + $builder = new AddressBuilder; + $builder->setRepository(app(AddressRepository::class)); $builder->recordIds([1]); $builder->addRecordIds(2); @@ -75,29 +61,11 @@ describe('customParameters', function () { it('should set the country iso code type property to the given type', function () { - $builder = new AddressBuilder(app(OnOfficeService::class)); + $builder = new AddressBuilder; + $builder->setRepository(app(AddressRepository::class)); $builder->addCountryIsoCodeType('ISO-3166-2'); expect($builder->customParameters['countryIsoCodeType'])->toBe('ISO-3166-2'); }); }); - -describe('create', function () { - it('works', function () { - Http::preventStrayRequests(); - Http::fake([ - '*' => Http::sequence([ - // Each response will have 600 estates to simulate pagination - CreateAddressResponse::make(addressId: 1), - ]), - ]); - - $address = AddressRepository::query() - ->create([]); - - expect($address) - ->toBeArray() - ->and(data_get($address, 'id'))->toBe(1); - }); -}); diff --git a/tests/Query/BuilderTest.php b/tests/Query/BuilderTest.php index 38d9086..35b73a4 100644 --- a/tests/Query/BuilderTest.php +++ b/tests/Query/BuilderTest.php @@ -212,33 +212,7 @@ public function modify(int $id): bool $builder->limit(-10); - expect($builder->limit)->toBe(0); - }); -}); - -describe('take', function () { - it('should set the take property to the given value', function () { - $builder = new Builder; - - $builder->take(10); - - expect($builder->take)->toBe(10); - }); - - it('should return the builder instance', function () { - $builder = new Builder; - - $result = $builder->take(10); - - expect($result)->toBeInstanceOf(Builder::class); - }); - - it('should not allow negative values', function () { - $builder = new Builder; - - $builder->take(-10); - - expect($builder->take)->toBe(-1); + expect($builder->limit)->toBe(-1); }); }); diff --git a/tests/Query/EstateBuilderTest.php b/tests/Query/EstateBuilderTest.php deleted file mode 100644 index cbdd99a..0000000 --- a/tests/Query/EstateBuilderTest.php +++ /dev/null @@ -1,27 +0,0 @@ - Http::sequence([ - // Each response will have 600 estates to simulate pagination - ReadEstateResponse::make(estateId: 1, count: 1500), - ReadEstateResponse::make(estateId: 2, count: 1500), - ReadEstateResponse::make(estateId: 3, count: 1500), - ]), - ]); - - $estates = EstateRepository::query() - ->get(); - - expect($estates) - ->toHaveCount(3) - ->and($estates->first()['id'])->toBe(1) - ->and($estates->last()['id'])->toBe(3); -}); diff --git a/tests/Query/EstateFileBuilderTest.php b/tests/Query/EstateFileBuilderTest.php deleted file mode 100644 index 919501b..0000000 --- a/tests/Query/EstateFileBuilderTest.php +++ /dev/null @@ -1,25 +0,0 @@ - Http::sequence([ - // Each response will have 600 estates to simulate pagination - GetEstatePicturesResponse::make(count: 1500), - GetEstatePicturesResponse::make(count: 1500), - GetEstatePicturesResponse::make(count: 1500), - ]), - ]); - - $estates = EstateRepository::files(1) - ->get(); - - expect($estates) - ->toHaveCount(6); -}); diff --git a/tests/Query/FieldBuilderTest.php b/tests/Query/FieldBuilderTest.php index 87b4dcd..84901bb 100644 --- a/tests/Query/FieldBuilderTest.php +++ b/tests/Query/FieldBuilderTest.php @@ -3,29 +3,15 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\FieldRepository; use Katalam\OnOfficeAdapter\Query\FieldBuilder; +use Katalam\OnOfficeAdapter\Repositories\FieldRepository; use Katalam\OnOfficeAdapter\Services\OnOfficeService; use Katalam\OnOfficeAdapter\Tests\Stubs\GetFieldsResponse; -it('works', function () { - Http::preventStrayRequests(); - Http::fake([ - '*' => Http::sequence([ - GetFieldsResponse::make(), - ]), - ]); - - $fields = FieldRepository::query() - ->get(); - - expect($fields) - ->toHaveCount(13); -}); - describe('withModules', function () { it('should set the modules property to the given modules', function () { - $builder = new FieldBuilder(app(OnOfficeService::class)); + $builder = new FieldBuilder; + $builder->setRepository(app(FieldRepository::class)); $builder->withModules(['estate']); @@ -33,7 +19,8 @@ }); it('should wrap the given modules in an array if it is a string', function () { - $builder = new FieldBuilder(app(OnOfficeService::class)); + $builder = new FieldBuilder; + $builder->setRepository(app(FieldRepository::class)); $builder->withModules('estate'); @@ -41,7 +28,8 @@ }); it('should return the builder instance', function () { - $builder = new FieldBuilder(app(OnOfficeService::class)); + $builder = new FieldBuilder; + $builder->setRepository(app(FieldRepository::class)); $result = $builder->withModules('estate'); @@ -49,7 +37,8 @@ }); it('should add multiple modules to the modules property', function () { - $builder = new FieldBuilder(app(OnOfficeService::class)); + $builder = new FieldBuilder; + $builder->setRepository(app(FieldRepository::class)); $builder->withModules('estate'); $builder->withModules('address'); diff --git a/tests/Query/ImprintBuilderTest.php b/tests/Query/ImprintBuilderTest.php deleted file mode 100644 index b1b9d95..0000000 --- a/tests/Query/ImprintBuilderTest.php +++ /dev/null @@ -1,22 +0,0 @@ - GetImprintResponse::make(), - ]); - - $imprint = SettingRepository::imprint() - ->get(); - - expect($imprint) - ->toHaveCount(1) - ->and(data_get($imprint, '0.elements.firstname')) - ->toBe('Max'); -}); diff --git a/tests/Query/MarketplaceBuilderTest.php b/tests/Query/MarketplaceBuilderTest.php deleted file mode 100644 index 69e1994..0000000 --- a/tests/Query/MarketplaceBuilderTest.php +++ /dev/null @@ -1,19 +0,0 @@ - DoUnlockProviderResponse::make(), - ]); - - $success = MarketplaceRepository::query() - ->unlockProvider('foo', 'bar'); - - expect($success)->toBeTrue(); -}); diff --git a/tests/Query/RegionBuilderTest.php b/tests/Query/RegionBuilderTest.php deleted file mode 100644 index 64f3050..0000000 --- a/tests/Query/RegionBuilderTest.php +++ /dev/null @@ -1,22 +0,0 @@ - GetRegionsResponse::make(), - ]); - - $regions = SettingRepository::regions() - ->get(); - - expect($regions) - ->toHaveCount(1) - ->and(data_get($regions, '0.elements.children')) - ->toHaveCount(2); -}); diff --git a/tests/Query/RelationBuilderTest.php b/tests/Query/RelationBuilderTest.php index d7636fa..ab03c9e 100644 --- a/tests/Query/RelationBuilderTest.php +++ b/tests/Query/RelationBuilderTest.php @@ -2,32 +2,14 @@ declare(strict_types=1); -use Illuminate\Support\Facades\Http; use Katalam\OnOfficeAdapter\Enums\OnOfficeRelationType; -use Katalam\OnOfficeAdapter\Facades\RelationRepository; use Katalam\OnOfficeAdapter\Query\RelationBuilder; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetEstateAgentsResponse; - -it('works', function () { - Http::preventStrayRequests(); - Http::fake([ - '*' => GetEstateAgentsResponse::make(), - ]); - - $agents = RelationRepository::query() - ->relationType(OnOfficeRelationType::ContactPersonBroker) - ->get(); - - expect($agents) - ->toHaveCount(6) - ->and($agents->first()[0])->toBe('2169') - ->and($agents->first()[1])->toBe('2205'); -}); +use Katalam\OnOfficeAdapter\Repositories\RelationRepository; describe('childIds', function () { it('should set the childIds property to the given childIds', function () { - $builder = new RelationBuilder(app(OnOfficeService::class)); + $builder = new RelationBuilder; + $builder->setRepository(app(RelationRepository::class)); $builder->childIds([1]); @@ -35,7 +17,8 @@ }); it('should wrap the given childIds in an array if it is a int', function () { - $builder = new RelationBuilder(app(OnOfficeService::class)); + $builder = new RelationBuilder; + $builder->setRepository(app(RelationRepository::class)); $builder->childIds(1); @@ -43,7 +26,8 @@ }); it('should return the builder instance', function () { - $builder = new RelationBuilder(app(OnOfficeService::class)); + $builder = new RelationBuilder; + $builder->setRepository(app(RelationRepository::class)); $result = $builder->childIds([1]); @@ -51,7 +35,8 @@ }); it('should add the given childId to the childIds property', function () { - $builder = new RelationBuilder(app(OnOfficeService::class)); + $builder = new RelationBuilder; + $builder->setRepository(app(RelationRepository::class)); $builder->childIds([1]); $builder->addChildIds([2]); @@ -60,7 +45,8 @@ }); it('should wrap the given childId in an array if it is a int', function () { - $builder = new RelationBuilder(app(OnOfficeService::class)); + $builder = new RelationBuilder; + $builder->setRepository(app(RelationRepository::class)); $builder->childIds([1]); $builder->addChildIds(2); @@ -71,7 +57,8 @@ describe('parentIds', function () { it('should set the parentIds property to the given parentIds', function () { - $builder = new RelationBuilder(app(OnOfficeService::class)); + $builder = new RelationBuilder; + $builder->setRepository(app(RelationRepository::class)); $builder->parentIds([1]); @@ -79,7 +66,8 @@ }); it('should wrap the given parentIds in an array if it is a int', function () { - $builder = new RelationBuilder(app(OnOfficeService::class)); + $builder = new RelationBuilder; + $builder->setRepository(app(RelationRepository::class)); $builder->parentIds(1); @@ -87,7 +75,8 @@ }); it('should return the builder instance', function () { - $builder = new RelationBuilder(app(OnOfficeService::class)); + $builder = new RelationBuilder; + $builder->setRepository(app(RelationRepository::class)); $result = $builder->parentIds([1]); @@ -95,7 +84,8 @@ }); it('should add the given parentId to the parentIds property', function () { - $builder = new RelationBuilder(app(OnOfficeService::class)); + $builder = new RelationBuilder; + $builder->setRepository(app(RelationRepository::class)); $builder->parentIds([1]); $builder->addParentIds([2]); @@ -104,7 +94,8 @@ }); it('should wrap the given parentId in an array if it is a int', function () { - $builder = new RelationBuilder(app(OnOfficeService::class)); + $builder = new RelationBuilder; + $builder->setRepository(app(RelationRepository::class)); $builder->parentIds([1]); $builder->addParentIds(2); @@ -115,7 +106,8 @@ describe('relationType', function () { it('should set the relationType property to the given relationType', function () { - $builder = new RelationBuilder(app(OnOfficeService::class)); + $builder = new RelationBuilder; + $builder->setRepository(app(RelationRepository::class)); $builder->relationType(OnOfficeRelationType::Buyer); @@ -123,7 +115,8 @@ }); it('should return the builder instance', function () { - $builder = new RelationBuilder(app(OnOfficeService::class)); + $builder = new RelationBuilder; + $builder->setRepository(app(RelationRepository::class)); $result = $builder->relationType(OnOfficeRelationType::Buyer); diff --git a/tests/Query/UploadBuilderTest.php b/tests/Query/UploadBuilderTest.php index f3cf5d5..730b901 100644 --- a/tests/Query/UploadBuilderTest.php +++ b/tests/Query/UploadBuilderTest.php @@ -5,6 +5,7 @@ use Illuminate\Http\Client\Request; use Illuminate\Support\Facades\Http; use Katalam\OnOfficeAdapter\Query\UploadBuilder; +use Katalam\OnOfficeAdapter\Repositories\FileRepository; use Katalam\OnOfficeAdapter\Services\OnOfficeService; use Katalam\OnOfficeAdapter\Tests\Stubs\LinkDataResponse; use Katalam\OnOfficeAdapter\Tests\Stubs\UploadFileResponse; @@ -17,7 +18,8 @@ '*' => UploadFileResponse::make(), ]); - $builder = new UploadBuilder(app(OnOfficeService::class)); + $builder = new UploadBuilder; + $builder->setRepository(app(FileRepository::class)); $tmpUploadId = $builder->save(base64_encode('test')); @@ -34,7 +36,8 @@ ]), ]); - $builder = new UploadBuilder(app(OnOfficeService::class)); + $builder = new UploadBuilder; + $builder->setRepository(app(FileRepository::class)); $tmpUploadId = $builder ->uploadInBlocks(4) // test as base64 string has 8 characters @@ -52,7 +55,8 @@ '*' => LinkDataResponse::make(), ]); - $builder = new UploadBuilder(app(OnOfficeService::class)); + $builder = new UploadBuilder; + $builder->setRepository(app(FileRepository::class)); $builder->link('a17ebec0-48f9-44cc-8629-f49ccc68f2d2', [ 'module' => 'estate', @@ -76,7 +80,8 @@ ]), ]); - $builder = new UploadBuilder(app(OnOfficeService::class)); + $builder = new UploadBuilder; + $builder->setRepository(app(FileRepository::class)); $builder->saveAndLink(base64_encode('test'), [ 'module' => 'estate', diff --git a/tests/Query/UserBuilderTest.php b/tests/Query/UserBuilderTest.php deleted file mode 100644 index 80237c2..0000000 --- a/tests/Query/UserBuilderTest.php +++ /dev/null @@ -1,27 +0,0 @@ - Http::sequence([ - // Each response will have 1500 users to simulate pagination - ReadUserResponse::make(userId: 1, count: 1500), - ReadUserResponse::make(userId: 2, count: 1500), - ReadUserResponse::make(userId: 3, count: 1500), - ]), - ]); - - $users = SettingRepository::users() - ->get(); - - expect($users) - ->toHaveCount(3) - ->and($users->first()['id'])->toBe(1) - ->and($users->last()['id'])->toBe(3); -}); diff --git a/tests/Repositories/ActivityRepositoryTest.php b/tests/Repositories/ActivityRepositoryTest.php new file mode 100644 index 0000000..1d2d528 --- /dev/null +++ b/tests/Repositories/ActivityRepositoryTest.php @@ -0,0 +1,49 @@ +id(1), + ]), + ])); + + $response = ActivityRepository::query()->get(); + + expect($response->count())->toBe(1) + ->and($response->first()['id'])->toBe(1); + + ActivityRepository::assertSentCount(1); + }); +}); + +describe('real responses', function () { + test('get', function () { + Http::preventStrayRequests(); + Http::fake([ + 'https://api.onoffice.de/api/stable/api.php/' => Http::sequence([ + ReadActivityResponse::make(count: 1500), + ReadActivityResponse::make(count: 1500), + ReadActivityResponse::make(count: 1500), + ]), + ]); + + ActivityRepository::record(); + + $response = ActivityRepository::query()->get(); + + expect($response->count())->toBe(3); + + ActivityRepository::assertSentCount(3); + }); +}); diff --git a/tests/Repositories/AddressRepositoryTest.php b/tests/Repositories/AddressRepositoryTest.php new file mode 100644 index 0000000..bee2967 --- /dev/null +++ b/tests/Repositories/AddressRepositoryTest.php @@ -0,0 +1,48 @@ +id(1), + ]), + ])); + + $response = AddressRepository::query()->get(); + + expect($response->count())->toBe(1) + ->and($response->first()['id'])->toBe(1); + + AddressRepository::assertSentCount(1); + }); +}); + +describe('real responses', function () { + test('get', function () { + Http::preventStrayRequests(); + Http::fake([ + 'https://api.onoffice.de/api/stable/api.php/' => Http::sequence([ + ReadAddressResponse::make(count: 1500), + ReadAddressResponse::make(count: 1500), + ReadAddressResponse::make(count: 1500), + ]), + ]); + + AddressRepository::record(); + + $response = AddressRepository::query()->get(); + + expect($response->count())->toBe(3); + + AddressRepository::assertSentCount(3); + }); +}); diff --git a/tests/Repositories/BaseRepositoryTest.php b/tests/Repositories/BaseRepositoryTest.php new file mode 100644 index 0000000..c9359ec --- /dev/null +++ b/tests/Repositories/BaseRepositoryTest.php @@ -0,0 +1,202 @@ +preventStrayRequests(); + + $m = new ReflectionProperty($builder, 'preventStrayRequests'); + $m->setAccessible(true); + + expect($m->getValue($builder))->toBe(true); + }); + + it('will set the preventStrayRequests property when calling preventStrayRequests with values', function ($value) { + $builder = new BaseRepository; + + $builder->preventStrayRequests($value); + + $m = new ReflectionProperty($builder, 'preventStrayRequests'); + $m->setAccessible(true); + + expect($m->getValue($builder))->toBe($value); + })->with([true, false]); + + it('will set the preventStrayRequest property when calling allowStrayRequests', function () { + $builder = new BaseRepository; + + $builder->preventStrayRequests(); + $builder->preventStrayRequests(false); + + $m = new ReflectionProperty($builder, 'preventStrayRequests'); + $m->setAccessible(true); + + expect($m->getValue($builder))->toBe(false); + }); +}); + +describe('record', function () { + it('will set the recording property when calling record default', function () { + $builder = new BaseRepository; + + $builder->record(); + + $m = new ReflectionProperty($builder, 'recording'); + $m->setAccessible(true); + + expect($m->getValue($builder))->toBe(true); + }); + + it('will set the recording property when calling stop recording', function () { + $builder = new BaseRepository; + + $builder->record(); + $builder->stopRecording(); + + $m = new ReflectionProperty($builder, 'recording'); + $m->setAccessible(true); + + expect($m->getValue($builder))->toBe(false); + }); + + it('will set the recording property when calling record with values', function ($value) { + $builder = new BaseRepository; + + $builder->record($value); + + $m = new ReflectionProperty($builder, 'recording'); + $m->setAccessible(true); + + expect($m->getValue($builder))->toBe($value); + })->with([true, false]); + + it('will add the request and response to the recorded property', function () { + $builder = new BaseRepository; + + $builder->record(); + $builder->recordRequestResponsePair(new OnOfficeRequest(OnOfficeAction::Read, OnOfficeResourceType::Estate), ['response']); + + $m = new ReflectionProperty($builder, 'recorded'); + $m->setAccessible(true); + + expect($m->getValue($builder))->toBeArray() + ->and($m->getValue($builder)[0][0]->toArray())->toBe((new OnOfficeRequest(OnOfficeAction::Read, OnOfficeResourceType::Estate))->toArray()) + ->and($m->getValue($builder)[0][1])->toBe(['response']); + }); + + it('will not add the request and response to the recorded property when recording is off', function () { + $builder = new BaseRepository; + + $builder->recordRequestResponsePair(new OnOfficeRequest(OnOfficeAction::Read, OnOfficeResourceType::Estate), ['response']); + + $m = new ReflectionProperty($builder, 'recorded'); + $m->setAccessible(true); + + expect($m->getValue($builder))->toBe([]); + }); +}); + +describe('fake', function () { + it('will add the response to the stubCallables property', function () { + $builder = new BaseRepository; + + $builder->fake(new OnOfficeResponse(collect())); + + $m = new ReflectionProperty($builder, 'stubCallables'); + $m->setAccessible(true); + + expect($m->getValue($builder)->toArray()[0])->toBeInstanceOf(OnOfficeResponse::class); + }); + + it('will add the response to the stubCallables property when calling fake with an array', function () { + $builder = new BaseRepository; + + $builder->fake([new OnOfficeResponse(collect())]); + + $m = new ReflectionProperty($builder, 'stubCallables'); + $m->setAccessible(true); + + expect($m->getValue($builder)->toArray()[0])->toBeInstanceOf(OnOfficeResponse::class); + }); +}); + +describe('assert', function () { + it('can find a record by callable', function () { + $builder = new BaseRepository; + + $builder->record(); + $builder->recordRequestResponsePair(new OnOfficeRequest(OnOfficeAction::Read, OnOfficeResourceType::Estate), ['response']); + + $filteredRecordings = $builder->recorded(function (OnOfficeRequest $request, array $response) { + return $request->actionId === OnOfficeAction::Read; + }); + + expect($filteredRecordings)->toBeInstanceOf(Collection::class) + ->and($filteredRecordings[0][0]->toArray())->toBe((new OnOfficeRequest(OnOfficeAction::Read, OnOfficeResourceType::Estate))->toArray()) + ->and($filteredRecordings[0][1])->toBe(['response']); + }); + + it('can assert sent', function () { + $builder = new BaseRepository; + + $builder->record(); + $builder->recordRequestResponsePair(new OnOfficeRequest(OnOfficeAction::Read, OnOfficeResourceType::Estate), ['response']); + + $builder->assertSent(function (OnOfficeRequest $request) { + return $request->actionId === OnOfficeAction::Read; + }); + }); + + it('can assert sent with a response', function () { + $builder = new BaseRepository; + + $builder->record(); + $builder->recordRequestResponsePair(new OnOfficeRequest(OnOfficeAction::Read, OnOfficeResourceType::Estate), ['response']); + + $builder->assertSent(function (OnOfficeRequest $request, array $response) { + return $request->actionId === OnOfficeAction::Read && $response === ['response']; + }); + }); + + it('can assert not sent', function () { + $builder = new BaseRepository; + + $builder->record(); + $builder->recordRequestResponsePair(new OnOfficeRequest(OnOfficeAction::Read, OnOfficeResourceType::Estate), ['response']); + + $builder->assertNotSent(function (OnOfficeRequest $request) { + return $request->actionId === OnOfficeAction::Create; + }); + }); + + it('can assert not sent with a response', function () { + $builder = new BaseRepository; + + $builder->record(); + $builder->recordRequestResponsePair(new OnOfficeRequest(OnOfficeAction::Read, OnOfficeResourceType::Estate), ['response']); + + $builder->assertNotSent(function (OnOfficeRequest $request, array $response) { + return $request->actionId === OnOfficeAction::Create && $response === ['response']; + }); + }); + + it('can assert sent count', function () { + $builder = new BaseRepository; + + $builder->record(); + $builder->recordRequestResponsePair(new OnOfficeRequest(OnOfficeAction::Read, OnOfficeResourceType::Estate), ['response']); + $builder->recordRequestResponsePair(new OnOfficeRequest(OnOfficeAction::Read, OnOfficeResourceType::Estate), ['response']); + + $builder->assertSentCount(2); + }); +}); diff --git a/tests/Repositories/EstateFileRepositoryTest.php b/tests/Repositories/EstateFileRepositoryTest.php new file mode 100644 index 0000000..6c9efbd --- /dev/null +++ b/tests/Repositories/EstateFileRepositoryTest.php @@ -0,0 +1,53 @@ +id(1), + ]), + ])); + + $response = EstateRepository::files(1)->get(); + + expect($response->count())->toBe(1) + ->and($response->first()['id'])->toBe(1); + + EstateRepository::assertSentCount(1); + }); +}); + +describe('real responses', function () { + test('get', function () { + Http::preventStrayRequests(); + Http::fake([ + 'https://api.onoffice.de/api/stable/api.php/' => Http::sequence([ + GetEstatePicturesResponse::make(count: 1500), + GetEstatePicturesResponse::make(count: 1500), + GetEstatePicturesResponse::make(count: 1500), + ]), + ]); + + EstateRepository::record(); + + $response = EstateRepository::files(1)->get(); + + expect($response->count())->toBe(6); + + EstateRepository::assertSentCount(3); + }); +}); diff --git a/tests/Repositories/EstateRepositoryTest.php b/tests/Repositories/EstateRepositoryTest.php new file mode 100644 index 0000000..874143d --- /dev/null +++ b/tests/Repositories/EstateRepositoryTest.php @@ -0,0 +1,51 @@ +id(1), + ]), + ])); + + $response = EstateRepository::query()->get(); + + expect($response->count())->toBe(1) + ->and($response->first()['id'])->toBe(1); + + EstateRepository::assertSentCount(1); + }); +}); + +describe('real responses', function () { + test('get', function () { + Http::preventStrayRequests(); + Http::fake([ + 'https://api.onoffice.de/api/stable/api.php/' => Http::sequence([ + ReadEstateResponse::make(count: 1500), + ReadEstateResponse::make(count: 1500), + ReadEstateResponse::make(count: 1500), + ]), + ]); + + EstateRepository::record(); + + $response = EstateRepository::query()->get(); + + expect($response->count())->toBe(3); + + EstateRepository::assertSentCount(3); + }); +}); diff --git a/tests/Repositories/FieldRepositoryTest.php b/tests/Repositories/FieldRepositoryTest.php new file mode 100644 index 0000000..c89abaf --- /dev/null +++ b/tests/Repositories/FieldRepositoryTest.php @@ -0,0 +1,52 @@ +id(1), + ]), + ])); + + $response = FieldRepository::query()->get(); + + expect($response->count())->toBe(1) + ->and($response->first()['id'])->toBe(1); + + FieldRepository::assertSentCount(1); + }); +}); + +describe('real responses', function () { + test('get', function () { + Http::preventStrayRequests(); + Http::fake([ + 'https://api.onoffice.de/api/stable/api.php/' => Http::sequence([ + GetFieldsResponse::make(), + ]), + ]); + + FieldRepository::record(); + + $response = FieldRepository::query()->get(); + + expect($response->count())->toBe(13); + + FieldRepository::assertSentCount(1); + }); +}); diff --git a/tests/Repositories/ImprintRepositoryTest.php b/tests/Repositories/ImprintRepositoryTest.php new file mode 100644 index 0000000..16acf16 --- /dev/null +++ b/tests/Repositories/ImprintRepositoryTest.php @@ -0,0 +1,55 @@ +id(1), + ]), + ])); + + $response = SettingRepository::imprint()->get(); + + expect($response->count())->toBe(1) + ->and($response->first()['id'])->toBe(1); + + SettingRepository::assertSentCount(1); + }); +}); + +describe('real responses', function () { + test('get', function () { + Http::preventStrayRequests(); + Http::fake([ + 'https://api.onoffice.de/api/stable/api.php/' => Http::sequence([ + GetImprintResponse::make(), + ]), + ]); + + SettingRepository::record(); + + $response = SettingRepository::imprint()->get(); + + expect($response->count())->toBe(1); + + SettingRepository::assertSentCount(1); + }); +}); diff --git a/tests/Repositories/MarketplaceRepositoryTest.php b/tests/Repositories/MarketplaceRepositoryTest.php new file mode 100644 index 0000000..55ca05e --- /dev/null +++ b/tests/Repositories/MarketplaceRepositoryTest.php @@ -0,0 +1,46 @@ +unlockProvider('foo', 'bar'); + + MarketplaceRepository::assertSentCount(1); + }); +}); + +describe('real responses', function () { + test('get', function () { + Http::preventStrayRequests(); + Http::fake([ + 'https://api.onoffice.de/api/stable/api.php/' => Http::sequence([ + DoUnlockProviderResponse::make(), + ]), + ]); + + MarketplaceRepository::record(); + + MarketplaceRepository::query()->unlockProvider('foo', 'bar'); + + MarketplaceRepository::assertSentCount(1); + }); +}); diff --git a/tests/Repositories/RegionRepositoryTest.php b/tests/Repositories/RegionRepositoryTest.php new file mode 100644 index 0000000..0454156 --- /dev/null +++ b/tests/Repositories/RegionRepositoryTest.php @@ -0,0 +1,57 @@ +id(1), + ]), + ])); + + $response = SettingRepository::regions()->get(); + + expect($response->count())->toBe(1) + ->and($response->first()['id'])->toBe(1); + + SettingRepository::assertSentCount(1); + }); +}); + +describe('real responses', function () { + test('get', function () { + Http::preventStrayRequests(); + Http::fake([ + 'https://api.onoffice.de/api/stable/api.php/' => Http::sequence([ + GetRegionsResponse::make(), + ]), + ]); + + SettingRepository::record(); + + $response = SettingRepository::regions()->get(); + + expect($response->count())->toBe(1); + + SettingRepository::assertSentCount(1); + }); +}); diff --git a/tests/Repositories/RelationRepositoryTest.php b/tests/Repositories/RelationRepositoryTest.php new file mode 100644 index 0000000..c0a16bd --- /dev/null +++ b/tests/Repositories/RelationRepositoryTest.php @@ -0,0 +1,61 @@ +data([ + 5779 => [ + '2169', + '2205', + ], + ]), + ]), + ])); + + $response = RelationRepository::query() + ->relationType(OnOfficeRelationType::ContactPersonBroker) + ->get(); + + expect($response->count())->toBe(1); + + RelationRepository::assertSentCount(1); + }); +}); + +describe('real responses', function () { + test('get', function () { + Http::preventStrayRequests(); + Http::fake([ + 'https://api.onoffice.de/api/stable/api.php/' => Http::sequence([ + GetEstateAgentsResponse::make(), + ]), + ]); + + RelationRepository::record(); + + $response = RelationRepository::query() + ->relationType(OnOfficeRelationType::ContactPersonBroker) + ->get(); + + expect($response->count())->toBe(6); + + RelationRepository::assertSentCount(1); + }); +}); diff --git a/tests/Repositories/SearchCriteriaRepositoryTest.php b/tests/Repositories/SearchCriteriaRepositoryTest.php new file mode 100644 index 0000000..9172368 --- /dev/null +++ b/tests/Repositories/SearchCriteriaRepositoryTest.php @@ -0,0 +1,54 @@ +find(1); + + expect($response)->toBe([ + 'id' => 0, + 'type' => '', + 'elements' => [], + ]); + + SearchCriteriaRepository::assertSentCount(1); + }); +}); + +describe('real responses', function () { + test('get', function () { + Http::preventStrayRequests(); + Http::fake([ + 'https://api.onoffice.de/api/stable/api.php/' => Http::sequence([ + GetSearchCriteriaResponse::make(), + ]), + ]); + + SearchCriteriaRepository::record(); + + $response = SearchCriteriaRepository::query()->find(1); + + expect($response)->toBe([]); + + SearchCriteriaRepository::assertSentCount(1); + }); +}); diff --git a/tests/Repositories/UploadRepositoryTest.php b/tests/Repositories/UploadRepositoryTest.php new file mode 100644 index 0000000..686471b --- /dev/null +++ b/tests/Repositories/UploadRepositoryTest.php @@ -0,0 +1,57 @@ +data([ + 'tmpUploadId' => 'abc', + ]), + ]), + ])); + + FileRepository::query()->save('abc'); + + FileRepository::assertSentCount(1); + }); +}); + +describe('real responses', function () { + test('get', function () { + Http::preventStrayRequests(); + Http::fake([ + 'https://api.onoffice.de/api/stable/api.php/' => Http::sequence([ + UploadFileResponse::make(), + ]), + ]); + + FileRepository::record(); + + FileRepository::query()->save('abc'); + + FileRepository::assertSentCount(1); + }); +}); diff --git a/tests/Repositories/UserRepositoryTest.php b/tests/Repositories/UserRepositoryTest.php new file mode 100644 index 0000000..e65abc6 --- /dev/null +++ b/tests/Repositories/UserRepositoryTest.php @@ -0,0 +1,57 @@ +id(1), + ]), + ])); + + $response = SettingRepository::users()->get(); + + expect($response->count())->toBe(1) + ->and($response->first()['id'])->toBe(1); + + SettingRepository::assertSentCount(1); + }); +}); + +describe('real responses', function () { + test('get', function () { + Http::preventStrayRequests(); + Http::fake([ + 'https://api.onoffice.de/api/stable/api.php/' => Http::sequence([ + ReadUserResponse::make(), + ]), + ]); + + SettingRepository::record(); + + $response = SettingRepository::users()->get(); + + expect($response->count())->toBe(1); + + SettingRepository::assertSentCount(1); + }); +}); diff --git a/tests/Services/OnOfficeServiceTest.php b/tests/Services/OnOfficeServiceTest.php index 7c891fd..2749f24 100644 --- a/tests/Services/OnOfficeServiceTest.php +++ b/tests/Services/OnOfficeServiceTest.php @@ -159,7 +159,7 @@ OnOfficeResourceType::Estate, ); }); - })->with([300, 301, 400, 401, 500, 501]); + })->with([300, 301, 400, 401, 500, 501])->throws(OnOfficeException::class); it('can handle null in result path', function () { Http::preventStrayRequests(); @@ -234,7 +234,7 @@ OnOfficeAction::Get, OnOfficeResourceType::Estate, ); - }, take: 1); + }, limit: 1); expect($response)->toBeInstanceOf(Collection::class) ->toHaveCount(1); @@ -265,7 +265,7 @@ OnOfficeResourceType::Estate, ); }, function () {}); - })->with([300, 301, 400, 401, 500, 501]); + })->with([300, 301, 400, 401, 500, 501])->throws(OnOfficeException::class); it('will call the callback', function () { Http::fake([ @@ -333,7 +333,7 @@ ); }, function ($elements) use (&$count) { $count += count($elements); - }, take: 1); + }, limit: 1); expect($count)->toBe(1); }); @@ -403,7 +403,7 @@ ); }, function ($elements) use (&$count) { $count += count($elements); - }, pageSize: 2, take: 3); + }, pageSize: 2, limit: 3); expect($count)->toBe(3); }); diff --git a/tests/Stubs/GetSearchCriteriaResponse.php b/tests/Stubs/GetSearchCriteriaResponse.php new file mode 100644 index 0000000..e5ff592 --- /dev/null +++ b/tests/Stubs/GetSearchCriteriaResponse.php @@ -0,0 +1,51 @@ + [ + 'code' => 200, + 'errorcode' => 0, + 'message' => 'OK', + ], + 'response' => [ + 'results' => [ + [ + 'actionid' => 'urn:onoffice-de-ns:smart:2.5:smartml:action:get', + 'resourceid' => '', + 'resourcetype' => 'searchcriterias', + 'cacheable' => true, + 'identifier' => '', + 'data' => [ + 'meta' => [ + 'cntabsolute' => null, + ], + 'records' => [ + [ + ], + ], + ], + 'status' => [ + 'errorcode' => 0, + 'message' => 'OK', + ], + ], + ], + ], + ], $data); + } +} diff --git a/tests/Testing/AddressRepositoryFakeTest.php b/tests/Testing/AddressRepositoryFakeTest.php deleted file mode 100644 index 7a8d038..0000000 --- a/tests/Testing/AddressRepositoryFakeTest.php +++ /dev/null @@ -1,57 +0,0 @@ -toBeInstanceOf(AddressRepositoryFake::class); - }); - - it('can count', function () { - AddressRepository::fake([ - [ - AddressFactory::make(), - ], - ]); - - $fake = AddressRepository::query() - ->count(); - - expect($fake)->toBe(1); - }); -}); - -describe('nullable first', function () { - it('can fake a null return', function () { - AddressRepository::fake([ - [ - null, - ], - ]); - - $fake = AddressRepository::query() - ->first(); - - expect($fake)->toBeNull(); - }); -}); - -describe('fake a exception', function () { - it('can fake a exception', function () { - AddressRepository::fake([ - [ - new OnOfficeException('foo', 1), - ], - ]); - - AddressRepository::query() - ->first(); - })->throws(OnOfficeException::class); -}); diff --git a/tests/Testing/EstateRepositoryFakeTest.php b/tests/Testing/EstateRepositoryFakeTest.php deleted file mode 100644 index 80152d8..0000000 --- a/tests/Testing/EstateRepositoryFakeTest.php +++ /dev/null @@ -1,212 +0,0 @@ -toBeInstanceOf(EstateRepositoryFake::class); - }); - - it('can get a fake response', function () { - EstateRepository::fake([ - [ - EstateFactory::make() - ->id(1) - ->set('foo', 'bar'), - ], - ]); - - $estates = EstateRepository::query()->get(); - - expect($estates)->toHaveCount(1) - ->and($estates->first()['id'])->toBe(1); - }); - - it('can get fake responses in pages', function () { - EstateRepository::fake([ - [ - EstateFactory::make()->id(1), - ], - [ - EstateFactory::make()->id(2), - EstateFactory::make()->id(3), - ], - ]); - - $estates = EstateRepository::query()->get(); - - expect($estates)->toHaveCount(3) - ->and($estates->first()['id'])->toBe(1) - ->and($estates->last()['id'])->toBe(3); - }); - - it('can get multiple fake responses', function () { - EstateRepository::fake([ - [ - EstateFactory::make()->id(1), - ], - ], [ - [ - EstateFactory::make()->id(2), - EstateFactory::make()->id(3), - ], - ]); - - $estates = EstateRepository::query()->get(); - - expect($estates)->toHaveCount(1) - ->and($estates->first()['id'])->toBe(1); - - $estates = EstateRepository::query()->get(); - - expect($estates)->toHaveCount(2) - ->and($estates->first()['id'])->toBe(2) - ->and($estates->last()['id'])->toBe(3); - }); - - it('throws an exception when no more fake responses are available', function () { - EstateRepository::fake([ - [ - EstateFactory::make()->id(1), - ], - ]); - - EstateRepository::query()->get(); - - expect(fn () => EstateRepository::query()->get()) - ->toThrow('No more fake responses'); - }); -}); - -describe('find', function () { - it('can find a fake response', function () { - EstateRepository::fake([ - [ - EstateFactory::make()->id(1), - ], - ]); - - $estate = EstateRepository::query()->find(1); - - expect($estate['id'])->toBe(1); - }); - - it('can find a fake response in pages', function () { - EstateRepository::fake([ - [ - EstateFactory::make()->id(1), - ], - [ - EstateFactory::make()->id(2), - EstateFactory::make()->id(3), - ], - ]); - - $estate = EstateRepository::query()->find(3); - - expect($estate['id'])->toBe(3); - }); - - it('throws an exception when no more fake responses are available', function () { - EstateRepository::fake([ - [ - EstateFactory::make()->id(1), - ], - ]); - - EstateRepository::query()->find(1); - - expect(static fn () => EstateRepository::query()->find(1)) - ->toThrow('No more fake responses'); - }); -}); - -describe('modify', function () { - it('can modify', function () { - EstateRepository::fake([ - [ - true, - ], - ]); - - $result = EstateRepository::query()->modify(1); - - expect($result)->toBeTrue(); - }); - - it('can modify multiple times', function () { - EstateRepository::fake([ - [ - true, - ], - ], [ - [ - true, - ], - ]); - - $result = EstateRepository::query()->modify(1); - - expect($result)->toBeTrue(); - - $result = EstateRepository::query()->modify(2); - - expect($result)->toBeTrue(); - }); - - it('throws an exception when no more fake responses are available', function () { - EstateRepository::fake(); - - EstateRepository::query()->modify(1); - })->throws(Exception::class, 'No more fake responses'); -}); - -describe('delete', function () { - it('can delete', function () { - EstateRepository::fake([ - [ - FileFactory::make() - ->ok(), - ], - ]); - - $result = EstateRepository::files()->delete(1); - - expect($result)->toBeTrue(); - }); - - it('can delete multiple times', function () { - EstateRepository::fake([ - [ - FileFactory::make() - ->ok(), - ], - ], [ - [ - FileFactory::make() - ->ok(), - ], - ]); - - $result = EstateRepository::files()->delete(1); - - expect($result)->toBeTrue(); - - $result = EstateRepository::files()->delete(2); - - expect($result)->toBeTrue(); - }); - - it('throws an exception when no more fake responses are available', function () { - EstateRepository::fake(); - - EstateRepository::files()->delete(1); - })->throws(Exception::class, 'No more fake responses'); -}); diff --git a/tests/Testing/FileRepositoryFakeTest.php b/tests/Testing/FileRepositoryFakeTest.php deleted file mode 100644 index 602f74d..0000000 --- a/tests/Testing/FileRepositoryFakeTest.php +++ /dev/null @@ -1,113 +0,0 @@ -toBeInstanceOf(FileRepositoryFake::class); -}); - -describe('save', function () { - it('can get a fake response', function () { - FileRepository::fake([ - [ - FileUploadFactory::make() - ->tmpUploadId('a17ebec0-48f9-44cc-8629-f49ccc68f2d2'), - ], - ]); - - $tmpUploadId = FileRepository::upload()->save(base64_encode('test')); - - expect($tmpUploadId)->toBe('a17ebec0-48f9-44cc-8629-f49ccc68f2d2'); - }); - - it('can get multiple fake responses', function () { - FileRepository::fake([ - [ - FileUploadFactory::make() - ->tmpUploadId('a17ebec0-48f9-44cc-8629-f49ccc68f2d2'), - ], - ], [ - [ - FileUploadFactory::make() - ->tmpUploadId('a17ebec0-48f9-44cc-8629-f49ccc68f2d3'), - ], - ]); - - $tmpUploadId = FileRepository::upload()->save(base64_encode('test')); - $tmpUploadId2 = FileRepository::upload()->save(base64_encode('test2')); - - expect($tmpUploadId)->toBe('a17ebec0-48f9-44cc-8629-f49ccc68f2d2') - ->and($tmpUploadId2)->toBe('a17ebec0-48f9-44cc-8629-f49ccc68f2d3'); - }); - - it('throws an exception when no more fake responses are available', function () { - FileRepository::fake([ - [ - FileUploadFactory::make() - ->tmpUploadId('a17ebec0-48f9-44cc-8629-f49ccc68f2d2'), - ], - ]); - - FileRepository::upload()->save(base64_encode('test')); - - expect(static fn () => FileRepository::upload()->save(base64_encode('test2'))) - ->toThrow('No more fake responses'); - }); -}); - -describe('link', function () { - it('can get a fake response', function () { - FileRepository::fake([ - [ - FileUploadFactory::make() - ->ok(), - ], - ]); - - $file = FileRepository::upload()->link('a17ebec0-48f9-44cc-8629-f49ccc68f2d2'); - - expect($file['elements']['success'])->toBe('success'); - }); - - it('can get multiple fake responses', function () { - FileRepository::fake([ - [ - FileUploadFactory::make() - ->ok(), - ], - ], [ - [ - FileUploadFactory::make() - ->error(), - ], - ]); - - $tmpUpload = FileRepository::upload()->link('a17ebec0-48f9-44cc-8629-f49ccc68f2d2'); - $tmpUpload2 = FileRepository::upload()->link('a17ebec0-48f9-44cc-8629-f49ccc68f2d3'); - - expect($tmpUpload)->toBeArray() - ->and($tmpUpload['elements']['success'])->toBe('success') - ->and($tmpUpload2)->toBeArray() - ->and($tmpUpload2['elements']['success'])->not->toBe('success'); - }); - - it('throws an exception when no more fake responses are available', function () { - FileRepository::fake([ - [ - FileUploadFactory::make() - ->ok(), - ], - ]); - - FileRepository::upload()->link('a17ebec0-48f9-44cc-8629-f49ccc68f2d3'); - - expect(static fn () => FileRepository::upload()->link('a17ebec0-48f9-44cc-8629-f49ccc68f2d3')) - ->toThrow('No more fake responses'); - }); -}); diff --git a/tests/Testing/MarketplaceRepositoryFakeTest.php b/tests/Testing/MarketplaceRepositoryFakeTest.php deleted file mode 100644 index 1789472..0000000 --- a/tests/Testing/MarketplaceRepositoryFakeTest.php +++ /dev/null @@ -1,39 +0,0 @@ -toBeInstanceOf(MarketplaceRepositoryFake::class); - }); - - it('can get a fake response', function () { - MarketplaceRepository::fake([ - [ - MarketPlaceUnlockProviderFactory::make()->ok(), - ], - ]); - - $success = MarketplaceRepository::query()->unlockProvider('foo', 'bar'); - - expect($success)->toBeTrue(); - }); - - it('can get an error fake response', function () { - MarketplaceRepository::fake([ - [ - MarketPlaceUnlockProviderFactory::make()->error(), - ], - ]); - - $success = MarketplaceRepository::query()->unlockProvider('foo', 'bar'); - - expect($success)->toBeFalse(); - }); -}); From 9e263d14fe7b9b19198fe2f409965b7bbf4c9b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=B6r=C3=9F?= Date: Wed, 18 Sep 2024 13:09:13 +0200 Subject: [PATCH 02/13] feat: add custom request --- src/Query/Builder.php | 66 ++++++++++++++++++++++- src/Repositories/BaseRepository.php | 28 +--------- tests/Query/BuilderTest.php | 28 +--------- tests/Repositories/BaseRepositoryTest.php | 62 +++++++++++++++++++++ 4 files changed, 129 insertions(+), 55 deletions(-) diff --git a/src/Query/Builder.php b/src/Query/Builder.php index dec8595..9319812 100644 --- a/src/Query/Builder.php +++ b/src/Query/Builder.php @@ -20,7 +20,7 @@ use Katalam\OnOfficeAdapter\Services\OnOfficeService; use Throwable; -abstract class Builder implements BuilderInterface +class Builder implements BuilderInterface { use Conditionable; @@ -326,4 +326,68 @@ public function parameters(array $parameters): static return $this; } + + /** + * @throws OnOfficeException + */ + public function get(): Collection + { + throw new OnOfficeException('Not implemented'); + } + + /** + * @throws OnOfficeException + */ + public function call(OnOfficeRequest $request): Collection + { + return $this->requestAll($request); + } + + /** + * @throws OnOfficeException + */ + public function first(): ?array + { + throw new OnOfficeException('Not implemented'); + } + + /** + * @throws Throwable + */ + public function once(OnOfficeRequest $request): Response + { + return $this->requestApi($request); + } + + /** + * @throws OnOfficeException + */ + public function find(int $id): array + { + throw new OnOfficeException('Not implemented'); + } + + /** + * @throws OnOfficeException + */ + public function each(callable $callback): void + { + throw new OnOfficeException('Not implemented'); + } + + /** + * @throws OnOfficeException + */ + public function chunked(OnOfficeRequest $request, callable $callback): void + { + $this->requestAllChunked($request, $callback); + } + + /** + * @throws OnOfficeException + */ + public function modify(int $id): bool + { + throw new OnOfficeException('Not implemented'); + } } diff --git a/src/Repositories/BaseRepository.php b/src/Repositories/BaseRepository.php index c389f70..d7071d9 100644 --- a/src/Repositories/BaseRepository.php +++ b/src/Repositories/BaseRepository.php @@ -126,33 +126,7 @@ public function query(): Builder protected function createBuilder(): Builder { - return new class extends Builder - { - public function get(): Collection - { - throw new RuntimeException('Not implemented'); - } - - public function first(): ?array - { - throw new RuntimeException('Not implemented'); - } - - public function find(int $id): array - { - throw new RuntimeException('Not implemented'); - } - - public function each(callable $callback): void - { - throw new RuntimeException('Not implemented'); - } - - public function modify(int $id): bool - { - throw new RuntimeException('Not implemented'); - } - }; + return new Builder; } /** diff --git a/tests/Query/BuilderTest.php b/tests/Query/BuilderTest.php index 35b73a4..66efc88 100644 --- a/tests/Query/BuilderTest.php +++ b/tests/Query/BuilderTest.php @@ -2,33 +2,7 @@ declare(strict_types=1); -use Illuminate\Support\Collection; -use Katalam\OnOfficeAdapter\Query\Builder as AbstractBuilder; - -class Builder extends AbstractBuilder -{ - public function get(): Collection - { - return new Collection; - } - - public function first(): ?array - { - return []; - } - - public function find(int $id): array - { - return []; - } - - public function each(callable $callback): void {} - - public function modify(int $id): bool - { - return true; - } -} +use Katalam\OnOfficeAdapter\Query\Builder; describe('select', function () { it('should set the columns property to the given columns', function () { diff --git a/tests/Repositories/BaseRepositoryTest.php b/tests/Repositories/BaseRepositoryTest.php index c9359ec..2acc002 100644 --- a/tests/Repositories/BaseRepositoryTest.php +++ b/tests/Repositories/BaseRepositoryTest.php @@ -3,6 +3,7 @@ declare(strict_types=1); use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Http; use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; @@ -200,3 +201,64 @@ $builder->assertSentCount(2); }); }); + +describe('request', function () { + it('will call once', function () { + Http::preventStrayRequests(); + Http::fake([ + 'https://api.onoffice.de/api/stable/api.php/' => Http::response([ + 'status' => [ + 'code' => 200, + ] + ]), + ]); + + $builder = new BaseRepository; + + $request = new OnOfficeRequest(OnOfficeAction::Read, OnOfficeResourceType::Estate); + + $builder->query()->once($request); + + Http::assertSentCount(1); + }); + + it('will call call', function () { + Http::preventStrayRequests(); + Http::fake([ + 'https://api.onoffice.de/api/stable/api.php/' => Http::response([ + 'status' => [ + 'code' => 200, + ] + ]), + ]); + + $builder = new BaseRepository; + + $request = new OnOfficeRequest(OnOfficeAction::Read, OnOfficeResourceType::Estate); + + $builder->query()->call($request); + + Http::assertSentCount(1); + }); + + it('will call chunked', function () { + Http::preventStrayRequests(); + Http::fake([ + 'https://api.onoffice.de/api/stable/api.php/' => Http::response([ + 'status' => [ + 'code' => 200, + ] + ]), + ]); + + $builder = new BaseRepository; + + $request = new OnOfficeRequest(OnOfficeAction::Read, OnOfficeResourceType::Estate); + + $builder->query()->chunked($request, function () { + return true; + }); + + Http::assertSentCount(1); + }); +}); From f3b4e0362ef67f333d9bc8f63b0b342f3b8567ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=B6r=C3=9F?= Date: Wed, 18 Sep 2024 13:10:00 +0200 Subject: [PATCH 03/13] chore: code style --- src/Facades/ActivityRepository.php | 2 +- src/Query/EstateFileBuilder.php | 3 +-- src/Repositories/BaseRepository.php | 1 - src/Repositories/SettingRepository.php | 1 - tests/Query/AddressBuilderTest.php | 5 ----- tests/Query/FieldBuilderTest.php | 3 --- tests/Query/UploadBuilderTest.php | 1 - tests/Repositories/ActivityRepositoryTest.php | 2 -- tests/Repositories/AddressRepositoryTest.php | 1 - tests/Repositories/BaseRepositoryTest.php | 6 +++--- .../Repositories/EstateFileRepositoryTest.php | 6 ------ tests/Repositories/EstateRepositoryTest.php | 4 ---- tests/Repositories/FieldRepositoryTest.php | 7 ------- tests/Repositories/ImprintRepositoryTest.php | 10 ---------- .../MarketplaceRepositoryTest.php | 7 ------- tests/Repositories/RegionRepositoryTest.php | 12 ------------ tests/Repositories/RelationRepositoryTest.php | 19 ++++++------------- .../SearchCriteriaRepositoryTest.php | 7 ------- tests/Repositories/UploadRepositoryTest.php | 15 --------------- tests/Repositories/UserRepositoryTest.php | 12 ------------ 20 files changed, 11 insertions(+), 113 deletions(-) diff --git a/src/Facades/ActivityRepository.php b/src/Facades/ActivityRepository.php index cc035e4..9dc39ca 100644 --- a/src/Facades/ActivityRepository.php +++ b/src/Facades/ActivityRepository.php @@ -6,8 +6,8 @@ use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; -use Katalam\OnOfficeAdapter\Repositories\ActivityRepository as RootRepository; use Katalam\OnOfficeAdapter\Query\ActivityBuilder; +use Katalam\OnOfficeAdapter\Repositories\ActivityRepository as RootRepository; /** * @see RootRepository diff --git a/src/Query/EstateFileBuilder.php b/src/Query/EstateFileBuilder.php index 21b0eb6..2445b60 100644 --- a/src/Query/EstateFileBuilder.php +++ b/src/Query/EstateFileBuilder.php @@ -10,7 +10,6 @@ use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceId; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; use Throwable; class EstateFileBuilder extends Builder @@ -145,6 +144,6 @@ public function delete(int $id): bool ); return $this->requestApi($request) - ->json('response.results.0.data.records.0.elements.success') === 'success'; + ->json('response.results.0.data.records.0.elements.success') === 'success'; } } diff --git a/src/Repositories/BaseRepository.php b/src/Repositories/BaseRepository.php index d7071d9..654d77b 100644 --- a/src/Repositories/BaseRepository.php +++ b/src/Repositories/BaseRepository.php @@ -14,7 +14,6 @@ use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; use Katalam\OnOfficeAdapter\Query\Builder; use PHPUnit\Framework\Assert as PHPUnit; -use RuntimeException; class BaseRepository { diff --git a/src/Repositories/SettingRepository.php b/src/Repositories/SettingRepository.php index d2be05b..72779e3 100644 --- a/src/Repositories/SettingRepository.php +++ b/src/Repositories/SettingRepository.php @@ -5,7 +5,6 @@ namespace Katalam\OnOfficeAdapter\Repositories; use Katalam\OnOfficeAdapter\Query\ActionBuilder; -use Katalam\OnOfficeAdapter\Query\Builder; use Katalam\OnOfficeAdapter\Query\ImprintBuilder; use Katalam\OnOfficeAdapter\Query\RegionBuilder; use Katalam\OnOfficeAdapter\Query\UserBuilder; diff --git a/tests/Query/AddressBuilderTest.php b/tests/Query/AddressBuilderTest.php index 85c32f2..b70af6f 100644 --- a/tests/Query/AddressBuilderTest.php +++ b/tests/Query/AddressBuilderTest.php @@ -2,13 +2,8 @@ declare(strict_types=1); -use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\EstateRepository; use Katalam\OnOfficeAdapter\Query\AddressBuilder; use Katalam\OnOfficeAdapter\Repositories\AddressRepository; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; -use Katalam\OnOfficeAdapter\Tests\Stubs\CreateAddressResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; describe('recordIds', function () { it('should set the recordIds property to the given recordIds', function () { diff --git a/tests/Query/FieldBuilderTest.php b/tests/Query/FieldBuilderTest.php index 84901bb..0b521f6 100644 --- a/tests/Query/FieldBuilderTest.php +++ b/tests/Query/FieldBuilderTest.php @@ -2,11 +2,8 @@ declare(strict_types=1); -use Illuminate\Support\Facades\Http; use Katalam\OnOfficeAdapter\Query\FieldBuilder; use Katalam\OnOfficeAdapter\Repositories\FieldRepository; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetFieldsResponse; describe('withModules', function () { it('should set the modules property to the given modules', function () { diff --git a/tests/Query/UploadBuilderTest.php b/tests/Query/UploadBuilderTest.php index 730b901..5a41b25 100644 --- a/tests/Query/UploadBuilderTest.php +++ b/tests/Query/UploadBuilderTest.php @@ -6,7 +6,6 @@ use Illuminate\Support\Facades\Http; use Katalam\OnOfficeAdapter\Query\UploadBuilder; use Katalam\OnOfficeAdapter\Repositories\FileRepository; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; use Katalam\OnOfficeAdapter\Tests\Stubs\LinkDataResponse; use Katalam\OnOfficeAdapter\Tests\Stubs\UploadFileResponse; diff --git a/tests/Repositories/ActivityRepositoryTest.php b/tests/Repositories/ActivityRepositoryTest.php index 1d2d528..c02c587 100644 --- a/tests/Repositories/ActivityRepositoryTest.php +++ b/tests/Repositories/ActivityRepositoryTest.php @@ -4,10 +4,8 @@ use Illuminate\Support\Facades\Http; use Katalam\OnOfficeAdapter\Facades\ActivityRepository; -use Katalam\OnOfficeAdapter\Facades\EstateRepository; use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; use Katalam\OnOfficeAdapter\Tests\Stubs\ReadActivityResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/AddressRepositoryTest.php b/tests/Repositories/AddressRepositoryTest.php index bee2967..89e0364 100644 --- a/tests/Repositories/AddressRepositoryTest.php +++ b/tests/Repositories/AddressRepositoryTest.php @@ -4,7 +4,6 @@ use Illuminate\Support\Facades\Http; use Katalam\OnOfficeAdapter\Facades\AddressRepository; -use Katalam\OnOfficeAdapter\Facades\EstateRepository; use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; use Katalam\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; diff --git a/tests/Repositories/BaseRepositoryTest.php b/tests/Repositories/BaseRepositoryTest.php index 2acc002..6e3b3ac 100644 --- a/tests/Repositories/BaseRepositoryTest.php +++ b/tests/Repositories/BaseRepositoryTest.php @@ -209,7 +209,7 @@ 'https://api.onoffice.de/api/stable/api.php/' => Http::response([ 'status' => [ 'code' => 200, - ] + ], ]), ]); @@ -228,7 +228,7 @@ 'https://api.onoffice.de/api/stable/api.php/' => Http::response([ 'status' => [ 'code' => 200, - ] + ], ]), ]); @@ -247,7 +247,7 @@ 'https://api.onoffice.de/api/stable/api.php/' => Http::response([ 'status' => [ 'code' => 200, - ] + ], ]), ]); diff --git a/tests/Repositories/EstateFileRepositoryTest.php b/tests/Repositories/EstateFileRepositoryTest.php index 6c9efbd..47d9e1f 100644 --- a/tests/Repositories/EstateFileRepositoryTest.php +++ b/tests/Repositories/EstateFileRepositoryTest.php @@ -3,15 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\ActivityRepository; use Katalam\OnOfficeAdapter\Facades\EstateRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\FileFactory; use Katalam\OnOfficeAdapter\Tests\Stubs\GetEstatePicturesResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadActivityResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadEstateResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/EstateRepositoryTest.php b/tests/Repositories/EstateRepositoryTest.php index 874143d..4bcdbc0 100644 --- a/tests/Repositories/EstateRepositoryTest.php +++ b/tests/Repositories/EstateRepositoryTest.php @@ -3,12 +3,8 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\ActivityRepository; use Katalam\OnOfficeAdapter\Facades\EstateRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadActivityResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; use Katalam\OnOfficeAdapter\Tests\Stubs\ReadEstateResponse; describe('fake responses', function () { diff --git a/tests/Repositories/FieldRepositoryTest.php b/tests/Repositories/FieldRepositoryTest.php index c89abaf..bcfb07e 100644 --- a/tests/Repositories/FieldRepositoryTest.php +++ b/tests/Repositories/FieldRepositoryTest.php @@ -3,16 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\ActivityRepository; -use Katalam\OnOfficeAdapter\Facades\EstateRepository; use Katalam\OnOfficeAdapter\Facades\FieldRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\FieldFactory; use Katalam\OnOfficeAdapter\Tests\Stubs\GetFieldsResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadActivityResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadEstateResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/ImprintRepositoryTest.php b/tests/Repositories/ImprintRepositoryTest.php index 16acf16..34711ed 100644 --- a/tests/Repositories/ImprintRepositoryTest.php +++ b/tests/Repositories/ImprintRepositoryTest.php @@ -3,19 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\ActivityRepository; -use Katalam\OnOfficeAdapter\Facades\EstateRepository; -use Katalam\OnOfficeAdapter\Facades\FieldRepository; use Katalam\OnOfficeAdapter\Facades\SettingRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\FieldFactory; use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\ImprintFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetFieldsResponse; use Katalam\OnOfficeAdapter\Tests\Stubs\GetImprintResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadActivityResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadEstateResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/MarketplaceRepositoryTest.php b/tests/Repositories/MarketplaceRepositoryTest.php index 55ca05e..9c2b3da 100644 --- a/tests/Repositories/MarketplaceRepositoryTest.php +++ b/tests/Repositories/MarketplaceRepositoryTest.php @@ -3,16 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\ActivityRepository; -use Katalam\OnOfficeAdapter\Facades\EstateRepository; use Katalam\OnOfficeAdapter\Facades\MarketplaceRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\MarketPlaceUnlockProviderFactory; use Katalam\OnOfficeAdapter\Tests\Stubs\DoUnlockProviderResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadActivityResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadEstateResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/RegionRepositoryTest.php b/tests/Repositories/RegionRepositoryTest.php index 0454156..3662811 100644 --- a/tests/Repositories/RegionRepositoryTest.php +++ b/tests/Repositories/RegionRepositoryTest.php @@ -3,21 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\ActivityRepository; -use Katalam\OnOfficeAdapter\Facades\EstateRepository; -use Katalam\OnOfficeAdapter\Facades\FieldRepository; use Katalam\OnOfficeAdapter\Facades\SettingRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\FieldFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\ImprintFactory; use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\RegionFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetFieldsResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetImprintResponse; use Katalam\OnOfficeAdapter\Tests\Stubs\GetRegionsResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadActivityResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadEstateResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/RelationRepositoryTest.php b/tests/Repositories/RelationRepositoryTest.php index c0a16bd..f858780 100644 --- a/tests/Repositories/RelationRepositoryTest.php +++ b/tests/Repositories/RelationRepositoryTest.php @@ -4,28 +4,21 @@ use Illuminate\Support\Facades\Http; use Katalam\OnOfficeAdapter\Enums\OnOfficeRelationType; -use Katalam\OnOfficeAdapter\Facades\ActivityRepository; -use Katalam\OnOfficeAdapter\Facades\EstateRepository; use Katalam\OnOfficeAdapter\Facades\RelationRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\RelationFactory; use Katalam\OnOfficeAdapter\Tests\Stubs\GetEstateAgentsResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadActivityResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadEstateResponse; describe('fake responses', function () { test('get', function () { RelationRepository::fake(RelationRepository::response([ RelationRepository::page(recordFactories: [ RelationFactory::make() - ->data([ - 5779 => [ - '2169', - '2205', - ], - ]), + ->data([ + 5779 => [ + '2169', + '2205', + ], + ]), ]), ])); diff --git a/tests/Repositories/SearchCriteriaRepositoryTest.php b/tests/Repositories/SearchCriteriaRepositoryTest.php index 9172368..5030e6a 100644 --- a/tests/Repositories/SearchCriteriaRepositoryTest.php +++ b/tests/Repositories/SearchCriteriaRepositoryTest.php @@ -3,16 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\ActivityRepository; -use Katalam\OnOfficeAdapter\Facades\EstateRepository; use Katalam\OnOfficeAdapter\Facades\SearchCriteriaRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\SearchCriteriaFactory; use Katalam\OnOfficeAdapter\Tests\Stubs\GetSearchCriteriaResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadActivityResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadEstateResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/UploadRepositoryTest.php b/tests/Repositories/UploadRepositoryTest.php index 686471b..0df510a 100644 --- a/tests/Repositories/UploadRepositoryTest.php +++ b/tests/Repositories/UploadRepositoryTest.php @@ -3,23 +3,8 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\ActivityRepository; -use Katalam\OnOfficeAdapter\Facades\EstateRepository; -use Katalam\OnOfficeAdapter\Facades\FieldRepository; use Katalam\OnOfficeAdapter\Facades\FileRepository; -use Katalam\OnOfficeAdapter\Facades\SettingRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\FieldFactory; use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\FileFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\ImprintFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\RegionFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetFieldsResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetImprintResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetRegionsResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadActivityResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadEstateResponse; use Katalam\OnOfficeAdapter\Tests\Stubs\UploadFileResponse; describe('fake responses', function () { diff --git a/tests/Repositories/UserRepositoryTest.php b/tests/Repositories/UserRepositoryTest.php index e65abc6..922f1ab 100644 --- a/tests/Repositories/UserRepositoryTest.php +++ b/tests/Repositories/UserRepositoryTest.php @@ -3,20 +3,8 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\ActivityRepository; -use Katalam\OnOfficeAdapter\Facades\EstateRepository; -use Katalam\OnOfficeAdapter\Facades\FieldRepository; use Katalam\OnOfficeAdapter\Facades\SettingRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\FieldFactory; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\ImprintFactory; use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\UserFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetFieldsResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetImprintResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadActivityResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadEstateResponse; use Katalam\OnOfficeAdapter\Tests\Stubs\ReadUserResponse; describe('fake responses', function () { From 620d3f1c9f432b50568549e6dc3029924bf6afae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=B6r=C3=9F?= Date: Wed, 18 Sep 2024 13:15:59 +0200 Subject: [PATCH 04/13] chore: code style --- src/Query/ActionBuilder.php | 32 ----------------------- src/Query/ActivityBuilder.php | 8 ------ src/Query/EstateBuilder.php | 23 ++++++++++------- src/Query/FieldBuilder.php | 16 ------------ src/Query/ImprintBuilder.php | 16 ------------ src/Query/MarketplaceBuilder.php | 40 ----------------------------- src/Query/RegionBuilder.php | 15 ----------- src/Query/RelationBuilder.php | 24 ----------------- src/Query/SearchCriteriaBuilder.php | 33 ------------------------ src/Query/UploadBuilder.php | 40 ----------------------------- src/Query/UserBuilder.php | 7 ----- 11 files changed, 14 insertions(+), 240 deletions(-) diff --git a/src/Query/ActionBuilder.php b/src/Query/ActionBuilder.php index 2d221f3..87a7409 100644 --- a/src/Query/ActionBuilder.php +++ b/src/Query/ActionBuilder.php @@ -33,36 +33,4 @@ public function get(): Collection return $this->requestAll($request); } - - /** - * @throws OnOfficeException - */ - public function first(): ?array - { - throw new OnOfficeException('Not implemented'); - } - - /** - * @throws OnOfficeException - */ - public function find(int $id): array - { - throw new OnOfficeException('Not implemented'); - } - - /** - * @throws OnOfficeException - */ - public function each(callable $callback): void - { - throw new OnOfficeException('Not implemented'); - } - - /** - * @throws OnOfficeException - */ - public function modify(int $id): bool - { - throw new OnOfficeException('Not implemented'); - } } diff --git a/src/Query/ActivityBuilder.php b/src/Query/ActivityBuilder.php index 7e225ce..c050038 100644 --- a/src/Query/ActivityBuilder.php +++ b/src/Query/ActivityBuilder.php @@ -114,14 +114,6 @@ public function each(callable $callback): void $this->requestAllChunked($request, $callback); } - /** - * @throws OnOfficeException - */ - public function modify(int $id): bool - { - throw new OnOfficeException('Not implemented yet'); - } - /** * @throws Throwable */ diff --git a/src/Query/EstateBuilder.php b/src/Query/EstateBuilder.php index dd06fad..a308aff 100644 --- a/src/Query/EstateBuilder.php +++ b/src/Query/EstateBuilder.php @@ -10,6 +10,7 @@ use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Throwable; class EstateBuilder extends Builder { @@ -54,21 +55,22 @@ public function first(): ?array } /** - * @throws OnOfficeException + * @throws Throwable */ public function find(int $id): array { - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Read, OnOfficeResourceType::Estate, $id, parameters: [ OnOfficeService::DATA => $this->columns, ...$this->customParameters, - ] + ], ); - return $response->json('response.results.0.data.records.0'); + return $this->requestApi($request) + ->json('response.results.0.data.records.0'); } /** @@ -91,11 +93,11 @@ public function each(callable $callback): void } /** - * @throws OnOfficeException + * @throws Throwable */ public function modify(int $id): bool { - $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Modify, OnOfficeResourceType::Estate, $id, @@ -104,15 +106,17 @@ public function modify(int $id): bool ], ); + $this->requestApi($request); + return true; } /** - * @throws OnOfficeException + * @throws Throwable */ public function create(array $data): array { - $response = $this->onOfficeService->requestApi( + $request = new OnOfficeRequest( OnOfficeAction::Create, OnOfficeResourceType::Estate, parameters: [ @@ -120,6 +124,7 @@ public function create(array $data): array ], ); - return $response->json('response.results.0.data.records.0'); + return $this->requestApi($request) + ->json('response.results.0.data.records.0'); } } diff --git a/src/Query/FieldBuilder.php b/src/Query/FieldBuilder.php index 7e6959e..6d1c63c 100644 --- a/src/Query/FieldBuilder.php +++ b/src/Query/FieldBuilder.php @@ -49,14 +49,6 @@ public function first(): ?array return $response->json('response.results.0.data.records.0'); } - /** - * @throws OnOfficeException - */ - public function find(int $id): array - { - throw new OnOfficeException('Not implemented in onOffice'); - } - /** * @throws OnOfficeException */ @@ -80,12 +72,4 @@ public function withModules(array|string $modules): static return $this; } - - /** - * @throws OnOfficeException - */ - public function modify(int $id): bool - { - throw new OnOfficeException('Not implemented'); - } } diff --git a/src/Query/ImprintBuilder.php b/src/Query/ImprintBuilder.php index 6a402d7..a53cdb0 100644 --- a/src/Query/ImprintBuilder.php +++ b/src/Query/ImprintBuilder.php @@ -70,20 +70,4 @@ public function find(int $id): array return $response->json('response.results.0.data.records.0'); } - - /** - * @throws OnOfficeException - */ - public function each(callable $callback): void - { - throw new OnOfficeException('Not implemented'); - } - - /** - * @throws OnOfficeException - */ - public function modify(int $id): bool - { - throw new OnOfficeException('Not implemented'); - } } diff --git a/src/Query/MarketplaceBuilder.php b/src/Query/MarketplaceBuilder.php index 6b73a07..493047c 100644 --- a/src/Query/MarketplaceBuilder.php +++ b/src/Query/MarketplaceBuilder.php @@ -14,14 +14,6 @@ class MarketplaceBuilder extends Builder { - /** - * @throws OnOfficeException - */ - public function get(): Collection - { - throw new OnOfficeException('Method not implemented yet'); - } - /** * @throws Throwable */ @@ -42,36 +34,4 @@ public function unlockProvider( return $this->requestApi($request) ->json('response.results.0.data.records.0.elements.success') === 'success'; } - - /** - * @throws OnOfficeException - */ - public function first(): ?array - { - throw new OnOfficeException('Method not implemented yet'); - } - - /** - * @throws OnOfficeException - */ - public function find(int $id): array - { - throw new OnOfficeException('Method not implemented yet'); - } - - /** - * @throws OnOfficeException - */ - public function each(callable $callback): void - { - throw new OnOfficeException('Method not implemented yet'); - } - - /** - * @throws OnOfficeException - */ - public function modify(int $id): bool - { - throw new OnOfficeException('Not implemented'); - } } diff --git a/src/Query/RegionBuilder.php b/src/Query/RegionBuilder.php index 11f1bd1..f381851 100644 --- a/src/Query/RegionBuilder.php +++ b/src/Query/RegionBuilder.php @@ -50,14 +50,6 @@ public function first(): ?array ->json('response.results.0.data.records.0'); } - /** - * @throws OnOfficeException - */ - public function find(int $id): array - { - throw new OnOfficeException('Method not implemented'); - } - /** * @throws OnOfficeException */ @@ -72,11 +64,4 @@ public function each(callable $callback): void $this->requestAllChunked($request, $callback); } - /** - * @throws OnOfficeException - */ - public function modify(int $id): bool - { - throw new OnOfficeException('Not implemented'); - } } diff --git a/src/Query/RelationBuilder.php b/src/Query/RelationBuilder.php index d4f3b0e..8989eff 100644 --- a/src/Query/RelationBuilder.php +++ b/src/Query/RelationBuilder.php @@ -46,22 +46,6 @@ public function get(): Collection return collect(data_get($records->first(), 'elements')); } - /** - * @throws OnOfficeException - */ - public function first(): ?array - { - throw new OnOfficeException('Not implemented in onOffice'); - } - - /** - * @throws OnOfficeException - */ - public function find(int $id): array - { - throw new OnOfficeException('Not implemented in onOffice'); - } - /** * @throws OnOfficeException */ @@ -72,14 +56,6 @@ public function each(callable $callback): void $callback($records); } - /** - * @throws OnOfficeException - */ - public function modify(int $id): bool - { - throw new OnOfficeException('Not implemented'); - } - /** * @throws Throwable */ diff --git a/src/Query/SearchCriteriaBuilder.php b/src/Query/SearchCriteriaBuilder.php index fc1a75b..b8bbbbd 100644 --- a/src/Query/SearchCriteriaBuilder.php +++ b/src/Query/SearchCriteriaBuilder.php @@ -5,7 +5,6 @@ namespace Katalam\OnOfficeAdapter\Query; use Illuminate\Support\Arr; -use Illuminate\Support\Collection; use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; @@ -17,22 +16,6 @@ class SearchCriteriaBuilder extends Builder { private string $mode = 'internal'; - /** - * @throws OnOfficeException - */ - public function get(): Collection - { - throw new OnOfficeException('Not implemented'); - } - - /** - * @throws OnOfficeException - */ - public function first(): ?array - { - throw new OnOfficeException('Not implemented'); - } - /** * @throws Throwable */ @@ -52,22 +35,6 @@ public function find(int|array $id): array ->json('response.results.0.data.records.0', []); } - /** - * @throws OnOfficeException - */ - public function each(callable $callback): void - { - throw new OnOfficeException('Not implemented'); - } - - /** - * @throws OnOfficeException - */ - public function modify(int $id): bool - { - throw new OnOfficeException('Not implemented'); - } - public function mode(string $mode): self { $this->mode = $mode; diff --git a/src/Query/UploadBuilder.php b/src/Query/UploadBuilder.php index 6ed6609..0b018fb 100644 --- a/src/Query/UploadBuilder.php +++ b/src/Query/UploadBuilder.php @@ -24,46 +24,6 @@ class UploadBuilder extends Builder use NonSelectable; use UploadInBlocks; - /** - * @throws OnOfficeException - */ - public function get(): Collection - { - throw new OnOfficeException('Method not implemented'); - } - - /** - * @throws OnOfficeException - */ - public function first(): ?array - { - throw new OnOfficeException('Method not implemented'); - } - - /** - * @throws OnOfficeException - */ - public function find(int $id): array - { - throw new OnOfficeException('Method not implemented'); - } - - /** - * @throws OnOfficeException - */ - public function each(callable $callback): void - { - throw new OnOfficeException('Method not implemented'); - } - - /** - * @throws OnOfficeException - */ - public function modify(int $id): bool - { - throw new OnOfficeException('Not implemented'); - } - /** * File content as base64-encoded binary data. * Returns the temporary upload id. diff --git a/src/Query/UserBuilder.php b/src/Query/UserBuilder.php index 4b1a48c..670907d 100644 --- a/src/Query/UserBuilder.php +++ b/src/Query/UserBuilder.php @@ -93,11 +93,4 @@ public function each(callable $callback): void $this->requestAllChunked($request, $callback); } - /** - * @throws OnOfficeException - */ - public function modify(int $id): bool - { - throw new OnOfficeException('Not implemented'); - } } From 6ba602688fd78589648f9127998d2946e46e5910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=B6r=C3=9F?= Date: Thu, 19 Sep 2024 09:21:31 +0200 Subject: [PATCH 05/13] docs: add repository docs --- .gitignore | 1 - README.md | 32 ++++++++++++++++--- docs/ActivityRepository.md | 45 ++++++++++++++++++++++++++ docs/AddressRepository.md | 44 +++++++++++++++++++++++++ docs/BaseRepository.md | 33 +++++++++++++++++++ docs/EstateRepository.md | 55 ++++++++++++++++++++++++++++++++ docs/FieldRepository.md | 20 ++++++++++++ docs/FileRepository.md | 23 +++++++++++++ docs/MarketplaceRepository.md | 9 ++++++ docs/RelationRepository.md | 33 +++++++++++++++++++ docs/SearchCriteriaRepository.md | 10 ++++++ docs/SettingRepository.md | 45 ++++++++++++++++++++++++++ 12 files changed, 344 insertions(+), 6 deletions(-) create mode 100644 docs/ActivityRepository.md create mode 100644 docs/AddressRepository.md create mode 100644 docs/BaseRepository.md create mode 100644 docs/EstateRepository.md create mode 100644 docs/FieldRepository.md create mode 100644 docs/FileRepository.md create mode 100644 docs/MarketplaceRepository.md create mode 100644 docs/RelationRepository.md create mode 100644 docs/SearchCriteriaRepository.md create mode 100644 docs/SettingRepository.md diff --git a/.gitignore b/.gitignore index a7f372d..8da5f11 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ build composer.lock coverage -docs phpunit.xml phpstan.neon testbench.yaml diff --git a/README.md b/README.md index eaf7d5f..f63c54b 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,18 @@ return [ ## Usage +### Repositories +* ActivityRepository +* AddressRepository +* EstateRepository +* FieldRepository +* FileRepository +* MarketplaceRepository +* RelationRepository +* SearchCriteriaRepository +* SettingRepository + +### Syntax for typical queries ```php $estates = EstateRepository::query() ->select('Id') @@ -59,9 +71,6 @@ $estates = EstateRepository::query() ->orderByDesc('warmmiete') ->get(); -$success = MarketplaceRepository::query() - ->unlockProvider($parameterCacheId, $extendedClaim); - $users = UserRepository::query() ->select([ 'Anrede', @@ -72,16 +81,29 @@ $users = UserRepository::query() ->where('Nr', $this->userId) ->get(); ``` + +### Unusual queries +```php +$success = MarketplaceRepository::query() + ->unlockProvider($parameterCacheId, $extendedClaim); +``` ```php $tmpUploadId = FileRepository::upload() ->save(base64_encode($fileContent)); - $success = FileRepository::upload()->link($tmpUploadId, [ 'module' => 'estate', 'relatedRecordId' => '12345', ]); -``` +// or + +$success = FileRepository::upload() + ->uploadInBlocks() + ->saveAndLink(base64_encode($fileContent), [ + 'module' => 'estate', + 'relatedRecordId' => '12345', + ]); +``` ```php ActivityRepository::query() ->recordIds($recordIds) diff --git a/docs/ActivityRepository.md b/docs/ActivityRepository.md new file mode 100644 index 0000000..e107b83 --- /dev/null +++ b/docs/ActivityRepository.md @@ -0,0 +1,45 @@ +# Activity Repository + +## Estates +```php +use Katalam\OnOfficeAdapter\Facades\ActivityRepository; + +$activities = ActivityRepository::query() + ->recordIdsAsAddress() + ->recordIdsAsEstate() + ->estate() + ->address() + ->recordIds([1, 2, 3]) + ->get(); + +$activity = ActivityRepository::query() + ->recordIdsAsAddress() + ->recordIdsAsEstate() + ->estate() + ->address() + ->recordIds([1, 2, 3]) + ->first(); + +$activity = ActivityRepository::query() + ->find(1); + +ActivityRepository::query() + ->recordIdsAsAddress() + ->recordIdsAsEstate() + ->estate() + ->address() + ->recordIds([1, 2, 3]) + ->each(function (array $estates) { + // First page + }); + +$activity = ActivityRepository::query() + ->recordIdsAsAddress() + ->recordIdsAsEstate() + ->estate() + ->address() + ->recordIds([1, 2, 3]) + ->create([ + 'activity_id' => 1, + ]); +``` diff --git a/docs/AddressRepository.md b/docs/AddressRepository.md new file mode 100644 index 0000000..a73383d --- /dev/null +++ b/docs/AddressRepository.md @@ -0,0 +1,44 @@ +# Address Repository + +## Estates +```php +use Katalam\OnOfficeAdapter\Facades\AddressRepository; + +$addresses = AddressRepository::query() + ->addCountryIsoCodeType('DE') + ->recordIds([1, 2, 3]) + ->get(); + +$address = AddressRepository::query() + ->addCountryIsoCodeType('DE') + ->recordIds([1, 2, 3]) + ->first(); + +$address = AddressRepository::query() + ->addCountryIsoCodeType('DE') + ->find(1); + +AddressRepository::query() + ->addCountryIsoCodeType('DE') + ->recordIds([1, 2, 3]) + ->each(function (array $estates) { + // First page + }); + +AddressRepository::query() + ->addModify('address_id', 1) + ->modify(1); + +$addressCounted = AddressRepository::query() + ->recordIds([1, 2, 3]) + ->count(); + +$estate = AddressRepository::query() + ->create([ + 'estate_id' => 1, + ]); + +$addresses = AddressRepository::query() + ->setInput('foo') + ->search(); +``` diff --git a/docs/BaseRepository.md b/docs/BaseRepository.md new file mode 100644 index 0000000..8b0f189 --- /dev/null +++ b/docs/BaseRepository.md @@ -0,0 +1,33 @@ +# Base Repository + +## Custom +```php +use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; +use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Katalam\OnOfficeAdapter\Facades\BaseRepository; + +$collection = BaseRepository::query() + ->call(new OnOfficeRequest( + OnOfficeAction::Read, + OnOfficeResourceType::Estate, + )); + +$first = BaseRepository::query() + ->call(new OnOfficeRequest( + OnOfficeAction::Read, + OnOfficeResourceType::Estate, + )) + ->once(); + +BaseRepository::query() + ->chunked( + new OnOfficeRequest( + OnOfficeAction::Read, + OnOfficeResourceType::Estate, + ), + function (array $estates) { + // First page + }, + ); +``` diff --git a/docs/EstateRepository.md b/docs/EstateRepository.md new file mode 100644 index 0000000..0fab8fa --- /dev/null +++ b/docs/EstateRepository.md @@ -0,0 +1,55 @@ +# Estate Repository + +## Estates +```php +use Katalam\OnOfficeAdapter\Facades\EstateRepository; + +$estates = EstateRepository::query() + ->get(); + +$estate = EstateRepository::query() + ->first(); + +$estate = EstateRepository::query() + ->find(1); + +EstateRepository::query() + ->each(function (array $estates) { + // First page + }); + +EstateRepository::query() + ->addModify('estate_id', 1) + ->modify(1); + +$estate = EstateRepository::query() + ->create([ + 'estate_id' => 1, + ]); +``` + +## Estate Files +```php +use Katalam\OnOfficeAdapter\Facades\EstateRepository; + +$files = EstateRepository::files(1) + ->get(); + +$file = EstateRepository::files(1) + ->first(); + +$file = EstateRepository::files(1) + ->find(1); + +EstateRepository::files(1) + ->each(function (array $files) { + // First page + }); + +EstateRepository::files(1) + ->addModify('file_id', 1) + ->modify(1); + +EstateRepository::files(1) + ->delete(1); +``` diff --git a/docs/FieldRepository.md b/docs/FieldRepository.md new file mode 100644 index 0000000..7944766 --- /dev/null +++ b/docs/FieldRepository.md @@ -0,0 +1,20 @@ +# Field Repository + +```php +use Katalam\OnOfficeAdapter\Facades\FieldRepository; + +$fields = FieldRepository::query() + ->withModules(['estate']) + ->get(); + +$field = FieldRepository::query() + ->withModules(['estate']) + ->first(); + +FieldRepository::query() + ->withModules(['estate']) + ->each(function (array $fields) { + // First page + }); +``` + diff --git a/docs/FileRepository.md b/docs/FileRepository.md new file mode 100644 index 0000000..399883a --- /dev/null +++ b/docs/FileRepository.md @@ -0,0 +1,23 @@ +# File Repository + +```php +use Katalam\OnOfficeAdapter\Facades\FileRepository; + +$tmpUploadId = FileRepository::query() + ->uploadInBlocks(5120) + ->save(base64_encode($fileContent)); + +$file = FileRepository::query() + ->link($tmpUploadId, [ + 'module' => 'estate', + 'relatedRecordId' => '12345', + ]); + +FileRepository::query() + ->uploadInBlocks(5120) + ->saveAndLink(base64_encode($fileContent), [ + 'module' => 'estate', + 'relatedRecordId' => '12345', + ]); +``` + diff --git a/docs/MarketplaceRepository.md b/docs/MarketplaceRepository.md new file mode 100644 index 0000000..b239ef1 --- /dev/null +++ b/docs/MarketplaceRepository.md @@ -0,0 +1,9 @@ +# Marketplace Repository + +```php +use Katalam\OnOfficeAdapter\Facades\MarketplaceRepository; + +$success = MarketplaceRepository::query() + ->unlockProvider('123', '456'); +``` + diff --git a/docs/RelationRepository.md b/docs/RelationRepository.md new file mode 100644 index 0000000..25f7bac --- /dev/null +++ b/docs/RelationRepository.md @@ -0,0 +1,33 @@ +# Relation Repository + +```php +use Katalam\OnOfficeAdapter\Enums\OnOfficeRelationType; +use Katalam\OnOfficeAdapter\Facades\RelationRepository; + +$relations = RelationRepository::query() + ->parentIds([1, 2, 3]) + ->addParentIds(1) + ->childIds([4, 5, 6]) + ->addChildIds(4) + ->relationType(OnOfficeRelationType::ContactPersonAll) + ->get(); + +RelationRepository::query() + ->parentIds([1, 2, 3]) + ->addParentIds(1) + ->childIds([4, 5, 6]) + ->addChildIds(4) + ->relationType(OnOfficeRelationType::ContactPersonAll) + ->each(function (array $relations) { + // All relations, because they don't have a pagination + }); + +RelationRepository::query() + ->parentIds([1, 2, 3]) + ->addParentIds(1) + ->childIds([4, 5, 6]) + ->addChildIds(4) + ->relationType(OnOfficeRelationType::ContactPersonAll) + ->create(); +``` + diff --git a/docs/SearchCriteriaRepository.md b/docs/SearchCriteriaRepository.md new file mode 100644 index 0000000..6da0fb1 --- /dev/null +++ b/docs/SearchCriteriaRepository.md @@ -0,0 +1,10 @@ +# Search Criteria Repository + +```php +use Katalam\OnOfficeAdapter\Facades\SearchCriteriaRepository; + +$searchCriteria = SearchCriteriaRepository::query() + ->mode('internal') + ->find(1); +``` + diff --git a/docs/SettingRepository.md b/docs/SettingRepository.md new file mode 100644 index 0000000..392bff3 --- /dev/null +++ b/docs/SettingRepository.md @@ -0,0 +1,45 @@ +# Setting Repository + +## Users +```php +use Katalam\OnOfficeAdapter\Facades\SettingRepository; + +$settings = SettingRepository::users() + ->get(); + +$setting = SettingRepository::users() + ->first(); + +$setting = SettingRepository::users() + ->find(1); + +SettingRepository::users() + ->each(function (array $settings) { + // First page + }); +``` + +## Regions +```php +use Katalam\OnOfficeAdapter\Facades\SettingRepository; + +$settings = SettingRepository::regions() + ->get(); +``` + +## Imprint +```php +use Katalam\OnOfficeAdapter\Facades\SettingRepository; + +$settings = SettingRepository::imprint() + ->get(); +``` + +## Actions +```php +use Katalam\OnOfficeAdapter\Facades\SettingRepository; + +$settings = SettingRepository::actions() + ->get(); +``` + From 400fdbe8ed3460d9fe88a1c0f400a23126b6dc8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=B6r=C3=9F?= Date: Thu, 19 Sep 2024 09:21:38 +0200 Subject: [PATCH 06/13] chore: code style --- src/Facades/BaseRepository.php | 3 ++- src/Query/MarketplaceBuilder.php | 1 - src/Query/RegionBuilder.php | 1 - src/Query/UploadBuilder.php | 1 - src/Query/UserBuilder.php | 1 - 5 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Facades/BaseRepository.php b/src/Facades/BaseRepository.php index d73af2e..b632dc0 100644 --- a/src/Facades/BaseRepository.php +++ b/src/Facades/BaseRepository.php @@ -10,12 +10,13 @@ use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceId; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Katalam\OnOfficeAdapter\Query\Builder; use Katalam\OnOfficeAdapter\Repositories\BaseRepository as RootRepository; /** * @see RootRepository * - * @method static RootRepository query() + * @method static Builder query() */ class BaseRepository extends Facade { diff --git a/src/Query/MarketplaceBuilder.php b/src/Query/MarketplaceBuilder.php index 493047c..6f95b9c 100644 --- a/src/Query/MarketplaceBuilder.php +++ b/src/Query/MarketplaceBuilder.php @@ -4,7 +4,6 @@ namespace Katalam\OnOfficeAdapter\Query; -use Illuminate\Support\Collection; use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; diff --git a/src/Query/RegionBuilder.php b/src/Query/RegionBuilder.php index f381851..42a60e7 100644 --- a/src/Query/RegionBuilder.php +++ b/src/Query/RegionBuilder.php @@ -63,5 +63,4 @@ public function each(callable $callback): void $this->requestAllChunked($request, $callback); } - } diff --git a/src/Query/UploadBuilder.php b/src/Query/UploadBuilder.php index 0b018fb..1f520ee 100644 --- a/src/Query/UploadBuilder.php +++ b/src/Query/UploadBuilder.php @@ -4,7 +4,6 @@ namespace Katalam\OnOfficeAdapter\Query; -use Illuminate\Support\Collection; use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; diff --git a/src/Query/UserBuilder.php b/src/Query/UserBuilder.php index 670907d..d408986 100644 --- a/src/Query/UserBuilder.php +++ b/src/Query/UserBuilder.php @@ -92,5 +92,4 @@ public function each(callable $callback): void $this->requestAllChunked($request, $callback); } - } From 28b125391b6614fa197879af37b6c860971449fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=B6r=C3=9F?= Date: Thu, 19 Sep 2024 09:27:08 +0200 Subject: [PATCH 07/13] docs: add fake docs --- README.md | 97 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 75 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index f63c54b..6674d2c 100644 --- a/README.md +++ b/README.md @@ -124,33 +124,86 @@ Config::set('onoffice.api_claim', 'api_claim'); ### Usage in tests ```php -EstateRepository::fake([ // First request - [ // First page of first request - EstateFactory::make() // First record of first page of first request - ->id(1) - ->set('foo', 'bar'), - ], -], [ // Second request - [ // First page of second request - EstateFactory::make() // First record of first page of second request - ->id(2) - ->set('foo', 'baz'), - EstateFactory::make() // Second record of first page of second request - ->id(3), - ], +use Katalam\OnOfficeAdapter\Facades\EstateRepository; + +EstateRepository::fake(EstateRepository::response([ + EstateRepository::page(recordFactories: [ + EstateFactory::make() + ->id(1), + ]), +])); + +$response = EstateRepository::query()->get(); + +expect($response->count())->toBe(1) + ->and($response->first()['id'])->toBe(1); + +EstateRepository::assertSentCount(1); +``` +```php +use Katalam\OnOfficeAdapter\Facades\EstateRepository; + +EstateRepository::fake(EstateRepository::response([ + EstateRepository::page(recordFactories: [ + EstateFactory::make() + ->id(1), + ]), + EstateRepository::page(recordFactories: [ + EstateFactory::make() + ->id(2), + ]), +])); + +$response = EstateRepository::query()->get(); + +expect($response->count())->toBe(2) + ->and($response->first()['id'])->toBe(1) + ->and($response->last()['id'])->toBe(2); + +EstateRepository::assertSentCount(2); +``` +```php +use Katalam\OnOfficeAdapter\Facades\EstateRepository; + +EstateRepository::preventStrayRequests(); +EstateRepository::fake([ + EstateRepository::response([ + EstateRepository::page(recordFactories: [ + EstateFactory::make() + ->id(1), + ]), + EstateRepository::page(recordFactories: [ + EstateFactory::make() + ->id(2), + ]), + ]), + EstateRepository::response([ + EstateRepository::page(recordFactories: [ + EstateFactory::make() + ->id(3), + ]), + EstateRepository::page(recordFactories: [ + EstateFactory::make() + ->id(4), + ]), + ]), ]); -// request as normal -$estates = EstateRepository::query()->get(); +$response = EstateRepository::query()->get(); + +expect($response->count())->toBe(2) + ->and($response->first()['id'])->toBe(1) + ->and($response->last()['id'])->toBe(2); + +$response = EstateRepository::query()->get(); -expect($estates)->toHaveCount(1) - ->and($estates->first()['id'])->toBe(1); +expect($response->count())->toBe(2) + ->and($response->first()['id'])->toBe(3) + ->and($response->last()['id'])->toBe(4); -$estates = EstateRepository::query()->get(); +EstateRepository::assertSentCount(4); -expect($estates)->toHaveCount(2) - ->and($estates->first()['id'])->toBe(2) - ->and($estates->last()['id'])->toBe(3); +$response = EstateRepository::query()->get(); // throws StrayRequestException ``` ## Testing From 9f47b4ecf67bbb84910a3dd6381047809fa68a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=B6r=C3=9F?= Date: Thu, 19 Sep 2024 09:27:16 +0200 Subject: [PATCH 08/13] chore: add changelog for v1 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b048a9a..df369f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog ## main +## v1.0.0 +- Overhaul of the package to use a new fake implementation +- Overhaul of the package to remove the fake builder classes +- Added the ability to call a custom request + ## v0.13.6 - Fixed typo on relation create From d14249e05417bcb72d857f2af3b06a87e584992e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=B6r=C3=9F?= Date: Thu, 19 Sep 2024 09:27:29 +0200 Subject: [PATCH 09/13] fix: remove abstract base factory to add factory to custom requests --- src/Facades/Testing/RecordFactories/BaseFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Facades/Testing/RecordFactories/BaseFactory.php b/src/Facades/Testing/RecordFactories/BaseFactory.php index 1308aa2..e3afc5f 100644 --- a/src/Facades/Testing/RecordFactories/BaseFactory.php +++ b/src/Facades/Testing/RecordFactories/BaseFactory.php @@ -4,7 +4,7 @@ namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories; -abstract class BaseFactory +class BaseFactory { public int|string $id = 0; From a8f49371b7e706cb6694a34002e91346ddefdbea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=B6r=C3=9F?= Date: Thu, 19 Sep 2024 09:36:45 +0200 Subject: [PATCH 10/13] ci: remove check missing iterable value type ignore --- phpstan.neon.dist | 1 - 1 file changed, 1 deletion(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 489fa4e..de458d6 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -10,5 +10,4 @@ parameters: tmpDir: build/phpstan checkOctaneCompatibility: true checkModelProperties: true - checkMissingIterableValueType: false From fb39df2da09b3d967315d97701215f83cd3109ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=B6r=C3=9F?= Date: Thu, 19 Sep 2024 09:38:07 +0200 Subject: [PATCH 11/13] fix: phpstan --- src/Repositories/BaseRepository.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Repositories/BaseRepository.php b/src/Repositories/BaseRepository.php index 654d77b..239efef 100644 --- a/src/Repositories/BaseRepository.php +++ b/src/Repositories/BaseRepository.php @@ -203,6 +203,7 @@ public function assertSent(?callable $callback = null): void public function assertNotSent(?callable $callback = null): void { + // @phpstan-ignore-next-line PHPUnit::assertTrue( $this->recorded($callback)->isEmpty(), 'An unexpected request was recorded.' From 283919928ec98c5d753ebffd20acf3ae928e8815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=B6r=C3=9F?= Date: Thu, 19 Sep 2024 10:12:46 +0200 Subject: [PATCH 12/13] chore: change vendor name --- .github/FUNDING.yml | 2 +- .github/ISSUE_TEMPLATE/config.yml | 6 +++--- LICENSE.md | 2 +- README.md | 18 ++++++++--------- composer.json | 12 +++++------ config/onoffice.php | 2 +- docs/ActivityRepository.md | 2 +- docs/AddressRepository.md | 2 +- docs/BaseRepository.md | 8 ++++---- docs/EstateRepository.md | 4 ++-- docs/FieldRepository.md | 2 +- docs/FileRepository.md | 2 +- docs/MarketplaceRepository.md | 2 +- docs/RelationRepository.md | 4 ++-- docs/SearchCriteriaRepository.md | 2 +- docs/SettingRepository.md | 8 ++++---- phpunit.xml.dist | 2 +- src/Dtos/OnOfficeRequest.php | 8 ++++---- src/Dtos/OnOfficeResponse.php | 2 +- src/Dtos/OnOfficeResponsePage.php | 10 +++++----- src/Enums/OnOfficeAction.php | 2 +- src/Enums/OnOfficeError.php | 2 +- src/Enums/OnOfficeRelationType.php | 2 +- src/Enums/OnOfficeResourceId.php | 2 +- src/Enums/OnOfficeResourceType.php | 2 +- src/Exceptions/OnOfficeException.php | 4 ++-- src/Exceptions/StrayRequestException.php | 4 ++-- src/Facades/ActivityRepository.php | 10 +++++----- src/Facades/AddressRepository.php | 10 +++++----- src/Facades/BaseRepository.php | 16 +++++++-------- src/Facades/EstateRepository.php | 12 +++++------ src/Facades/FieldRepository.php | 10 +++++----- src/Facades/FileRepository.php | 10 +++++----- src/Facades/MarketplaceRepository.php | 10 +++++----- src/Facades/RelationRepository.php | 10 +++++----- src/Facades/SearchCriteriaRepository.php | 10 +++++----- src/Facades/SettingRepository.php | 16 +++++++-------- .../Testing/RecordFactories/ActionFactory.php | 2 +- .../RecordFactories/ActivityFactory.php | 2 +- .../RecordFactories/AddressFactory.php | 2 +- .../Testing/RecordFactories/BaseFactory.php | 2 +- .../RecordFactories/Concerns/SuccessTrait.php | 2 +- .../Testing/RecordFactories/EstateFactory.php | 2 +- .../Testing/RecordFactories/FieldFactory.php | 2 +- .../Testing/RecordFactories/FileFactory.php | 4 ++-- .../RecordFactories/FileUploadFactory.php | 4 ++-- .../RecordFactories/ImprintFactory.php | 2 +- .../MarketPlaceUnlockProviderFactory.php | 4 ++-- .../Testing/RecordFactories/RegionFactory.php | 2 +- .../RecordFactories/RelationFactory.php | 2 +- .../RecordFactories/SearchCriteriaFactory.php | 2 +- .../Testing/RecordFactories/UserFactory.php | 2 +- src/OnOfficeAdapterServiceProvider.php | 4 ++-- src/Query/ActionBuilder.php | 14 ++++++------- src/Query/ActivityBuilder.php | 14 ++++++------- src/Query/AddressBuilder.php | 18 ++++++++--------- src/Query/Builder.php | 16 +++++++-------- src/Query/Concerns/BuilderInterface.php | 2 +- src/Query/Concerns/Input.php | 2 +- src/Query/Concerns/NonFilterable.php | 2 +- src/Query/Concerns/NonLimitable.php | 2 +- src/Query/Concerns/NonOrderable.php | 2 +- src/Query/Concerns/NonSelectable.php | 2 +- src/Query/Concerns/RecordIds.php | 2 +- src/Query/Concerns/RelationTypes.php | 4 ++-- src/Query/Concerns/UploadInBlocks.php | 2 +- src/Query/EstateBuilder.php | 12 +++++------ src/Query/EstateFileBuilder.php | 12 +++++------ src/Query/FieldBuilder.php | 10 +++++----- src/Query/ImprintBuilder.php | 16 +++++++-------- src/Query/MarketplaceBuilder.php | 12 +++++------ src/Query/RegionBuilder.php | 16 +++++++-------- src/Query/RelationBuilder.php | 20 +++++++++---------- src/Query/SearchCriteriaBuilder.php | 12 +++++------ src/Query/UploadBuilder.php | 20 +++++++++---------- src/Query/UserBuilder.php | 12 +++++------ src/Repositories/ActivityRepository.php | 4 ++-- src/Repositories/AddressRepository.php | 4 ++-- src/Repositories/BaseRepository.php | 16 +++++++-------- src/Repositories/EstateRepository.php | 6 +++--- src/Repositories/FieldRepository.php | 4 ++-- src/Repositories/FileRepository.php | 6 +++--- src/Repositories/MarketplaceRepository.php | 4 ++-- src/Repositories/RelationRepository.php | 4 ++-- src/Repositories/SearchCriteriaRepository.php | 4 ++-- src/Repositories/SettingRepository.php | 10 +++++----- src/Services/OnOfficeParameterConst.php | 2 +- src/Services/OnOfficeService.php | 10 +++++----- tests/ArchTest.php | 2 +- tests/Dtos/OnOfficeResponsePageTest.php | 10 +++++----- tests/Dtos/OnOfficeResponseTest.php | 10 +++++----- tests/Enums/OnOfficeErrorTest.php | 2 +- tests/Exceptions/OnOfficeExceptionTest.php | 4 ++-- tests/Pest.php | 2 +- tests/Query/AddressBuilderTest.php | 4 ++-- tests/Query/BuilderTest.php | 2 +- tests/Query/FieldBuilderTest.php | 4 ++-- tests/Query/RelationBuilderTest.php | 6 +++--- tests/Query/UploadBuilderTest.php | 8 ++++---- tests/Repositories/ActivityRepositoryTest.php | 6 +++--- tests/Repositories/AddressRepositoryTest.php | 6 +++--- tests/Repositories/BaseRepositoryTest.php | 10 +++++----- .../Repositories/EstateFileRepositoryTest.php | 6 +++--- tests/Repositories/EstateRepositoryTest.php | 6 +++--- tests/Repositories/FieldRepositoryTest.php | 6 +++--- tests/Repositories/ImprintRepositoryTest.php | 6 +++--- .../MarketplaceRepositoryTest.php | 6 +++--- tests/Repositories/RegionRepositoryTest.php | 6 +++--- tests/Repositories/RelationRepositoryTest.php | 8 ++++---- .../SearchCriteriaRepositoryTest.php | 6 +++--- tests/Repositories/UploadRepositoryTest.php | 6 +++--- tests/Repositories/UserRepositoryTest.php | 6 +++--- tests/Services/OnOfficeServiceTest.php | 12 +++++------ tests/Stubs/CreateAddressResponse.php | 2 +- tests/Stubs/DoUnlockProviderResponse.php | 2 +- .../Stubs/EmptyGetEstatePicturesResponse.php | 2 +- tests/Stubs/EmptyReadEstateResponse.php | 2 +- .../Stubs/GetEstateAgentsDetailedResponse.php | 2 +- tests/Stubs/GetEstateAgentsResponse.php | 2 +- tests/Stubs/GetEstatePictureResponse.php | 2 +- tests/Stubs/GetEstatePicturesResponse.php | 2 +- tests/Stubs/GetFieldsResponse.php | 2 +- tests/Stubs/GetImprintResponse.php | 2 +- tests/Stubs/GetRegionsResponse.php | 2 +- tests/Stubs/GetSearchCriteriaResponse.php | 2 +- tests/Stubs/InvalidHmacResponse.php | 2 +- tests/Stubs/LinkDataResponse.php | 2 +- tests/Stubs/ReadActivityResponse.php | 2 +- tests/Stubs/ReadAddressResponse.php | 2 +- tests/Stubs/ReadEstateResponse.php | 2 +- tests/Stubs/ReadTwoEstateResponse.php | 2 +- tests/Stubs/ReadUserResponse.php | 2 +- tests/Stubs/UploadFileResponse.php | 2 +- tests/TestCase.php | 6 +++--- tests/Testing/Factories/BaseFactoryTest.php | 2 +- 135 files changed, 384 insertions(+), 384 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index ab90468..202a6ff 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -github: Katalam +github: Innobrain diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 8fe1755..04aea92 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,11 +1,11 @@ blank_issues_enabled: false contact_links: - name: Ask a question - url: https://github.com/Katalam/laravel-onoffice-adapter/discussions/new?category=q-a + url: https://github.com/Innobrain/laravel-onoffice-adapter/discussions/new?category=q-a about: Ask the community for help - name: Request a feature - url: https://github.com/Katalam/laravel-onoffice-adapter/discussions/new?category=ideas + url: https://github.com/Innobrain/laravel-onoffice-adapter/discussions/new?category=ideas about: Share ideas for new features - name: Report a security issue - url: https://github.com/Katalam/laravel-onoffice-adapter/security/policy + url: https://github.com/Innobrain/laravel-onoffice-adapter/security/policy about: Learn how to notify us for sensitive bugs diff --git a/LICENSE.md b/LICENSE.md index 7e79db6..1cb2cbe 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) Katalam +Copyright (c) Innobrain Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 6674d2c..0f4e01b 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # onOffice Adapter for Laravel -[![Latest Version on Packagist](https://img.shields.io/packagist/v/katalam/laravel-onoffice-adapter.svg?style=flat-square)](https://packagist.org/packages/katalam/laravel-onoffice-adapter) -[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/katalam/laravel-onoffice-adapter/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/katalam/laravel-onoffice-adapter/actions?query=workflow%3Arun-tests+branch%3Amain) -[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/katalam/laravel-onoffice-adapter/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/katalam/laravel-onoffice-adapter/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain) -[![Total Downloads](https://img.shields.io/packagist/dt/katalam/laravel-onoffice-adapter.svg?style=flat-square)](https://packagist.org/packages/katalam/laravel-onoffice-adapter) +[![Latest Version on Packagist](https://img.shields.io/packagist/v/innobrain/laravel-onoffice-adapter.svg?style=flat-square)](https://packagist.org/packages/innobrain/laravel-onoffice-adapter) +[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/innobrain/laravel-onoffice-adapter/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/innobrain/laravel-onoffice-adapter/actions?query=workflow%3Arun-tests+branch%3Amain) +[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/innobrain/laravel-onoffice-adapter/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/innobrain/laravel-onoffice-adapter/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain) +[![Total Downloads](https://img.shields.io/packagist/dt/innobrain/laravel-onoffice-adapter.svg?style=flat-square)](https://packagist.org/packages/innobrain/laravel-onoffice-adapter) An onOffice adapter for Laravel @@ -12,7 +12,7 @@ An onOffice adapter for Laravel You can install the package via composer: ```bash -composer require katalam/laravel-onoffice-adapter +composer require innobrain/laravel-onoffice-adapter ``` You can publish the config file with: @@ -124,7 +124,7 @@ Config::set('onoffice.api_claim', 'api_claim'); ### Usage in tests ```php -use Katalam\OnOfficeAdapter\Facades\EstateRepository; +use Innobrain\OnOfficeAdapter\Facades\EstateRepository; EstateRepository::fake(EstateRepository::response([ EstateRepository::page(recordFactories: [ @@ -141,7 +141,7 @@ expect($response->count())->toBe(1) EstateRepository::assertSentCount(1); ``` ```php -use Katalam\OnOfficeAdapter\Facades\EstateRepository; +use Innobrain\OnOfficeAdapter\Facades\EstateRepository; EstateRepository::fake(EstateRepository::response([ EstateRepository::page(recordFactories: [ @@ -163,7 +163,7 @@ expect($response->count())->toBe(2) EstateRepository::assertSentCount(2); ``` ```php -use Katalam\OnOfficeAdapter\Facades\EstateRepository; +use Innobrain\OnOfficeAdapter\Facades\EstateRepository; EstateRepository::preventStrayRequests(); EstateRepository::fake([ @@ -222,7 +222,7 @@ Please review [our security policy](../../security/policy) on how to report secu ## Credits -- [Bruno Görß](https://github.com/Katalam) +- [Bruno Görß](https://github.com/Innobrain) - [All Contributors](../../contributors) ## License diff --git a/composer.json b/composer.json index 062c93f..3c784d6 100644 --- a/composer.json +++ b/composer.json @@ -1,12 +1,12 @@ { - "name": "katalam/laravel-onoffice-adapter", + "name": "innobrain/laravel-onoffice-adapter", "description": "This is my package laravel-onoffice-adapter", "keywords": [ "Katalam", "laravel", "laravel-onoffice-adapter" ], - "homepage": "https://github.com/katalam/laravel-onoffice-adapter", + "homepage": "https://github.com/innobraingmbh/laravel-onoffice-adapter", "license": "MIT", "authors": [ { @@ -35,13 +35,13 @@ }, "autoload": { "psr-4": { - "Katalam\\OnOfficeAdapter\\": "src/", - "Katalam\\OnOfficeAdapter\\Database\\Factories\\": "database/factories/" + "Innobrain\\OnOfficeAdapter\\": "src/", + "Innobrain\\OnOfficeAdapter\\Database\\Factories\\": "database/factories/" } }, "autoload-dev": { "psr-4": { - "Katalam\\OnOfficeAdapter\\Tests\\": "tests/" + "Innobrain\\OnOfficeAdapter\\Tests\\": "tests/" } }, "scripts": { @@ -72,7 +72,7 @@ "extra": { "laravel": { "providers": [ - "Katalam\\OnOfficeAdapter\\OnOfficeAdapterServiceProvider" + "Innobrain\\OnOfficeAdapter\\OnOfficeAdapterServiceProvider" ] } }, diff --git a/config/onoffice.php b/config/onoffice.php index 8049e49..07249ad 100644 --- a/config/onoffice.php +++ b/config/onoffice.php @@ -2,7 +2,7 @@ declare(strict_types=1); -// config for Katalam/OnOfficeAdapter +// config for Innobrain/OnOfficeAdapter return [ /** * The base URL of the OnOffice API. diff --git a/docs/ActivityRepository.md b/docs/ActivityRepository.md index e107b83..1c34628 100644 --- a/docs/ActivityRepository.md +++ b/docs/ActivityRepository.md @@ -2,7 +2,7 @@ ## Estates ```php -use Katalam\OnOfficeAdapter\Facades\ActivityRepository; +use Innobrain\OnOfficeAdapter\Facades\ActivityRepository; $activities = ActivityRepository::query() ->recordIdsAsAddress() diff --git a/docs/AddressRepository.md b/docs/AddressRepository.md index a73383d..9014f06 100644 --- a/docs/AddressRepository.md +++ b/docs/AddressRepository.md @@ -2,7 +2,7 @@ ## Estates ```php -use Katalam\OnOfficeAdapter\Facades\AddressRepository; +use Innobrain\OnOfficeAdapter\Facades\AddressRepository; $addresses = AddressRepository::query() ->addCountryIsoCodeType('DE') diff --git a/docs/BaseRepository.md b/docs/BaseRepository.md index 8b0f189..504fded 100644 --- a/docs/BaseRepository.md +++ b/docs/BaseRepository.md @@ -2,10 +2,10 @@ ## Custom ```php -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Facades\BaseRepository; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Facades\BaseRepository; $collection = BaseRepository::query() ->call(new OnOfficeRequest( diff --git a/docs/EstateRepository.md b/docs/EstateRepository.md index 0fab8fa..062462d 100644 --- a/docs/EstateRepository.md +++ b/docs/EstateRepository.md @@ -2,7 +2,7 @@ ## Estates ```php -use Katalam\OnOfficeAdapter\Facades\EstateRepository; +use Innobrain\OnOfficeAdapter\Facades\EstateRepository; $estates = EstateRepository::query() ->get(); @@ -30,7 +30,7 @@ $estate = EstateRepository::query() ## Estate Files ```php -use Katalam\OnOfficeAdapter\Facades\EstateRepository; +use Innobrain\OnOfficeAdapter\Facades\EstateRepository; $files = EstateRepository::files(1) ->get(); diff --git a/docs/FieldRepository.md b/docs/FieldRepository.md index 7944766..b44e2f0 100644 --- a/docs/FieldRepository.md +++ b/docs/FieldRepository.md @@ -1,7 +1,7 @@ # Field Repository ```php -use Katalam\OnOfficeAdapter\Facades\FieldRepository; +use Innobrain\OnOfficeAdapter\Facades\FieldRepository; $fields = FieldRepository::query() ->withModules(['estate']) diff --git a/docs/FileRepository.md b/docs/FileRepository.md index 399883a..8f59b70 100644 --- a/docs/FileRepository.md +++ b/docs/FileRepository.md @@ -1,7 +1,7 @@ # File Repository ```php -use Katalam\OnOfficeAdapter\Facades\FileRepository; +use Innobrain\OnOfficeAdapter\Facades\FileRepository; $tmpUploadId = FileRepository::query() ->uploadInBlocks(5120) diff --git a/docs/MarketplaceRepository.md b/docs/MarketplaceRepository.md index b239ef1..f4c32cc 100644 --- a/docs/MarketplaceRepository.md +++ b/docs/MarketplaceRepository.md @@ -1,7 +1,7 @@ # Marketplace Repository ```php -use Katalam\OnOfficeAdapter\Facades\MarketplaceRepository; +use Innobrain\OnOfficeAdapter\Facades\MarketplaceRepository; $success = MarketplaceRepository::query() ->unlockProvider('123', '456'); diff --git a/docs/RelationRepository.md b/docs/RelationRepository.md index 25f7bac..bb0435b 100644 --- a/docs/RelationRepository.md +++ b/docs/RelationRepository.md @@ -1,8 +1,8 @@ # Relation Repository ```php -use Katalam\OnOfficeAdapter\Enums\OnOfficeRelationType; -use Katalam\OnOfficeAdapter\Facades\RelationRepository; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeRelationType; +use Innobrain\OnOfficeAdapter\Facades\RelationRepository; $relations = RelationRepository::query() ->parentIds([1, 2, 3]) diff --git a/docs/SearchCriteriaRepository.md b/docs/SearchCriteriaRepository.md index 6da0fb1..1941a11 100644 --- a/docs/SearchCriteriaRepository.md +++ b/docs/SearchCriteriaRepository.md @@ -1,7 +1,7 @@ # Search Criteria Repository ```php -use Katalam\OnOfficeAdapter\Facades\SearchCriteriaRepository; +use Innobrain\OnOfficeAdapter\Facades\SearchCriteriaRepository; $searchCriteria = SearchCriteriaRepository::query() ->mode('internal') diff --git a/docs/SettingRepository.md b/docs/SettingRepository.md index 392bff3..b72a945 100644 --- a/docs/SettingRepository.md +++ b/docs/SettingRepository.md @@ -2,7 +2,7 @@ ## Users ```php -use Katalam\OnOfficeAdapter\Facades\SettingRepository; +use Innobrain\OnOfficeAdapter\Facades\SettingRepository; $settings = SettingRepository::users() ->get(); @@ -21,7 +21,7 @@ SettingRepository::users() ## Regions ```php -use Katalam\OnOfficeAdapter\Facades\SettingRepository; +use Innobrain\OnOfficeAdapter\Facades\SettingRepository; $settings = SettingRepository::regions() ->get(); @@ -29,7 +29,7 @@ $settings = SettingRepository::regions() ## Imprint ```php -use Katalam\OnOfficeAdapter\Facades\SettingRepository; +use Innobrain\OnOfficeAdapter\Facades\SettingRepository; $settings = SettingRepository::imprint() ->get(); @@ -37,7 +37,7 @@ $settings = SettingRepository::imprint() ## Actions ```php -use Katalam\OnOfficeAdapter\Facades\SettingRepository; +use Innobrain\OnOfficeAdapter\Facades\SettingRepository; $settings = SettingRepository::actions() ->get(); diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a5b8260..0e5b9f2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -16,7 +16,7 @@ backupStaticProperties="false" > - + tests diff --git a/src/Dtos/OnOfficeRequest.php b/src/Dtos/OnOfficeRequest.php index 60940c5..b8197e4 100644 --- a/src/Dtos/OnOfficeRequest.php +++ b/src/Dtos/OnOfficeRequest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Dtos; +namespace Innobrain\OnOfficeAdapter\Dtos; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceId; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceId; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; readonly class OnOfficeRequest { diff --git a/src/Dtos/OnOfficeResponse.php b/src/Dtos/OnOfficeResponse.php index 987c7f3..3e6811f 100644 --- a/src/Dtos/OnOfficeResponse.php +++ b/src/Dtos/OnOfficeResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Dtos; +namespace Innobrain\OnOfficeAdapter\Dtos; use Illuminate\Support\Collection; diff --git a/src/Dtos/OnOfficeResponsePage.php b/src/Dtos/OnOfficeResponsePage.php index 0a561df..5e95df7 100644 --- a/src/Dtos/OnOfficeResponsePage.php +++ b/src/Dtos/OnOfficeResponsePage.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Dtos; +namespace Innobrain\OnOfficeAdapter\Dtos; use Illuminate\Support\Collection; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceId; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\BaseFactory; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceId; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\BaseFactory; readonly class OnOfficeResponsePage { diff --git a/src/Enums/OnOfficeAction.php b/src/Enums/OnOfficeAction.php index 941b013..21bd8bf 100644 --- a/src/Enums/OnOfficeAction.php +++ b/src/Enums/OnOfficeAction.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Enums; +namespace Innobrain\OnOfficeAdapter\Enums; enum OnOfficeAction: string { diff --git a/src/Enums/OnOfficeError.php b/src/Enums/OnOfficeError.php index b447458..2462768 100644 --- a/src/Enums/OnOfficeError.php +++ b/src/Enums/OnOfficeError.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Enums; +namespace Innobrain\OnOfficeAdapter\Enums; enum OnOfficeError: int { diff --git a/src/Enums/OnOfficeRelationType.php b/src/Enums/OnOfficeRelationType.php index 3b994db..78d8b3a 100644 --- a/src/Enums/OnOfficeRelationType.php +++ b/src/Enums/OnOfficeRelationType.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Enums; +namespace Innobrain\OnOfficeAdapter\Enums; enum OnOfficeRelationType: string { diff --git a/src/Enums/OnOfficeResourceId.php b/src/Enums/OnOfficeResourceId.php index 8ca7926..a190949 100644 --- a/src/Enums/OnOfficeResourceId.php +++ b/src/Enums/OnOfficeResourceId.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Enums; +namespace Innobrain\OnOfficeAdapter\Enums; enum OnOfficeResourceId: string { diff --git a/src/Enums/OnOfficeResourceType.php b/src/Enums/OnOfficeResourceType.php index 49654ed..120979c 100644 --- a/src/Enums/OnOfficeResourceType.php +++ b/src/Enums/OnOfficeResourceType.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Enums; +namespace Innobrain\OnOfficeAdapter\Enums; enum OnOfficeResourceType: string { diff --git a/src/Exceptions/OnOfficeException.php b/src/Exceptions/OnOfficeException.php index 0da1367..9f75bba 100644 --- a/src/Exceptions/OnOfficeException.php +++ b/src/Exceptions/OnOfficeException.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Exceptions; +namespace Innobrain\OnOfficeAdapter\Exceptions; use Exception; -use Katalam\OnOfficeAdapter\Enums\OnOfficeError; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeError; use Throwable; class OnOfficeException extends Exception diff --git a/src/Exceptions/StrayRequestException.php b/src/Exceptions/StrayRequestException.php index cbc8c6a..cb196b7 100644 --- a/src/Exceptions/StrayRequestException.php +++ b/src/Exceptions/StrayRequestException.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Exceptions; +namespace Innobrain\OnOfficeAdapter\Exceptions; use Exception; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; use Throwable; class StrayRequestException extends Exception diff --git a/src/Facades/ActivityRepository.php b/src/Facades/ActivityRepository.php index 9dc39ca..bf87f68 100644 --- a/src/Facades/ActivityRepository.php +++ b/src/Facades/ActivityRepository.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades; +namespace Innobrain\OnOfficeAdapter\Facades; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; -use Katalam\OnOfficeAdapter\Query\ActivityBuilder; -use Katalam\OnOfficeAdapter\Repositories\ActivityRepository as RootRepository; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponsePage; +use Innobrain\OnOfficeAdapter\Query\ActivityBuilder; +use Innobrain\OnOfficeAdapter\Repositories\ActivityRepository as RootRepository; /** * @see RootRepository diff --git a/src/Facades/AddressRepository.php b/src/Facades/AddressRepository.php index cc32a4c..6e20c16 100644 --- a/src/Facades/AddressRepository.php +++ b/src/Facades/AddressRepository.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades; +namespace Innobrain\OnOfficeAdapter\Facades; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; -use Katalam\OnOfficeAdapter\Query\AddressBuilder; -use Katalam\OnOfficeAdapter\Repositories\AddressRepository as RootRepository; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponsePage; +use Innobrain\OnOfficeAdapter\Query\AddressBuilder; +use Innobrain\OnOfficeAdapter\Repositories\AddressRepository as RootRepository; /** * @see RootRepository diff --git a/src/Facades/BaseRepository.php b/src/Facades/BaseRepository.php index b632dc0..f9aab84 100644 --- a/src/Facades/BaseRepository.php +++ b/src/Facades/BaseRepository.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades; +namespace Innobrain\OnOfficeAdapter\Facades; use Illuminate\Support\Facades\Facade; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceId; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Query\Builder; -use Katalam\OnOfficeAdapter\Repositories\BaseRepository as RootRepository; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponsePage; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceId; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Query\Builder; +use Innobrain\OnOfficeAdapter\Repositories\BaseRepository as RootRepository; /** * @see RootRepository diff --git a/src/Facades/EstateRepository.php b/src/Facades/EstateRepository.php index 0e63a07..a05f52e 100644 --- a/src/Facades/EstateRepository.php +++ b/src/Facades/EstateRepository.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades; +namespace Innobrain\OnOfficeAdapter\Facades; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; -use Katalam\OnOfficeAdapter\Query\EstateBuilder; -use Katalam\OnOfficeAdapter\Query\EstateFileBuilder; -use Katalam\OnOfficeAdapter\Repositories\EstateRepository as RootRepository; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponsePage; +use Innobrain\OnOfficeAdapter\Query\EstateBuilder; +use Innobrain\OnOfficeAdapter\Query\EstateFileBuilder; +use Innobrain\OnOfficeAdapter\Repositories\EstateRepository as RootRepository; /** * @see RootRepository diff --git a/src/Facades/FieldRepository.php b/src/Facades/FieldRepository.php index bfa6808..0872ef4 100644 --- a/src/Facades/FieldRepository.php +++ b/src/Facades/FieldRepository.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades; +namespace Innobrain\OnOfficeAdapter\Facades; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; -use Katalam\OnOfficeAdapter\Query\FieldBuilder; -use Katalam\OnOfficeAdapter\Repositories\FieldRepository as RootRepository; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponsePage; +use Innobrain\OnOfficeAdapter\Query\FieldBuilder; +use Innobrain\OnOfficeAdapter\Repositories\FieldRepository as RootRepository; /** * @see RootRepository diff --git a/src/Facades/FileRepository.php b/src/Facades/FileRepository.php index d0cc475..53e602d 100644 --- a/src/Facades/FileRepository.php +++ b/src/Facades/FileRepository.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades; +namespace Innobrain\OnOfficeAdapter\Facades; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; -use Katalam\OnOfficeAdapter\Query\UploadBuilder; -use Katalam\OnOfficeAdapter\Repositories\FileRepository as RootRepository; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponsePage; +use Innobrain\OnOfficeAdapter\Query\UploadBuilder; +use Innobrain\OnOfficeAdapter\Repositories\FileRepository as RootRepository; /** * @see RootRepository diff --git a/src/Facades/MarketplaceRepository.php b/src/Facades/MarketplaceRepository.php index 63f828a..4adf189 100644 --- a/src/Facades/MarketplaceRepository.php +++ b/src/Facades/MarketplaceRepository.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades; +namespace Innobrain\OnOfficeAdapter\Facades; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; -use Katalam\OnOfficeAdapter\Query\MarketplaceBuilder; -use Katalam\OnOfficeAdapter\Repositories\MarketplaceRepository as RootRepository; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponsePage; +use Innobrain\OnOfficeAdapter\Query\MarketplaceBuilder; +use Innobrain\OnOfficeAdapter\Repositories\MarketplaceRepository as RootRepository; /** * @see RootRepository diff --git a/src/Facades/RelationRepository.php b/src/Facades/RelationRepository.php index 1ffbb04..d9466b0 100644 --- a/src/Facades/RelationRepository.php +++ b/src/Facades/RelationRepository.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades; +namespace Innobrain\OnOfficeAdapter\Facades; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; -use Katalam\OnOfficeAdapter\Query\RelationBuilder; -use Katalam\OnOfficeAdapter\Repositories\RelationRepository as RootRepository; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponsePage; +use Innobrain\OnOfficeAdapter\Query\RelationBuilder; +use Innobrain\OnOfficeAdapter\Repositories\RelationRepository as RootRepository; /** * @see RootRepository diff --git a/src/Facades/SearchCriteriaRepository.php b/src/Facades/SearchCriteriaRepository.php index 0dffdef..a0d21c3 100644 --- a/src/Facades/SearchCriteriaRepository.php +++ b/src/Facades/SearchCriteriaRepository.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades; +namespace Innobrain\OnOfficeAdapter\Facades; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; -use Katalam\OnOfficeAdapter\Query\SearchCriteriaBuilder; -use Katalam\OnOfficeAdapter\Repositories\SearchCriteriaRepository as RootRepository; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponsePage; +use Innobrain\OnOfficeAdapter\Query\SearchCriteriaBuilder; +use Innobrain\OnOfficeAdapter\Repositories\SearchCriteriaRepository as RootRepository; /** * @see RootRepository diff --git a/src/Facades/SettingRepository.php b/src/Facades/SettingRepository.php index 8799e03..8d27009 100644 --- a/src/Facades/SettingRepository.php +++ b/src/Facades/SettingRepository.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades; +namespace Innobrain\OnOfficeAdapter\Facades; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; -use Katalam\OnOfficeAdapter\Query\ActionBuilder; -use Katalam\OnOfficeAdapter\Query\ImprintBuilder; -use Katalam\OnOfficeAdapter\Query\RegionBuilder; -use Katalam\OnOfficeAdapter\Query\UserBuilder; -use Katalam\OnOfficeAdapter\Repositories\SettingRepository as RootRepository; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponsePage; +use Innobrain\OnOfficeAdapter\Query\ActionBuilder; +use Innobrain\OnOfficeAdapter\Query\ImprintBuilder; +use Innobrain\OnOfficeAdapter\Query\RegionBuilder; +use Innobrain\OnOfficeAdapter\Query\UserBuilder; +use Innobrain\OnOfficeAdapter\Repositories\SettingRepository as RootRepository; /** * @see RootRepository diff --git a/src/Facades/Testing/RecordFactories/ActionFactory.php b/src/Facades/Testing/RecordFactories/ActionFactory.php index 6d83ec5..ae40037 100644 --- a/src/Facades/Testing/RecordFactories/ActionFactory.php +++ b/src/Facades/Testing/RecordFactories/ActionFactory.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories; +namespace Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories; class ActionFactory extends BaseFactory { diff --git a/src/Facades/Testing/RecordFactories/ActivityFactory.php b/src/Facades/Testing/RecordFactories/ActivityFactory.php index 48c28ad..9366043 100644 --- a/src/Facades/Testing/RecordFactories/ActivityFactory.php +++ b/src/Facades/Testing/RecordFactories/ActivityFactory.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories; +namespace Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories; class ActivityFactory extends BaseFactory { diff --git a/src/Facades/Testing/RecordFactories/AddressFactory.php b/src/Facades/Testing/RecordFactories/AddressFactory.php index f1c7416..6368e2e 100644 --- a/src/Facades/Testing/RecordFactories/AddressFactory.php +++ b/src/Facades/Testing/RecordFactories/AddressFactory.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories; +namespace Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories; class AddressFactory extends BaseFactory { diff --git a/src/Facades/Testing/RecordFactories/BaseFactory.php b/src/Facades/Testing/RecordFactories/BaseFactory.php index e3afc5f..7f1da54 100644 --- a/src/Facades/Testing/RecordFactories/BaseFactory.php +++ b/src/Facades/Testing/RecordFactories/BaseFactory.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories; +namespace Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories; class BaseFactory { diff --git a/src/Facades/Testing/RecordFactories/Concerns/SuccessTrait.php b/src/Facades/Testing/RecordFactories/Concerns/SuccessTrait.php index 88bf6bc..ba44c14 100644 --- a/src/Facades/Testing/RecordFactories/Concerns/SuccessTrait.php +++ b/src/Facades/Testing/RecordFactories/Concerns/SuccessTrait.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\Concerns; +namespace Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\Concerns; trait SuccessTrait { diff --git a/src/Facades/Testing/RecordFactories/EstateFactory.php b/src/Facades/Testing/RecordFactories/EstateFactory.php index 2cee9b6..ba464da 100644 --- a/src/Facades/Testing/RecordFactories/EstateFactory.php +++ b/src/Facades/Testing/RecordFactories/EstateFactory.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories; +namespace Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories; class EstateFactory extends BaseFactory { diff --git a/src/Facades/Testing/RecordFactories/FieldFactory.php b/src/Facades/Testing/RecordFactories/FieldFactory.php index 1e0220a..2531500 100644 --- a/src/Facades/Testing/RecordFactories/FieldFactory.php +++ b/src/Facades/Testing/RecordFactories/FieldFactory.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories; +namespace Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories; class FieldFactory extends BaseFactory { diff --git a/src/Facades/Testing/RecordFactories/FileFactory.php b/src/Facades/Testing/RecordFactories/FileFactory.php index 57267a3..af57afb 100644 --- a/src/Facades/Testing/RecordFactories/FileFactory.php +++ b/src/Facades/Testing/RecordFactories/FileFactory.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories; +namespace Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\Concerns\SuccessTrait; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\Concerns\SuccessTrait; class FileFactory extends BaseFactory { diff --git a/src/Facades/Testing/RecordFactories/FileUploadFactory.php b/src/Facades/Testing/RecordFactories/FileUploadFactory.php index fd62a4e..c3c9d86 100644 --- a/src/Facades/Testing/RecordFactories/FileUploadFactory.php +++ b/src/Facades/Testing/RecordFactories/FileUploadFactory.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories; +namespace Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories; use Illuminate\Support\Str; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\Concerns\SuccessTrait; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\Concerns\SuccessTrait; class FileUploadFactory extends BaseFactory { diff --git a/src/Facades/Testing/RecordFactories/ImprintFactory.php b/src/Facades/Testing/RecordFactories/ImprintFactory.php index 49181d6..68ab07c 100644 --- a/src/Facades/Testing/RecordFactories/ImprintFactory.php +++ b/src/Facades/Testing/RecordFactories/ImprintFactory.php @@ -2,6 +2,6 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories; +namespace Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories; class ImprintFactory extends BaseFactory {} diff --git a/src/Facades/Testing/RecordFactories/MarketPlaceUnlockProviderFactory.php b/src/Facades/Testing/RecordFactories/MarketPlaceUnlockProviderFactory.php index bcbe596..3e41a21 100644 --- a/src/Facades/Testing/RecordFactories/MarketPlaceUnlockProviderFactory.php +++ b/src/Facades/Testing/RecordFactories/MarketPlaceUnlockProviderFactory.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories; +namespace Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\Concerns\SuccessTrait; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\Concerns\SuccessTrait; class MarketPlaceUnlockProviderFactory extends BaseFactory { diff --git a/src/Facades/Testing/RecordFactories/RegionFactory.php b/src/Facades/Testing/RecordFactories/RegionFactory.php index 926a77b..16c5aa1 100644 --- a/src/Facades/Testing/RecordFactories/RegionFactory.php +++ b/src/Facades/Testing/RecordFactories/RegionFactory.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories; +namespace Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories; class RegionFactory extends BaseFactory { diff --git a/src/Facades/Testing/RecordFactories/RelationFactory.php b/src/Facades/Testing/RecordFactories/RelationFactory.php index b133d77..913ba62 100644 --- a/src/Facades/Testing/RecordFactories/RelationFactory.php +++ b/src/Facades/Testing/RecordFactories/RelationFactory.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories; +namespace Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories; class RelationFactory extends BaseFactory { diff --git a/src/Facades/Testing/RecordFactories/SearchCriteriaFactory.php b/src/Facades/Testing/RecordFactories/SearchCriteriaFactory.php index 5fde63a..dc7be54 100644 --- a/src/Facades/Testing/RecordFactories/SearchCriteriaFactory.php +++ b/src/Facades/Testing/RecordFactories/SearchCriteriaFactory.php @@ -2,6 +2,6 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories; +namespace Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories; class SearchCriteriaFactory extends BaseFactory {} diff --git a/src/Facades/Testing/RecordFactories/UserFactory.php b/src/Facades/Testing/RecordFactories/UserFactory.php index dffc726..b2e0b34 100644 --- a/src/Facades/Testing/RecordFactories/UserFactory.php +++ b/src/Facades/Testing/RecordFactories/UserFactory.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories; +namespace Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories; class UserFactory extends BaseFactory { diff --git a/src/OnOfficeAdapterServiceProvider.php b/src/OnOfficeAdapterServiceProvider.php index c25d6b2..4627bf3 100644 --- a/src/OnOfficeAdapterServiceProvider.php +++ b/src/OnOfficeAdapterServiceProvider.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter; +namespace Innobrain\OnOfficeAdapter; use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Innobrain\OnOfficeAdapter\Services\OnOfficeService; use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; diff --git a/src/Query/ActionBuilder.php b/src/Query/ActionBuilder.php index 87a7409..448f76a 100644 --- a/src/Query/ActionBuilder.php +++ b/src/Query/ActionBuilder.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query; +namespace Innobrain\OnOfficeAdapter\Query; use Illuminate\Support\Collection; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; -use Katalam\OnOfficeAdapter\Query\Concerns\NonFilterable; -use Katalam\OnOfficeAdapter\Query\Concerns\NonOrderable; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Query\Concerns\NonFilterable; +use Innobrain\OnOfficeAdapter\Query\Concerns\NonOrderable; class ActionBuilder extends Builder { diff --git a/src/Query/ActivityBuilder.php b/src/Query/ActivityBuilder.php index c050038..dc25961 100644 --- a/src/Query/ActivityBuilder.php +++ b/src/Query/ActivityBuilder.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query; +namespace Innobrain\OnOfficeAdapter\Query; use Illuminate\Support\Collection; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; -use Katalam\OnOfficeAdapter\Query\Concerns\RecordIds; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Query\Concerns\RecordIds; +use Innobrain\OnOfficeAdapter\Services\OnOfficeService; use Throwable; class ActivityBuilder extends Builder diff --git a/src/Query/AddressBuilder.php b/src/Query/AddressBuilder.php index 9b8cf40..f6687bb 100644 --- a/src/Query/AddressBuilder.php +++ b/src/Query/AddressBuilder.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query; +namespace Innobrain\OnOfficeAdapter\Query; use Illuminate\Support\Collection; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceId; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; -use Katalam\OnOfficeAdapter\Query\Concerns\Input; -use Katalam\OnOfficeAdapter\Query\Concerns\RecordIds; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceId; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Query\Concerns\Input; +use Innobrain\OnOfficeAdapter\Query\Concerns\RecordIds; +use Innobrain\OnOfficeAdapter\Services\OnOfficeService; use Throwable; class AddressBuilder extends Builder diff --git a/src/Query/Builder.php b/src/Query/Builder.php index 9319812..5ed65d9 100644 --- a/src/Query/Builder.php +++ b/src/Query/Builder.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query; +namespace Innobrain\OnOfficeAdapter\Query; use GuzzleHttp\Psr7\Response as Psr7Response; use Illuminate\Http\Client\Response; @@ -11,13 +11,13 @@ use Illuminate\Support\Str; use Illuminate\Support\Traits\Conditionable; use JsonException; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; -use Katalam\OnOfficeAdapter\Exceptions\StrayRequestException; -use Katalam\OnOfficeAdapter\Query\Concerns\BuilderInterface; -use Katalam\OnOfficeAdapter\Repositories\BaseRepository; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Exceptions\StrayRequestException; +use Innobrain\OnOfficeAdapter\Query\Concerns\BuilderInterface; +use Innobrain\OnOfficeAdapter\Repositories\BaseRepository; +use Innobrain\OnOfficeAdapter\Services\OnOfficeService; use Throwable; class Builder implements BuilderInterface diff --git a/src/Query/Concerns/BuilderInterface.php b/src/Query/Concerns/BuilderInterface.php index b37f71f..d787785 100644 --- a/src/Query/Concerns/BuilderInterface.php +++ b/src/Query/Concerns/BuilderInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query\Concerns; +namespace Innobrain\OnOfficeAdapter\Query\Concerns; use Illuminate\Support\Collection; diff --git a/src/Query/Concerns/Input.php b/src/Query/Concerns/Input.php index a8e2109..1337311 100644 --- a/src/Query/Concerns/Input.php +++ b/src/Query/Concerns/Input.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query\Concerns; +namespace Innobrain\OnOfficeAdapter\Query\Concerns; trait Input { diff --git a/src/Query/Concerns/NonFilterable.php b/src/Query/Concerns/NonFilterable.php index 790c875..1db2ef3 100644 --- a/src/Query/Concerns/NonFilterable.php +++ b/src/Query/Concerns/NonFilterable.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query\Concerns; +namespace Innobrain\OnOfficeAdapter\Query\Concerns; trait NonFilterable { diff --git a/src/Query/Concerns/NonLimitable.php b/src/Query/Concerns/NonLimitable.php index 2d8276f..6f40741 100644 --- a/src/Query/Concerns/NonLimitable.php +++ b/src/Query/Concerns/NonLimitable.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query\Concerns; +namespace Innobrain\OnOfficeAdapter\Query\Concerns; trait NonLimitable { diff --git a/src/Query/Concerns/NonOrderable.php b/src/Query/Concerns/NonOrderable.php index 831ca2b..bb78195 100644 --- a/src/Query/Concerns/NonOrderable.php +++ b/src/Query/Concerns/NonOrderable.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query\Concerns; +namespace Innobrain\OnOfficeAdapter\Query\Concerns; trait NonOrderable { diff --git a/src/Query/Concerns/NonSelectable.php b/src/Query/Concerns/NonSelectable.php index 473ea87..3e4314a 100644 --- a/src/Query/Concerns/NonSelectable.php +++ b/src/Query/Concerns/NonSelectable.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query\Concerns; +namespace Innobrain\OnOfficeAdapter\Query\Concerns; trait NonSelectable { diff --git a/src/Query/Concerns/RecordIds.php b/src/Query/Concerns/RecordIds.php index a6c45f0..bd63333 100644 --- a/src/Query/Concerns/RecordIds.php +++ b/src/Query/Concerns/RecordIds.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query\Concerns; +namespace Innobrain\OnOfficeAdapter\Query\Concerns; use Illuminate\Support\Arr; diff --git a/src/Query/Concerns/RelationTypes.php b/src/Query/Concerns/RelationTypes.php index 8045396..5dda452 100644 --- a/src/Query/Concerns/RelationTypes.php +++ b/src/Query/Concerns/RelationTypes.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query\Concerns; +namespace Innobrain\OnOfficeAdapter\Query\Concerns; use Illuminate\Support\Arr; -use Katalam\OnOfficeAdapter\Enums\OnOfficeRelationType; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeRelationType; trait RelationTypes { diff --git a/src/Query/Concerns/UploadInBlocks.php b/src/Query/Concerns/UploadInBlocks.php index 2938fe7..1abb9f1 100644 --- a/src/Query/Concerns/UploadInBlocks.php +++ b/src/Query/Concerns/UploadInBlocks.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query\Concerns; +namespace Innobrain\OnOfficeAdapter\Query\Concerns; trait UploadInBlocks { diff --git a/src/Query/EstateBuilder.php b/src/Query/EstateBuilder.php index a308aff..dca1358 100644 --- a/src/Query/EstateBuilder.php +++ b/src/Query/EstateBuilder.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query; +namespace Innobrain\OnOfficeAdapter\Query; use Illuminate\Support\Collection; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Services\OnOfficeService; use Throwable; class EstateBuilder extends Builder diff --git a/src/Query/EstateFileBuilder.php b/src/Query/EstateFileBuilder.php index 2445b60..e8284b5 100644 --- a/src/Query/EstateFileBuilder.php +++ b/src/Query/EstateFileBuilder.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query; +namespace Innobrain\OnOfficeAdapter\Query; use Illuminate\Support\Collection; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceId; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceId; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; use Throwable; class EstateFileBuilder extends Builder diff --git a/src/Query/FieldBuilder.php b/src/Query/FieldBuilder.php index 6d1c63c..5371a5d 100644 --- a/src/Query/FieldBuilder.php +++ b/src/Query/FieldBuilder.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query; +namespace Innobrain\OnOfficeAdapter\Query; use Illuminate\Support\Arr; use Illuminate\Support\Collection; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; class FieldBuilder extends Builder { diff --git a/src/Query/ImprintBuilder.php b/src/Query/ImprintBuilder.php index a53cdb0..c2c916e 100644 --- a/src/Query/ImprintBuilder.php +++ b/src/Query/ImprintBuilder.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query; +namespace Innobrain\OnOfficeAdapter\Query; use Illuminate\Support\Collection; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; -use Katalam\OnOfficeAdapter\Query\Concerns\NonFilterable; -use Katalam\OnOfficeAdapter\Query\Concerns\NonOrderable; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Query\Concerns\NonFilterable; +use Innobrain\OnOfficeAdapter\Query\Concerns\NonOrderable; +use Innobrain\OnOfficeAdapter\Services\OnOfficeService; class ImprintBuilder extends Builder { diff --git a/src/Query/MarketplaceBuilder.php b/src/Query/MarketplaceBuilder.php index 6f95b9c..cef7a0a 100644 --- a/src/Query/MarketplaceBuilder.php +++ b/src/Query/MarketplaceBuilder.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query; +namespace Innobrain\OnOfficeAdapter\Query; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Services\OnOfficeService; use Throwable; class MarketplaceBuilder extends Builder diff --git a/src/Query/RegionBuilder.php b/src/Query/RegionBuilder.php index 42a60e7..df613aa 100644 --- a/src/Query/RegionBuilder.php +++ b/src/Query/RegionBuilder.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query; +namespace Innobrain\OnOfficeAdapter\Query; use Illuminate\Support\Collection; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; -use Katalam\OnOfficeAdapter\Query\Concerns\NonFilterable; -use Katalam\OnOfficeAdapter\Query\Concerns\NonOrderable; -use Katalam\OnOfficeAdapter\Query\Concerns\NonSelectable; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Query\Concerns\NonFilterable; +use Innobrain\OnOfficeAdapter\Query\Concerns\NonOrderable; +use Innobrain\OnOfficeAdapter\Query\Concerns\NonSelectable; use Throwable; class RegionBuilder extends Builder diff --git a/src/Query/RelationBuilder.php b/src/Query/RelationBuilder.php index 8989eff..9297ae8 100644 --- a/src/Query/RelationBuilder.php +++ b/src/Query/RelationBuilder.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query; +namespace Innobrain\OnOfficeAdapter\Query; use Illuminate\Support\Collection; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; -use Katalam\OnOfficeAdapter\Query\Concerns\NonFilterable; -use Katalam\OnOfficeAdapter\Query\Concerns\NonOrderable; -use Katalam\OnOfficeAdapter\Query\Concerns\NonSelectable; -use Katalam\OnOfficeAdapter\Query\Concerns\RelationTypes; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Query\Concerns\NonFilterable; +use Innobrain\OnOfficeAdapter\Query\Concerns\NonOrderable; +use Innobrain\OnOfficeAdapter\Query\Concerns\NonSelectable; +use Innobrain\OnOfficeAdapter\Query\Concerns\RelationTypes; +use Innobrain\OnOfficeAdapter\Services\OnOfficeService; use Throwable; class RelationBuilder extends Builder diff --git a/src/Query/SearchCriteriaBuilder.php b/src/Query/SearchCriteriaBuilder.php index b8bbbbd..2a6fe2a 100644 --- a/src/Query/SearchCriteriaBuilder.php +++ b/src/Query/SearchCriteriaBuilder.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query; +namespace Innobrain\OnOfficeAdapter\Query; use Illuminate\Support\Arr; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Services\OnOfficeService; use Throwable; class SearchCriteriaBuilder extends Builder diff --git a/src/Query/UploadBuilder.php b/src/Query/UploadBuilder.php index 1f520ee..2d18695 100644 --- a/src/Query/UploadBuilder.php +++ b/src/Query/UploadBuilder.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query; +namespace Innobrain\OnOfficeAdapter\Query; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; -use Katalam\OnOfficeAdapter\Query\Concerns\NonFilterable; -use Katalam\OnOfficeAdapter\Query\Concerns\NonOrderable; -use Katalam\OnOfficeAdapter\Query\Concerns\NonSelectable; -use Katalam\OnOfficeAdapter\Query\Concerns\UploadInBlocks; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Query\Concerns\NonFilterable; +use Innobrain\OnOfficeAdapter\Query\Concerns\NonOrderable; +use Innobrain\OnOfficeAdapter\Query\Concerns\NonSelectable; +use Innobrain\OnOfficeAdapter\Query\Concerns\UploadInBlocks; +use Innobrain\OnOfficeAdapter\Services\OnOfficeService; use Throwable; class UploadBuilder extends Builder diff --git a/src/Query/UserBuilder.php b/src/Query/UserBuilder.php index d408986..f4943b8 100644 --- a/src/Query/UserBuilder.php +++ b/src/Query/UserBuilder.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Query; +namespace Innobrain\OnOfficeAdapter\Query; use Illuminate\Support\Collection; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Services\OnOfficeService; use Throwable; class UserBuilder extends Builder diff --git a/src/Repositories/ActivityRepository.php b/src/Repositories/ActivityRepository.php index 5e4ed10..b333f4c 100644 --- a/src/Repositories/ActivityRepository.php +++ b/src/Repositories/ActivityRepository.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Repositories; +namespace Innobrain\OnOfficeAdapter\Repositories; -use Katalam\OnOfficeAdapter\Query\ActivityBuilder; +use Innobrain\OnOfficeAdapter\Query\ActivityBuilder; class ActivityRepository extends BaseRepository { diff --git a/src/Repositories/AddressRepository.php b/src/Repositories/AddressRepository.php index 2f1e035..a0dc43e 100644 --- a/src/Repositories/AddressRepository.php +++ b/src/Repositories/AddressRepository.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Repositories; +namespace Innobrain\OnOfficeAdapter\Repositories; -use Katalam\OnOfficeAdapter\Query\AddressBuilder; +use Innobrain\OnOfficeAdapter\Query\AddressBuilder; class AddressRepository extends BaseRepository { diff --git a/src/Repositories/BaseRepository.php b/src/Repositories/BaseRepository.php index 239efef..bf118f4 100644 --- a/src/Repositories/BaseRepository.php +++ b/src/Repositories/BaseRepository.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Repositories; +namespace Innobrain\OnOfficeAdapter\Repositories; use Illuminate\Support\Arr; use Illuminate\Support\Collection; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceId; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Query\Builder; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponsePage; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceId; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Query\Builder; use PHPUnit\Framework\Assert as PHPUnit; class BaseRepository diff --git a/src/Repositories/EstateRepository.php b/src/Repositories/EstateRepository.php index 4a4173e..9e13625 100644 --- a/src/Repositories/EstateRepository.php +++ b/src/Repositories/EstateRepository.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Repositories; +namespace Innobrain\OnOfficeAdapter\Repositories; -use Katalam\OnOfficeAdapter\Query\EstateBuilder; -use Katalam\OnOfficeAdapter\Query\EstateFileBuilder; +use Innobrain\OnOfficeAdapter\Query\EstateBuilder; +use Innobrain\OnOfficeAdapter\Query\EstateFileBuilder; class EstateRepository extends BaseRepository { diff --git a/src/Repositories/FieldRepository.php b/src/Repositories/FieldRepository.php index 2784896..dcd2f7d 100644 --- a/src/Repositories/FieldRepository.php +++ b/src/Repositories/FieldRepository.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Repositories; +namespace Innobrain\OnOfficeAdapter\Repositories; -use Katalam\OnOfficeAdapter\Query\FieldBuilder; +use Innobrain\OnOfficeAdapter\Query\FieldBuilder; class FieldRepository extends BaseRepository { diff --git a/src/Repositories/FileRepository.php b/src/Repositories/FileRepository.php index eed96d1..7407a60 100644 --- a/src/Repositories/FileRepository.php +++ b/src/Repositories/FileRepository.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Repositories; +namespace Innobrain\OnOfficeAdapter\Repositories; -use Katalam\OnOfficeAdapter\Query\Builder; -use Katalam\OnOfficeAdapter\Query\UploadBuilder; +use Innobrain\OnOfficeAdapter\Query\Builder; +use Innobrain\OnOfficeAdapter\Query\UploadBuilder; class FileRepository extends BaseRepository { diff --git a/src/Repositories/MarketplaceRepository.php b/src/Repositories/MarketplaceRepository.php index a2c3102..be71e91 100644 --- a/src/Repositories/MarketplaceRepository.php +++ b/src/Repositories/MarketplaceRepository.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Repositories; +namespace Innobrain\OnOfficeAdapter\Repositories; -use Katalam\OnOfficeAdapter\Query\MarketplaceBuilder; +use Innobrain\OnOfficeAdapter\Query\MarketplaceBuilder; class MarketplaceRepository extends BaseRepository { diff --git a/src/Repositories/RelationRepository.php b/src/Repositories/RelationRepository.php index c6bb595..1e87f38 100644 --- a/src/Repositories/RelationRepository.php +++ b/src/Repositories/RelationRepository.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Repositories; +namespace Innobrain\OnOfficeAdapter\Repositories; -use Katalam\OnOfficeAdapter\Query\RelationBuilder; +use Innobrain\OnOfficeAdapter\Query\RelationBuilder; class RelationRepository extends BaseRepository { diff --git a/src/Repositories/SearchCriteriaRepository.php b/src/Repositories/SearchCriteriaRepository.php index 430d4f3..0df8553 100644 --- a/src/Repositories/SearchCriteriaRepository.php +++ b/src/Repositories/SearchCriteriaRepository.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Repositories; +namespace Innobrain\OnOfficeAdapter\Repositories; -use Katalam\OnOfficeAdapter\Query\SearchCriteriaBuilder; +use Innobrain\OnOfficeAdapter\Query\SearchCriteriaBuilder; class SearchCriteriaRepository extends BaseRepository { diff --git a/src/Repositories/SettingRepository.php b/src/Repositories/SettingRepository.php index 72779e3..6c41f54 100644 --- a/src/Repositories/SettingRepository.php +++ b/src/Repositories/SettingRepository.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Repositories; +namespace Innobrain\OnOfficeAdapter\Repositories; -use Katalam\OnOfficeAdapter\Query\ActionBuilder; -use Katalam\OnOfficeAdapter\Query\ImprintBuilder; -use Katalam\OnOfficeAdapter\Query\RegionBuilder; -use Katalam\OnOfficeAdapter\Query\UserBuilder; +use Innobrain\OnOfficeAdapter\Query\ActionBuilder; +use Innobrain\OnOfficeAdapter\Query\ImprintBuilder; +use Innobrain\OnOfficeAdapter\Query\RegionBuilder; +use Innobrain\OnOfficeAdapter\Query\UserBuilder; class SettingRepository extends BaseRepository { diff --git a/src/Services/OnOfficeParameterConst.php b/src/Services/OnOfficeParameterConst.php index be60b01..bd71bdb 100644 --- a/src/Services/OnOfficeParameterConst.php +++ b/src/Services/OnOfficeParameterConst.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Services; +namespace Innobrain\OnOfficeAdapter\Services; trait OnOfficeParameterConst { diff --git a/src/Services/OnOfficeService.php b/src/Services/OnOfficeService.php index 3bbe227..6a9e3f6 100644 --- a/src/Services/OnOfficeService.php +++ b/src/Services/OnOfficeService.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Services; +namespace Innobrain\OnOfficeAdapter\Services; use Illuminate\Http\Client\Response; use Illuminate\Support\Carbon; @@ -10,10 +10,10 @@ use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Log; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceId; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceId; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; class OnOfficeService { diff --git a/tests/ArchTest.php b/tests/ArchTest.php index 849d3ca..9c1aa86 100644 --- a/tests/ArchTest.php +++ b/tests/ArchTest.php @@ -3,7 +3,7 @@ declare(strict_types=1); arch('strict types') - ->expect('Katalam\OnOfficeAdapter') + ->expect('Innobrain\OnOfficeAdapter') ->toUseStrictTypes(); arch('it will not use debugging functions') diff --git a/tests/Dtos/OnOfficeResponsePageTest.php b/tests/Dtos/OnOfficeResponsePageTest.php index 36f5571..1b2cabe 100644 --- a/tests/Dtos/OnOfficeResponsePageTest.php +++ b/tests/Dtos/OnOfficeResponsePageTest.php @@ -3,11 +3,11 @@ declare(strict_types=1); use Illuminate\Support\Collection; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceId; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponsePage; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceId; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; it('works', function () { $recordFactories = new Collection; diff --git a/tests/Dtos/OnOfficeResponseTest.php b/tests/Dtos/OnOfficeResponseTest.php index 122b434..23b0ae2 100644 --- a/tests/Dtos/OnOfficeResponseTest.php +++ b/tests/Dtos/OnOfficeResponseTest.php @@ -3,11 +3,11 @@ declare(strict_types=1); use Illuminate\Support\Collection; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponsePage; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponsePage; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; it('works', function () { $recordFactories = new Collection; diff --git a/tests/Enums/OnOfficeErrorTest.php b/tests/Enums/OnOfficeErrorTest.php index b4b9d93..9d61867 100644 --- a/tests/Enums/OnOfficeErrorTest.php +++ b/tests/Enums/OnOfficeErrorTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Katalam\OnOfficeAdapter\Enums\OnOfficeError; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeError; describe('to string', function () { it('can stringify an error', function (OnOfficeError $error) { diff --git a/tests/Exceptions/OnOfficeExceptionTest.php b/tests/Exceptions/OnOfficeExceptionTest.php index 12e053a..e91df62 100644 --- a/tests/Exceptions/OnOfficeExceptionTest.php +++ b/tests/Exceptions/OnOfficeExceptionTest.php @@ -2,8 +2,8 @@ declare(strict_types=1); -use Katalam\OnOfficeAdapter\Enums\OnOfficeError; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeError; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; describe('is response error', function () { it('can be created', function () { diff --git a/tests/Pest.php b/tests/Pest.php index 2c8b447..54ae622 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -2,6 +2,6 @@ declare(strict_types=1); -use Katalam\OnOfficeAdapter\Tests\TestCase; +use Innobrain\OnOfficeAdapter\Tests\TestCase; uses(TestCase::class)->in(__DIR__); diff --git a/tests/Query/AddressBuilderTest.php b/tests/Query/AddressBuilderTest.php index b70af6f..b4c314e 100644 --- a/tests/Query/AddressBuilderTest.php +++ b/tests/Query/AddressBuilderTest.php @@ -2,8 +2,8 @@ declare(strict_types=1); -use Katalam\OnOfficeAdapter\Query\AddressBuilder; -use Katalam\OnOfficeAdapter\Repositories\AddressRepository; +use Innobrain\OnOfficeAdapter\Query\AddressBuilder; +use Innobrain\OnOfficeAdapter\Repositories\AddressRepository; describe('recordIds', function () { it('should set the recordIds property to the given recordIds', function () { diff --git a/tests/Query/BuilderTest.php b/tests/Query/BuilderTest.php index 66efc88..000554b 100644 --- a/tests/Query/BuilderTest.php +++ b/tests/Query/BuilderTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Katalam\OnOfficeAdapter\Query\Builder; +use Innobrain\OnOfficeAdapter\Query\Builder; describe('select', function () { it('should set the columns property to the given columns', function () { diff --git a/tests/Query/FieldBuilderTest.php b/tests/Query/FieldBuilderTest.php index 0b521f6..beeaaf1 100644 --- a/tests/Query/FieldBuilderTest.php +++ b/tests/Query/FieldBuilderTest.php @@ -2,8 +2,8 @@ declare(strict_types=1); -use Katalam\OnOfficeAdapter\Query\FieldBuilder; -use Katalam\OnOfficeAdapter\Repositories\FieldRepository; +use Innobrain\OnOfficeAdapter\Query\FieldBuilder; +use Innobrain\OnOfficeAdapter\Repositories\FieldRepository; describe('withModules', function () { it('should set the modules property to the given modules', function () { diff --git a/tests/Query/RelationBuilderTest.php b/tests/Query/RelationBuilderTest.php index ab03c9e..2199c39 100644 --- a/tests/Query/RelationBuilderTest.php +++ b/tests/Query/RelationBuilderTest.php @@ -2,9 +2,9 @@ declare(strict_types=1); -use Katalam\OnOfficeAdapter\Enums\OnOfficeRelationType; -use Katalam\OnOfficeAdapter\Query\RelationBuilder; -use Katalam\OnOfficeAdapter\Repositories\RelationRepository; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeRelationType; +use Innobrain\OnOfficeAdapter\Query\RelationBuilder; +use Innobrain\OnOfficeAdapter\Repositories\RelationRepository; describe('childIds', function () { it('should set the childIds property to the given childIds', function () { diff --git a/tests/Query/UploadBuilderTest.php b/tests/Query/UploadBuilderTest.php index 5a41b25..57afd79 100644 --- a/tests/Query/UploadBuilderTest.php +++ b/tests/Query/UploadBuilderTest.php @@ -4,10 +4,10 @@ use Illuminate\Http\Client\Request; use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Query\UploadBuilder; -use Katalam\OnOfficeAdapter\Repositories\FileRepository; -use Katalam\OnOfficeAdapter\Tests\Stubs\LinkDataResponse; -use Katalam\OnOfficeAdapter\Tests\Stubs\UploadFileResponse; +use Innobrain\OnOfficeAdapter\Query\UploadBuilder; +use Innobrain\OnOfficeAdapter\Repositories\FileRepository; +use Innobrain\OnOfficeAdapter\Tests\Stubs\LinkDataResponse; +use Innobrain\OnOfficeAdapter\Tests\Stubs\UploadFileResponse; describe('work', function () { it('can save', function () { diff --git a/tests/Repositories/ActivityRepositoryTest.php b/tests/Repositories/ActivityRepositoryTest.php index c02c587..85c0f6e 100644 --- a/tests/Repositories/ActivityRepositoryTest.php +++ b/tests/Repositories/ActivityRepositoryTest.php @@ -3,9 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\ActivityRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadActivityResponse; +use Innobrain\OnOfficeAdapter\Facades\ActivityRepository; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; +use Innobrain\OnOfficeAdapter\Tests\Stubs\ReadActivityResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/AddressRepositoryTest.php b/tests/Repositories/AddressRepositoryTest.php index 89e0364..4670310 100644 --- a/tests/Repositories/AddressRepositoryTest.php +++ b/tests/Repositories/AddressRepositoryTest.php @@ -3,9 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\AddressRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; +use Innobrain\OnOfficeAdapter\Facades\AddressRepository; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\AddressFactory; +use Innobrain\OnOfficeAdapter\Tests\Stubs\ReadAddressResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/BaseRepositoryTest.php b/tests/Repositories/BaseRepositoryTest.php index 6e3b3ac..eeee8ba 100644 --- a/tests/Repositories/BaseRepositoryTest.php +++ b/tests/Repositories/BaseRepositoryTest.php @@ -4,11 +4,11 @@ use Illuminate\Support\Collection; use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeRequest; -use Katalam\OnOfficeAdapter\Dtos\OnOfficeResponse; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Repositories\BaseRepository; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; +use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponse; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Repositories\BaseRepository; describe('stray requests', function () { it('will set the preventStrayRequests property when calling preventStrayRequests default', function () { diff --git a/tests/Repositories/EstateFileRepositoryTest.php b/tests/Repositories/EstateFileRepositoryTest.php index 47d9e1f..1ce40ef 100644 --- a/tests/Repositories/EstateFileRepositoryTest.php +++ b/tests/Repositories/EstateFileRepositoryTest.php @@ -3,9 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\EstateRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\FileFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetEstatePicturesResponse; +use Innobrain\OnOfficeAdapter\Facades\EstateRepository; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\FileFactory; +use Innobrain\OnOfficeAdapter\Tests\Stubs\GetEstatePicturesResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/EstateRepositoryTest.php b/tests/Repositories/EstateRepositoryTest.php index 4bcdbc0..c274f66 100644 --- a/tests/Repositories/EstateRepositoryTest.php +++ b/tests/Repositories/EstateRepositoryTest.php @@ -3,9 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\EstateRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadEstateResponse; +use Innobrain\OnOfficeAdapter\Facades\EstateRepository; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; +use Innobrain\OnOfficeAdapter\Tests\Stubs\ReadEstateResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/FieldRepositoryTest.php b/tests/Repositories/FieldRepositoryTest.php index bcfb07e..6b6fdea 100644 --- a/tests/Repositories/FieldRepositoryTest.php +++ b/tests/Repositories/FieldRepositoryTest.php @@ -3,9 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\FieldRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\FieldFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetFieldsResponse; +use Innobrain\OnOfficeAdapter\Facades\FieldRepository; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\FieldFactory; +use Innobrain\OnOfficeAdapter\Tests\Stubs\GetFieldsResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/ImprintRepositoryTest.php b/tests/Repositories/ImprintRepositoryTest.php index 34711ed..032563e 100644 --- a/tests/Repositories/ImprintRepositoryTest.php +++ b/tests/Repositories/ImprintRepositoryTest.php @@ -3,9 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\SettingRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\ImprintFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetImprintResponse; +use Innobrain\OnOfficeAdapter\Facades\SettingRepository; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\ImprintFactory; +use Innobrain\OnOfficeAdapter\Tests\Stubs\GetImprintResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/MarketplaceRepositoryTest.php b/tests/Repositories/MarketplaceRepositoryTest.php index 9c2b3da..e6439ae 100644 --- a/tests/Repositories/MarketplaceRepositoryTest.php +++ b/tests/Repositories/MarketplaceRepositoryTest.php @@ -3,9 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\MarketplaceRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\MarketPlaceUnlockProviderFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\DoUnlockProviderResponse; +use Innobrain\OnOfficeAdapter\Facades\MarketplaceRepository; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\MarketPlaceUnlockProviderFactory; +use Innobrain\OnOfficeAdapter\Tests\Stubs\DoUnlockProviderResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/RegionRepositoryTest.php b/tests/Repositories/RegionRepositoryTest.php index 3662811..49366a1 100644 --- a/tests/Repositories/RegionRepositoryTest.php +++ b/tests/Repositories/RegionRepositoryTest.php @@ -3,9 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\SettingRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\RegionFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetRegionsResponse; +use Innobrain\OnOfficeAdapter\Facades\SettingRepository; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\RegionFactory; +use Innobrain\OnOfficeAdapter\Tests\Stubs\GetRegionsResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/RelationRepositoryTest.php b/tests/Repositories/RelationRepositoryTest.php index f858780..d184b5d 100644 --- a/tests/Repositories/RelationRepositoryTest.php +++ b/tests/Repositories/RelationRepositoryTest.php @@ -3,10 +3,10 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Enums\OnOfficeRelationType; -use Katalam\OnOfficeAdapter\Facades\RelationRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\RelationFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetEstateAgentsResponse; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeRelationType; +use Innobrain\OnOfficeAdapter\Facades\RelationRepository; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\RelationFactory; +use Innobrain\OnOfficeAdapter\Tests\Stubs\GetEstateAgentsResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/SearchCriteriaRepositoryTest.php b/tests/Repositories/SearchCriteriaRepositoryTest.php index 5030e6a..811b838 100644 --- a/tests/Repositories/SearchCriteriaRepositoryTest.php +++ b/tests/Repositories/SearchCriteriaRepositoryTest.php @@ -3,9 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\SearchCriteriaRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\SearchCriteriaFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\GetSearchCriteriaResponse; +use Innobrain\OnOfficeAdapter\Facades\SearchCriteriaRepository; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\SearchCriteriaFactory; +use Innobrain\OnOfficeAdapter\Tests\Stubs\GetSearchCriteriaResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/UploadRepositoryTest.php b/tests/Repositories/UploadRepositoryTest.php index 0df510a..717349f 100644 --- a/tests/Repositories/UploadRepositoryTest.php +++ b/tests/Repositories/UploadRepositoryTest.php @@ -3,9 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\FileRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\FileFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\UploadFileResponse; +use Innobrain\OnOfficeAdapter\Facades\FileRepository; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\FileFactory; +use Innobrain\OnOfficeAdapter\Tests\Stubs\UploadFileResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Repositories/UserRepositoryTest.php b/tests/Repositories/UserRepositoryTest.php index 922f1ab..78dc94a 100644 --- a/tests/Repositories/UserRepositoryTest.php +++ b/tests/Repositories/UserRepositoryTest.php @@ -3,9 +3,9 @@ declare(strict_types=1); use Illuminate\Support\Facades\Http; -use Katalam\OnOfficeAdapter\Facades\SettingRepository; -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\UserFactory; -use Katalam\OnOfficeAdapter\Tests\Stubs\ReadUserResponse; +use Innobrain\OnOfficeAdapter\Facades\SettingRepository; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\UserFactory; +use Innobrain\OnOfficeAdapter\Tests\Stubs\ReadUserResponse; describe('fake responses', function () { test('get', function () { diff --git a/tests/Services/OnOfficeServiceTest.php b/tests/Services/OnOfficeServiceTest.php index 2749f24..b6adc8d 100644 --- a/tests/Services/OnOfficeServiceTest.php +++ b/tests/Services/OnOfficeServiceTest.php @@ -6,12 +6,12 @@ use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; -use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; -use Katalam\OnOfficeAdapter\Enums\OnOfficeError; -use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; -use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; -use Katalam\OnOfficeAdapter\Services\OnOfficeService; -use Katalam\OnOfficeAdapter\Tests\Stubs\InvalidHmacResponse; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeAction; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeError; +use Innobrain\OnOfficeAdapter\Enums\OnOfficeResourceType; +use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; +use Innobrain\OnOfficeAdapter\Services\OnOfficeService; +use Innobrain\OnOfficeAdapter\Tests\Stubs\InvalidHmacResponse; describe('credentials', function () { it('can use the config once', function () { diff --git a/tests/Stubs/CreateAddressResponse.php b/tests/Stubs/CreateAddressResponse.php index 4948f9e..610e8ed 100644 --- a/tests/Stubs/CreateAddressResponse.php +++ b/tests/Stubs/CreateAddressResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/DoUnlockProviderResponse.php b/tests/Stubs/DoUnlockProviderResponse.php index 63d0468..7f4f227 100644 --- a/tests/Stubs/DoUnlockProviderResponse.php +++ b/tests/Stubs/DoUnlockProviderResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/EmptyGetEstatePicturesResponse.php b/tests/Stubs/EmptyGetEstatePicturesResponse.php index e26f852..63a6896 100644 --- a/tests/Stubs/EmptyGetEstatePicturesResponse.php +++ b/tests/Stubs/EmptyGetEstatePicturesResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/EmptyReadEstateResponse.php b/tests/Stubs/EmptyReadEstateResponse.php index 459dff6..b3acd8e 100644 --- a/tests/Stubs/EmptyReadEstateResponse.php +++ b/tests/Stubs/EmptyReadEstateResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/GetEstateAgentsDetailedResponse.php b/tests/Stubs/GetEstateAgentsDetailedResponse.php index 3325078..d52c41e 100644 --- a/tests/Stubs/GetEstateAgentsDetailedResponse.php +++ b/tests/Stubs/GetEstateAgentsDetailedResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/GetEstateAgentsResponse.php b/tests/Stubs/GetEstateAgentsResponse.php index ad2a1cb..31bf80b 100644 --- a/tests/Stubs/GetEstateAgentsResponse.php +++ b/tests/Stubs/GetEstateAgentsResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/GetEstatePictureResponse.php b/tests/Stubs/GetEstatePictureResponse.php index e0a0633..239a723 100644 --- a/tests/Stubs/GetEstatePictureResponse.php +++ b/tests/Stubs/GetEstatePictureResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/GetEstatePicturesResponse.php b/tests/Stubs/GetEstatePicturesResponse.php index 2e8943d..72dfcd6 100644 --- a/tests/Stubs/GetEstatePicturesResponse.php +++ b/tests/Stubs/GetEstatePicturesResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/GetFieldsResponse.php b/tests/Stubs/GetFieldsResponse.php index b582e09..74c8825 100644 --- a/tests/Stubs/GetFieldsResponse.php +++ b/tests/Stubs/GetFieldsResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/GetImprintResponse.php b/tests/Stubs/GetImprintResponse.php index 8d41653..5fa467b 100644 --- a/tests/Stubs/GetImprintResponse.php +++ b/tests/Stubs/GetImprintResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/GetRegionsResponse.php b/tests/Stubs/GetRegionsResponse.php index e73aeaa..867f06f 100644 --- a/tests/Stubs/GetRegionsResponse.php +++ b/tests/Stubs/GetRegionsResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/GetSearchCriteriaResponse.php b/tests/Stubs/GetSearchCriteriaResponse.php index e5ff592..8ecf4cd 100644 --- a/tests/Stubs/GetSearchCriteriaResponse.php +++ b/tests/Stubs/GetSearchCriteriaResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/InvalidHmacResponse.php b/tests/Stubs/InvalidHmacResponse.php index fd27e1a..733e20e 100644 --- a/tests/Stubs/InvalidHmacResponse.php +++ b/tests/Stubs/InvalidHmacResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/LinkDataResponse.php b/tests/Stubs/LinkDataResponse.php index 3873472..372e3f1 100644 --- a/tests/Stubs/LinkDataResponse.php +++ b/tests/Stubs/LinkDataResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/ReadActivityResponse.php b/tests/Stubs/ReadActivityResponse.php index 8c9cc95..c397e04 100644 --- a/tests/Stubs/ReadActivityResponse.php +++ b/tests/Stubs/ReadActivityResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/ReadAddressResponse.php b/tests/Stubs/ReadAddressResponse.php index 69b839f..0f2f7d3 100644 --- a/tests/Stubs/ReadAddressResponse.php +++ b/tests/Stubs/ReadAddressResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/ReadEstateResponse.php b/tests/Stubs/ReadEstateResponse.php index e3dd900..09ff172 100644 --- a/tests/Stubs/ReadEstateResponse.php +++ b/tests/Stubs/ReadEstateResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/ReadTwoEstateResponse.php b/tests/Stubs/ReadTwoEstateResponse.php index 3c19df2..ba0f247 100644 --- a/tests/Stubs/ReadTwoEstateResponse.php +++ b/tests/Stubs/ReadTwoEstateResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/ReadUserResponse.php b/tests/Stubs/ReadUserResponse.php index b1a7c51..61d0af1 100644 --- a/tests/Stubs/ReadUserResponse.php +++ b/tests/Stubs/ReadUserResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/Stubs/UploadFileResponse.php b/tests/Stubs/UploadFileResponse.php index ad51498..59d95c1 100644 --- a/tests/Stubs/UploadFileResponse.php +++ b/tests/Stubs/UploadFileResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests\Stubs; +namespace Innobrain\OnOfficeAdapter\Tests\Stubs; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; diff --git a/tests/TestCase.php b/tests/TestCase.php index 27d8bf0..57de47e 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Katalam\OnOfficeAdapter\Tests; +namespace Innobrain\OnOfficeAdapter\Tests; use Illuminate\Database\Eloquent\Factories\Factory; -use Katalam\OnOfficeAdapter\OnOfficeAdapterServiceProvider; +use Innobrain\OnOfficeAdapter\OnOfficeAdapterServiceProvider; use Orchestra\Testbench\TestCase as Orchestra; class TestCase extends Orchestra @@ -15,7 +15,7 @@ protected function setUp(): void parent::setUp(); Factory::guessFactoryNamesUsing( - fn (string $modelName) => 'Katalam\\OnOfficeAdapter\\Database\\Factories\\'.class_basename($modelName).'Factory' + fn (string $modelName) => 'Innobrain\\OnOfficeAdapter\\Database\\Factories\\'.class_basename($modelName).'Factory' ); } diff --git a/tests/Testing/Factories/BaseFactoryTest.php b/tests/Testing/Factories/BaseFactoryTest.php index cebf1f0..0c8898f 100644 --- a/tests/Testing/Factories/BaseFactoryTest.php +++ b/tests/Testing/Factories/BaseFactoryTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Katalam\OnOfficeAdapter\Facades\Testing\RecordFactories\BaseFactory; +use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\BaseFactory; class Factory extends BaseFactory {} From 219814ef699f300b0549534f759f046780ae59bb Mon Sep 17 00:00:00 2001 From: Katalam Date: Thu, 19 Sep 2024 08:14:16 +0000 Subject: [PATCH 13/13] chore: code style issues --- src/Query/Builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Query/Builder.php b/src/Query/Builder.php index 5ed65d9..7e26aec 100644 --- a/src/Query/Builder.php +++ b/src/Query/Builder.php @@ -10,7 +10,6 @@ use Illuminate\Support\Collection; use Illuminate\Support\Str; use Illuminate\Support\Traits\Conditionable; -use JsonException; use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; use Innobrain\OnOfficeAdapter\Dtos\OnOfficeResponse; use Innobrain\OnOfficeAdapter\Exceptions\OnOfficeException; @@ -18,6 +17,7 @@ use Innobrain\OnOfficeAdapter\Query\Concerns\BuilderInterface; use Innobrain\OnOfficeAdapter\Repositories\BaseRepository; use Innobrain\OnOfficeAdapter\Services\OnOfficeService; +use JsonException; use Throwable; class Builder implements BuilderInterface