diff --git a/CHANGELOG.md b/CHANGELOG.md index c215027..5f8e4fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ## main +## v.0.8.0 +- Added the parameter helper to all repositories + ## v0.7.7 - Fixed typo of addressids diff --git a/src/Query/ActivityBuilder.php b/src/Query/ActivityBuilder.php index ae56c73..9889a35 100644 --- a/src/Query/ActivityBuilder.php +++ b/src/Query/ActivityBuilder.php @@ -17,8 +17,6 @@ class ActivityBuilder extends Builder public string $estateOrAddress = 'estate'; - public array $customParameters = []; - public function __construct( private readonly OnOfficeService $onOfficeService, ) {} @@ -91,6 +89,7 @@ public function find(int $id): array $id, parameters: [ OnOfficeService::DATA => $this->columns, + ...$this->customParameters, ] ); diff --git a/src/Query/AddressBuilder.php b/src/Query/AddressBuilder.php index 3d3d7b2..5b0bf2c 100644 --- a/src/Query/AddressBuilder.php +++ b/src/Query/AddressBuilder.php @@ -15,8 +15,6 @@ class AddressBuilder extends Builder { use RecordIds; - public array $customParameters = []; - public function __construct( private readonly OnOfficeService $onOfficeService, ) {} @@ -99,6 +97,7 @@ public function find(int $id): array $id, parameters: [ OnOfficeService::DATA => $columns, + ...$this->customParameters, ] ); diff --git a/src/Query/Builder.php b/src/Query/Builder.php index d5b5826..9991145 100644 --- a/src/Query/Builder.php +++ b/src/Query/Builder.php @@ -44,6 +44,11 @@ abstract class Builder */ public int $offset = 0; + /* + * An array of custom parameters. + */ + public array $customParameters = []; + public function select(array|string $columns = ['ID']): static { $this->columns = Arr::wrap($columns); @@ -140,6 +145,20 @@ protected function getOrderBy(): array })->toArray(); } + public function parameter(string $key, mixed $value): static + { + $this->customParameters[$key] = $value; + + return $this; + } + + public function parameters(array $parameters): static + { + $this->customParameters = array_replace_recursive($this->customParameters, $parameters); + + return $this; + } + abstract public function get(): Collection; abstract public function first(): array; diff --git a/src/Query/EstateBuilder.php b/src/Query/EstateBuilder.php index e593d5f..b508b80 100644 --- a/src/Query/EstateBuilder.php +++ b/src/Query/EstateBuilder.php @@ -36,6 +36,7 @@ public function get(): Collection OnOfficeService::LISTLIMIT => $pageSize, OnOfficeService::LISTOFFSET => $offset, OnOfficeService::SORTBY => $orderBy, + ...$this->customParameters, ] ); }, pageSize: $listLimit, offset: $listOffset); @@ -61,6 +62,7 @@ public function first(): array OnOfficeService::LISTLIMIT => $listLimit, OnOfficeService::LISTOFFSET => $listOffset, OnOfficeService::SORTBY => $orderBy, + ...$this->customParameters, ] ); @@ -80,6 +82,7 @@ public function find(int $id): array $id, parameters: [ OnOfficeService::DATA => $columns, + ...$this->customParameters, ] ); @@ -106,6 +109,7 @@ public function each(callable $callback): void OnOfficeService::LISTLIMIT => $pageSize, OnOfficeService::LISTOFFSET => $offset, OnOfficeService::SORTBY => $orderBy, + ...$this->customParameters, ] ); }, $callback, pageSize: $listLimit, offset: $listOffset); diff --git a/src/Query/EstateFileBuilder.php b/src/Query/EstateFileBuilder.php index f318abb..0c5e286 100644 --- a/src/Query/EstateFileBuilder.php +++ b/src/Query/EstateFileBuilder.php @@ -35,6 +35,7 @@ public function get(): Collection 'estateid' => $this->estateId, OnOfficeService::LISTLIMIT => $pageSize, OnOfficeService::LISTOFFSET => $offset, + ...$this->customParameters, ], ); }, pageSize: $this->limit, offset: $this->offset); @@ -51,6 +52,7 @@ public function first(): array OnOfficeResourceId::Estate, parameters: [ 'estateid' => $this->estateId, + ...$this->customParameters, ], ); @@ -69,6 +71,7 @@ public function find(int $id): array parameters: [ 'estateid' => $this->estateId, 'fileid' => $id, + ...$this->customParameters, ], ); @@ -94,6 +97,7 @@ public function each(callable $callback): void 'estateid' => $this->estateId, OnOfficeService::LISTLIMIT => $pageSize, OnOfficeService::LISTOFFSET => $offset, + ...$this->customParameters, ], ); }, $callback, pageSize: $this->limit, offset: $this->offset); @@ -131,6 +135,7 @@ public function delete(int $id): bool 'fileId' => $id, 'parentid' => $this->estateId, 'relationtype' => 'estate', + ...$this->customParameters, ], ); diff --git a/src/Query/FieldBuilder.php b/src/Query/FieldBuilder.php index d9475ec..149a055 100644 --- a/src/Query/FieldBuilder.php +++ b/src/Query/FieldBuilder.php @@ -29,6 +29,7 @@ public function get(): Collection OnOfficeResourceType::Fields, parameters: [ 'modules' => $this->modules, + ...$this->customParameters, ], ); }); @@ -44,6 +45,7 @@ public function first(): array OnOfficeResourceType::Fields, parameters: [ 'modules' => $this->modules, + ...$this->customParameters, ], ); @@ -68,6 +70,7 @@ public function each(callable $callback): void OnOfficeResourceType::Fields, parameters: [ 'modules' => $this->modules, + ...$this->customParameters, ], ); }, $callback); diff --git a/src/Query/ImprintBuilder.php b/src/Query/ImprintBuilder.php index bcffe26..1edf9da 100644 --- a/src/Query/ImprintBuilder.php +++ b/src/Query/ImprintBuilder.php @@ -36,6 +36,7 @@ public function get(): Collection OnOfficeResourceType::Impressum, parameters: [ OnOfficeService::DATA => $columns, + ...$this->customParameters, ] ); }, pageSize: $listLimit, offset: $listOffset); @@ -53,6 +54,7 @@ public function first(): array OnOfficeResourceType::Impressum, parameters: [ OnOfficeService::DATA => $columns, + ...$this->customParameters, ] ); @@ -72,6 +74,7 @@ public function find(int $id): array resourceId: $id, parameters: [ OnOfficeService::DATA => $columns, + ...$this->customParameters, ] ); diff --git a/src/Query/MarketplaceBuilder.php b/src/Query/MarketplaceBuilder.php index e156114..d552be2 100644 --- a/src/Query/MarketplaceBuilder.php +++ b/src/Query/MarketplaceBuilder.php @@ -34,6 +34,7 @@ public function unlockProvider( parameters: [ OnOfficeService::PARAMETERCACHEID => $parameterCacheId, OnOfficeService::EXTENDEDCLAIM => $extendedClaim, + ...$this->customParameters, ] ); diff --git a/src/Query/RegionBuilder.php b/src/Query/RegionBuilder.php index 9d54d6d..c3b0a48 100644 --- a/src/Query/RegionBuilder.php +++ b/src/Query/RegionBuilder.php @@ -35,6 +35,7 @@ public function get(): Collection return $this->onOfficeService->requestApi( OnOfficeAction::Get, OnOfficeResourceType::Regions, + ...$this->customParameters, ); }, pageSize: $listLimit, offset: $listOffset); } @@ -47,6 +48,7 @@ public function first(): array $response = $this->onOfficeService->requestApi( OnOfficeAction::Get, OnOfficeResourceType::Regions, + ...$this->customParameters, ); return $response->json('response.results.0.data.records.0'); @@ -71,6 +73,7 @@ public function each(callable $callback): void return $this->onOfficeService->requestApi( OnOfficeAction::Get, OnOfficeResourceType::Regions, + ...$this->customParameters, ); }, $callback, pageSize: $listLimit, offset: $listOffset); } diff --git a/src/Query/RelationBuilder.php b/src/Query/RelationBuilder.php index 2beec1c..841223d 100644 --- a/src/Query/RelationBuilder.php +++ b/src/Query/RelationBuilder.php @@ -44,6 +44,7 @@ public function get(): Collection OnOfficeService::RELATIONTYPE => $this->relationType, OnOfficeService::PARENTIDS => $this->parentIds, OnOfficeService::CHILDIDS => $this->childIds, + ...$this->customParameters, ], ); }, pageSize: $this->limit, offset: $this->offset); diff --git a/src/Query/UploadBuilder.php b/src/Query/UploadBuilder.php index d48dc84..1e53e12 100644 --- a/src/Query/UploadBuilder.php +++ b/src/Query/UploadBuilder.php @@ -77,6 +77,7 @@ public function save(string $fileContent): string OnOfficeResourceType::UploadFile, parameters: [ OnOfficeService::DATA => $fileContent, + ...$this->customParameters, ] ); diff --git a/src/Query/UserBuilder.php b/src/Query/UserBuilder.php index c5c4a8c..5fd75b9 100644 --- a/src/Query/UserBuilder.php +++ b/src/Query/UserBuilder.php @@ -36,6 +36,7 @@ public function get(): Collection OnOfficeService::LISTLIMIT => $pageSize, OnOfficeService::LISTOFFSET => $offset, OnOfficeService::SORTBY => $orderBy, + ...$this->customParameters, ], ); }, pageSize: $listLimit, offset: $listOffset); @@ -61,6 +62,7 @@ public function first(): array OnOfficeService::LISTLIMIT => $listLimit, OnOfficeService::LISTOFFSET => $listOffset, OnOfficeService::SORTBY => $orderBy, + ...$this->customParameters, ] ); @@ -80,6 +82,7 @@ public function find(int $id): array $id, parameters: [ OnOfficeService::DATA => $columns, + ...$this->customParameters, ] ); @@ -106,6 +109,7 @@ public function each(callable $callback): void OnOfficeService::LISTLIMIT => $pageSize, OnOfficeService::LISTOFFSET => $offset, OnOfficeService::SORTBY => $orderBy, + ...$this->customParameters, ] ); }, $callback, pageSize: $listLimit, offset: $listOffset);