-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
dbdba9b
commit 980fdef
Showing
3 changed files
with
105 additions
and
29 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/Contracts/Resources/RealEstateDevelopments/UnitContract.php
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,44 @@ | ||
<?php | ||
|
||
namespace Bildvitta\IssProduto\Contracts\Resources\RealEstateDevelopments; | ||
|
||
use Illuminate\Http\Client\RequestException; | ||
|
||
interface UnitContract | ||
{ | ||
/** | ||
* @const string | ||
*/ | ||
public const ENDPOINT_PREFIX = '/real-estate-developments/%s'; | ||
|
||
/** | ||
* @const string | ||
*/ | ||
public const ENDPOINT_INDEX = self::ENDPOINT_PREFIX.'/units'; | ||
|
||
/** | ||
* @const string | ||
*/ | ||
public const ENDPOINT_UPDATE = self::ENDPOINT_PREFIX.'/units/%s'; | ||
|
||
/** | ||
* @param string $realEstateDevelopment | ||
* @param array $query | ||
* | ||
* @return object | ||
* | ||
* @throws RequestException | ||
*/ | ||
public function get(string $realEstateDevelopment, array $query = []): object; | ||
|
||
/** | ||
* @param string $realEstateDevelopment | ||
* @param string $unit | ||
* @param array $query | ||
* | ||
* @return object | ||
* | ||
* @throws RequestException | ||
*/ | ||
public function update(string $realEstateDevelopment, string $unit, array $data = []): object; | ||
} |
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,52 @@ | ||
<?php | ||
|
||
namespace Bildvitta\IssProduto\Resources\RealEstateDevelopments; | ||
|
||
use Bildvitta\IssProduto\Contracts\Resources\RealEstateDevelopments\UnitContract; | ||
use Illuminate\Http\Client\RequestException; | ||
|
||
class UnitResource extends BaseResource implements UnitContract | ||
{ | ||
/** | ||
* @param string $realEstateDevelopment | ||
* @param array $query | ||
* | ||
* @return object | ||
* | ||
* @throws RequestException | ||
*/ | ||
public function get(string $realEstateDevelopment, array $query = []): object | ||
{ | ||
$endpoint = self::ENDPOINT_INDEX; | ||
if ($this->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(); | ||
} | ||
} |
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