-
Notifications
You must be signed in to change notification settings - Fork 6
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
5 changed files
with
235 additions
and
1 deletion.
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,124 @@ | ||
<?php | ||
|
||
namespace Bluerock\Sellsy\Api; | ||
|
||
use Bluerock\Sellsy\Entities\RateCategory; | ||
use Bluerock\Sellsy\Collections\RateCategoryCollection; | ||
use Bluerock\Sellsy\Core\Response; | ||
|
||
/** | ||
* The API client for the `rate-categories` namespace. | ||
* | ||
* @package bluerock/sellsy-client | ||
* @author Thomas <[email protected]> | ||
* @version 1.1 | ||
* @access public | ||
* @see https://api.sellsy.com/doc/v2/#tag/Rate-Categories | ||
*/ | ||
class RateCategoriesApi extends AbstractApi | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->entity = RateCategory::class; | ||
$this->collection = RateCategoryCollection::class; | ||
} | ||
|
||
/** | ||
* List all rate categories. | ||
* | ||
* @param array $query Query parameters. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/get-rate-categories | ||
*/ | ||
public function index(array $query = []): Response | ||
{ | ||
$response = $this->connection | ||
->request('rate-categories') | ||
->get($query); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
|
||
/** | ||
* Show a single rate category by id. | ||
* | ||
* @param string $id The rate category id to retrieve. | ||
* @param array $query Query parameters. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/get-rate-category | ||
*/ | ||
public function show(string $id, array $query = []): Response | ||
{ | ||
$response = $this->connection | ||
->request("rate-categories/{$id}") | ||
->get($query); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
|
||
/** | ||
* Store (create) a rate category. | ||
* | ||
* @param RateCategory $rateCategory The rate category entity to store. | ||
* @param array $query Query parameters. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/create-rate-category | ||
*/ | ||
public function store(RateCategory $rateCategory, array $query = []): Response | ||
{ | ||
$body = $rateCategory->except('id') | ||
->toArray(); | ||
|
||
$response = $this->connection | ||
->request('rate-categories') | ||
->post(array_filter($body) + $query); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
|
||
/** | ||
* Update an existing rate category. | ||
* | ||
* @param RateCategory $rateCategory The rate category entity to store. | ||
* @param array $query Query parameters. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/update-rate-category | ||
*/ | ||
public function update(RateCategory $rateCategory, array $query = []): Response | ||
{ | ||
$body = $rateCategory->except('id') | ||
->toArray(); | ||
|
||
$response = $this->connection | ||
->request("rate-categories/{$rateCategory->id}") | ||
->put(array_filter($body) + $query); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
|
||
/** | ||
* Delete an existing rate category. | ||
* | ||
* @param int $id The rate category id to be deleted. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/delete-rate-category | ||
*/ | ||
public function destroy(int $id): Response | ||
{ | ||
$response = $this->connection | ||
->request("rate-categories/{$id}") | ||
->delete(); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
} |
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\RateCategory; | ||
use Bluerock\Sellsy\Contracts\EntityCollectionContract; | ||
use Spatie\DataTransferObject\DataTransferObjectCollection; | ||
|
||
/** | ||
* The RateCategory Entity collection. | ||
* | ||
* @package bluerock/sellsy-client | ||
* @author Thomas <[email protected]> | ||
* @version 1.1 | ||
* @access public | ||
* | ||
* @method \Bluerock\Sellsy\Entities\RateCategory current | ||
*/ | ||
class RateCategoryCollection extends DataTransferObjectCollection implements EntityCollectionContract | ||
{ | ||
public static function create(array $data): RateCategoryCollection | ||
{ | ||
return new static(RateCategory::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,26 @@ | ||
<?php | ||
|
||
namespace Bluerock\Sellsy\Entities; | ||
|
||
use Bluerock\Sellsy\Entities\Entity; | ||
|
||
/** | ||
* The Accounting Entity. | ||
* | ||
* @package bluerock/sellsy-client | ||
* @author Thomas <[email protected]> | ||
* @version 1.1 | ||
* @access public | ||
*/ | ||
class Accounting extends Entity | ||
{ | ||
/** | ||
* Accounting code ID. | ||
*/ | ||
public ?int $accounting_code_id; | ||
|
||
/** | ||
* Discount accounting code ID. | ||
*/ | ||
public ?int $discount_accounting_code_id; | ||
} |
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 |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
/** | ||
* The Item Entity. | ||
* | ||
* @package cedricWebsenso/sellsy-client | ||
* @package bluerock/sellsy-client | ||
* @author Cédric <[email protected]> | ||
* @version 1.0 | ||
* @access public | ||
|
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,59 @@ | ||
<?php | ||
|
||
namespace Bluerock\Sellsy\Entities; | ||
|
||
use Bluerock\Sellsy\Entities\Tax; | ||
use Bluerock\Sellsy\Entities\Unit; | ||
use Bluerock\Sellsy\Entities\Entity; | ||
use Bluerock\Sellsy\Entities\Accounting; | ||
|
||
/** | ||
* The Rate Category Entity. | ||
* | ||
* @package bluerock/sellsy-client | ||
* @author Thomas <[email protected]> | ||
* @version 1.0 | ||
* @access public | ||
*/ | ||
class RateCategory extends Entity | ||
{ | ||
/** | ||
* <READONLY> Rate category ID from Sellsy. | ||
*/ | ||
public ?int $id; | ||
|
||
/** | ||
* Rate category related tax ID from Sellsy. | ||
*/ | ||
public ?int $tax_id; | ||
|
||
/** | ||
* Rate category label. | ||
*/ | ||
public ?string $label; | ||
|
||
/** | ||
* Rate category currency. | ||
*/ | ||
public string $currency = 'EUR'; | ||
|
||
/** | ||
* Does the Rate category includes taxes. | ||
*/ | ||
public ?bool $includes_taxes; | ||
|
||
/** | ||
* Does the Rate category is the default for this account. | ||
*/ | ||
public ?bool $is_default; | ||
|
||
/** | ||
* Rate category accounting. | ||
*/ | ||
public ?Accounting $accounting; | ||
|
||
/** | ||
* Rate category default layouts. | ||
*/ | ||
public ?array $default_layouts; | ||
} |