generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
# Changelog | ||
## main | ||
|
||
## v0.8.2 | ||
- Added search criteria repository | ||
|
||
## v0.8.1 | ||
- Added a field repository fake | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Katalam\OnOfficeAdapter\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
use Katalam\OnOfficeAdapter\Facades\Testing\SearchCriteriaRepositoryFake; | ||
use Katalam\OnOfficeAdapter\Query\SearchCriteriaBuilder; | ||
|
||
/** | ||
* @see \Katalam\OnOfficeAdapter\Repositories\SearchCriteriaRepository | ||
* | ||
* @method static SearchCriteriaBuilder query() | ||
*/ | ||
class SearchCriteriaRepository extends Facade | ||
{ | ||
public static function fake(array ...$fakeResponses): SearchCriteriaRepositoryFake | ||
{ | ||
static::swap($fake = new SearchCriteriaRepositoryFake(...$fakeResponses)); | ||
|
||
return $fake; | ||
} | ||
|
||
protected static function getFacadeAccessor(): string | ||
{ | ||
return \Katalam\OnOfficeAdapter\Repositories\SearchCriteriaRepository::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Katalam\OnOfficeAdapter\Facades\Testing; | ||
|
||
use Katalam\OnOfficeAdapter\Query\Testing\SearchCriteriaBuilderFake; | ||
|
||
class SearchCriteriaRepositoryFake | ||
{ | ||
use FakeResponses; | ||
|
||
/** | ||
* Returns a new fake user builder instance. | ||
*/ | ||
public function query(): SearchCriteriaBuilderFake | ||
{ | ||
return new SearchCriteriaBuilderFake($this->fakeResponses); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Katalam\OnOfficeAdapter\Query; | ||
|
||
use Illuminate\Support\Arr; | ||
use Illuminate\Support\Collection; | ||
use Katalam\OnOfficeAdapter\Enums\OnOfficeAction; | ||
use Katalam\OnOfficeAdapter\Enums\OnOfficeResourceType; | ||
use Katalam\OnOfficeAdapter\Exceptions\OnOfficeException; | ||
use Katalam\OnOfficeAdapter\Services\OnOfficeService; | ||
|
||
class SearchCriteriaBuilder extends Builder | ||
{ | ||
private string $mode = 'internal'; | ||
|
||
public function __construct( | ||
private readonly OnOfficeService $onOfficeService, | ||
) {} | ||
|
||
/** | ||
* @throws OnOfficeException | ||
*/ | ||
public function get(): Collection | ||
{ | ||
throw new OnOfficeException('Not implemented'); | ||
} | ||
|
||
/** | ||
* @throws OnOfficeException | ||
*/ | ||
public function first(): array | ||
{ | ||
throw new OnOfficeException('Not implemented'); | ||
} | ||
|
||
/** | ||
* @throws OnOfficeException | ||
*/ | ||
public function find(int|array $id): array | ||
{ | ||
$response = $this->onOfficeService->requestApi( | ||
OnOfficeAction::Get, | ||
OnOfficeResourceType::SearchCriteria, | ||
parameters: [ | ||
OnOfficeService::MODE => $this->mode, | ||
OnOfficeService::IDS => Arr::wrap($id), | ||
...$this->customParameters, | ||
], | ||
); | ||
|
||
return $response->json('response.results.0.data.records'); | ||
} | ||
|
||
/** | ||
* @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; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Katalam\OnOfficeAdapter\Query\Testing; | ||
|
||
class SearchCriteriaBuilderFake extends BaseFake {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Katalam\OnOfficeAdapter\Repositories; | ||
|
||
use Katalam\OnOfficeAdapter\Query\SearchCriteriaBuilder; | ||
use Katalam\OnOfficeAdapter\Services\OnOfficeService; | ||
|
||
class SearchCriteriaRepository | ||
{ | ||
public function __construct( | ||
private readonly OnOfficeService $onOfficeService, | ||
) {} | ||
|
||
/** | ||
* Returns a new user builder instance. | ||
*/ | ||
public function query(): SearchCriteriaBuilder | ||
{ | ||
return new SearchCriteriaBuilder($this->onOfficeService); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters