-
Notifications
You must be signed in to change notification settings - Fork 7
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
6 changed files
with
105 additions
and
12 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
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
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,49 @@ | ||
<?php | ||
|
||
namespace Bluerock\Sellsy\Api; | ||
|
||
use Bluerock\Sellsy\Entities\Unit; | ||
use Bluerock\Sellsy\Collections\UnitCollection; | ||
|
||
/** | ||
* The API client for the `units` namespace. | ||
* | ||
* @package sellsy-connector | ||
* @author Thomas <thomas@bluerocktel.com> | ||
* @version 1.1 | ||
* @access public | ||
* @see https://api.sellsy.com/doc/v2/#tag/Units | ||
*/ | ||
class UnitsApi extends AbstractApi | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->entity = Unit::class; | ||
$this->collection = UnitCollection::class; | ||
} | ||
|
||
/** | ||
* List all units. | ||
* | ||
* @param array $query Query parameters. | ||
* | ||
* @return \Illuminate\Http\Client\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/get-units | ||
*/ | ||
public function index(array $query = []): self | ||
{ | ||
$response = $this->connection | ||
->request('units') | ||
->get($query); | ||
|
||
$this->response = $response; | ||
$this->response->throw(); | ||
|
||
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,25 @@ | ||
<?php | ||
|
||
namespace Bluerock\Sellsy\Collections; | ||
|
||
use Bluerock\Sellsy\Entities\Unit; | ||
use Bluerock\Sellsy\Contracts\EntityCollectionContract; | ||
use Spatie\DataTransferObject\DataTransferObjectCollection; | ||
|
||
/** | ||
* The Unit Entity collection. | ||
* | ||
* @package sellsy-connector | ||
* @author Thomas <thomas@bluerocktel.com> | ||
* @version 1.0 | ||
* @access public | ||
* | ||
* @method \Bluerock\Sellsy\Entities\Unit current | ||
*/ | ||
class UnitCollection extends DataTransferObjectCollection implements EntityCollectionContract | ||
{ | ||
public static function create(array $data): UnitCollection | ||
{ | ||
return new static(Unit::arrayOf($data)); | ||
} | ||
} |
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,27 @@ | ||
<?php | ||
|
||
namespace Bluerock\Sellsy\Entities; | ||
|
||
use Bluerock\Sellsy\Contracts\EntityContract; | ||
use Spatie\DataTransferObject\FlexibleDataTransferObject; | ||
|
||
/** | ||
* The Tax Entity. | ||
* | ||
* @package sellsy-connector | ||
* @author Thomas <thomas@bluerocktel.com> | ||
* @version 1.0 | ||
* @access public | ||
*/ | ||
class Unit extends FlexibleDataTransferObject implements EntityContract | ||
{ | ||
/** | ||
* <READONLY> Tax class ID from Sellsy. | ||
*/ | ||
public int $id; | ||
|
||
/** | ||
* Tax class label. | ||
*/ | ||
public ?string $label; | ||
} |