mirror of
https://github.com/anikeen-com/id.git
synced 2026-05-08 22:59:01 +00:00
refactored code
Signed-off-by: Maurice Preuß (envoyr) <hello@envoyr.com>
This commit is contained in:
54
src/Id/Resources/OrderItem.php
Normal file
54
src/Id/Resources/OrderItem.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Anikeen\Id\Resources;
|
||||
|
||||
use Anikeen\Id\Concerns\HasBillable;
|
||||
use Anikeen\Id\Concerns\HasParent;
|
||||
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
||||
/**
|
||||
* @property string $id
|
||||
*/
|
||||
class OrderItem extends BaseResource
|
||||
{
|
||||
use HasBillable;
|
||||
use HasParent;
|
||||
|
||||
/**
|
||||
* Update given order item from given order.
|
||||
*
|
||||
* VAT is calculated based on the billing address and shown in the order item response.
|
||||
*
|
||||
* @param array{
|
||||
* items: array<array{
|
||||
* type: string,
|
||||
* name: string,
|
||||
* description: string,
|
||||
* price: float|int,
|
||||
* unit: string,
|
||||
* units: int
|
||||
* }>
|
||||
* } $attributes The order data:
|
||||
* - items: Array of order items, each with type, name, description, price, unit, and quantity
|
||||
* @throws RequestRequiresClientIdException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function update(array $attributes = []): self
|
||||
{
|
||||
return (new self($this->billable->request('PUT', sprintf('v1/orders/%s/items/%s', $this->parent->id, $this->id), $attributes)))
|
||||
->setBillable($this->billable)
|
||||
->setParent($this->parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete given order item from given order.
|
||||
*
|
||||
* @throws RequestRequiresClientIdException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
return $this->billable->request('DELETE', sprintf('v1/orders/%s/items/%s', $this->parent->id, $this->id))->success();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user