-
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
3 changed files
with
108 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Hydrat\Sellsy\Api; | ||
|
||
use Hydrat\Sellsy\Entities\Tax; | ||
use Hydrat\Sellsy\Collections\TaxCollection; | ||
|
||
/** | ||
* The API client for the `companies` namespace. | ||
* | ||
* @package sellsy-connector | ||
* @author Thomas <thomas@hydrat.agency> | ||
* @version 1.0 | ||
* @access public | ||
*/ | ||
class TaxesApi extends AbstractApi | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->entity = Tax::class; | ||
$this->collection = TaxCollection::class; | ||
} | ||
|
||
|
||
/** | ||
* List all taxes. | ||
* | ||
* @param array $query Query parameters. | ||
* | ||
* @return \Illuminate\Http\Client\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/get-taxes | ||
*/ | ||
public function index(array $query = []): self | ||
{ | ||
$response = $this->connection | ||
->request('taxes') | ||
->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 Hydrat\Sellsy\Collections; | ||
|
||
use Hydrat\Sellsy\Entities\Tax; | ||
use Hydrat\Sellsy\Contracts\EntityCollectionContract; | ||
use Spatie\DataTransferObject\DataTransferObjectCollection; | ||
|
||
/** | ||
* The Tax Entity collection. | ||
* | ||
* @package sellsy-connector | ||
* @author Thomas <thomas@hydrat.agency> | ||
* @version 1.0 | ||
* @access public | ||
* | ||
* @method \Hydrat\Sellsy\Entities\Tax current | ||
*/ | ||
class TaxCollection extends DataTransferObjectCollection implements EntityCollectionContract | ||
{ | ||
public static function create(array $data): TaxCollection | ||
{ | ||
return new static(Tax::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,34 @@ | ||
<?php | ||
|
||
namespace Hydrat\Sellsy\Entities; | ||
|
||
use Hydrat\Sellsy\Contracts\EntityContract; | ||
use Spatie\DataTransferObject\FlexibleDataTransferObject; | ||
|
||
/** | ||
* The Tax Entity. | ||
* | ||
* @package sellsy-connector | ||
* @author Thomas <thomas@hydrat.agency> | ||
* @version 1.0 | ||
* @access public | ||
*/ | ||
class Tax extends FlexibleDataTransferObject implements EntityContract | ||
{ | ||
/** | ||
* <READONLY> Tax class ID from Sellsy. | ||
*/ | ||
public int $id; | ||
|
||
/** | ||
* Tax rate in percentage. | ||
* | ||
* @var int|float|null | ||
*/ | ||
public $rate; | ||
|
||
/** | ||
* Tax class label. | ||
*/ | ||
public ?string $label; | ||
} |