From 980fdeff4a4de223c5caa6885aa20dcf3533193e Mon Sep 17 00:00:00 2001 From: Michael Nakamura Date: Wed, 27 Sep 2023 15:13:14 -0300 Subject: [PATCH] Programmati Units Update --- .../RealEstateDevelopments/UnitContract.php | 44 ++++++++++++++++ .../RealEstateDevelopments/UnitResource.php | 52 +++++++++++++++++++ .../RealStateDevelopmentResource.php | 38 ++++---------- 3 files changed, 105 insertions(+), 29 deletions(-) create mode 100644 src/Contracts/Resources/RealEstateDevelopments/UnitContract.php create mode 100644 src/Resources/RealEstateDevelopments/UnitResource.php diff --git a/src/Contracts/Resources/RealEstateDevelopments/UnitContract.php b/src/Contracts/Resources/RealEstateDevelopments/UnitContract.php new file mode 100644 index 0000000..a4742a3 --- /dev/null +++ b/src/Contracts/Resources/RealEstateDevelopments/UnitContract.php @@ -0,0 +1,44 @@ +issProduto->getProgrammatic()) { + $endpoint = '/programmatic' . $endpoint; + } + + return $this->issProduto->request + ->get(vsprintf($endpoint, [$realEstateDevelopment]), $query) + ->throw() + ->object(); + } + + /** + * @param string $realEstateDevelopment + * @param string $unit + * @param array $query + * + * @return object + * + * @throws RequestException + */ + public function update(string $realEstateDevelopment, string $unit, array $data = []): object + { + $endpoint = self::ENDPOINT_UPDATE; + if ($this->issProduto->getProgrammatic()) { + $endpoint = '/programmatic' . $endpoint; + } + + return $this->issProduto->request + ->put(vsprintf($endpoint, [$realEstateDevelopment, $unit]), $data) + ->throw() + ->object(); + } +} diff --git a/src/Resources/RealStateDevelopmentResource.php b/src/Resources/RealStateDevelopmentResource.php index 0671eb9..061d7e8 100644 --- a/src/Resources/RealStateDevelopmentResource.php +++ b/src/Resources/RealStateDevelopmentResource.php @@ -5,6 +5,7 @@ use Bildvitta\IssProduto\Contracts\Resources\RealStateDevelopmentContract; use Bildvitta\IssProduto\IssProduto; use Bildvitta\IssProduto\Resources\RealEstateDevelopments\BlueprintResource; +use Bildvitta\IssProduto\Resources\RealEstateDevelopments\UnitResource; use Bildvitta\IssProduto\Resources\RealEstateDevelopments\CharacteristicResource; use Bildvitta\IssProduto\Resources\RealEstateDevelopments\MirrorResource; use Bildvitta\IssProduto\Resources\RealEstateDevelopments\StageResource; @@ -73,6 +74,14 @@ public function blueprints(): BlueprintResource return new BlueprintResource($this->issProduto); } + /** + * @return UnitResource + */ + public function units(): UnitResource + { + return new UnitResource($this->issProduto); + } + /** * @param array $query * @param array $body @@ -119,33 +128,4 @@ public function update(string $uuid, array $data = []): object { return $this->issProduto->request->put(vsprintf(self::ENDPOINT_FIND_BY_UUID, [$uuid]), $data)->throw()->object(); } - - /** - * @param string $uuid - * @param array $query - * - * @return object - * - * @throws RequestException - */ - public function unities(string $uuid, array $query = []) - { - return $this->issProduto->request->get(vsprintf(self::ENDPOINT_UNIT_PREFIX, [$uuid]), $query)->throw()->object(); - } - - /** - * @param string $realEstateDevelopment - * @param array $data - * - * @return object - * - * @throws RequestException - */ - public function updateUnit(string $realEstateDevelopment, array $data = []) - { - return $this->issProduto->request->put( - vsprintf(self::ENDPOINT_UNIT_PREFIX, [$realEstateDevelopment]), - ['data' => $data] - )->throw()->object(); - } }