mirror of
https://github.com/anikeen-com/id.git
synced 2026-11-03 22:29:33 +00:00
update resources
Signed-off-by: Maurice Preuß (envoyr) <hello@envoyr.com>
This commit is contained in:
33 files changed
+303
-320
No files matched your search
@@ -4,9 +4,8 @@ namespace Anikeen\Id\Resources;
|
||||
|
||||
use Anikeen\Id\Concerns\HasBillable;
|
||||
use Anikeen\Id\Concerns\HasParent;
|
||||
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
|
||||
use Anikeen\Id\Result;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Throwable;
|
||||
|
||||
class OrderItems extends BaseCollection
|
||||
{
|
||||
@@ -30,12 +29,11 @@ class OrderItems extends BaseCollection
|
||||
* }>
|
||||
* } $attributes The order data:
|
||||
* - items: Array of order items, each with type, name, description, price, unit, and quantity
|
||||
* @throws RequestRequiresClientIdException
|
||||
* @throws GuzzleException
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function create(string $orderId, array $attributes = []): OrderItem
|
||||
{
|
||||
return (new OrderItem($this->billable->request('POST', sprintf('v1/orders/%s', $orderId), $attributes)))
|
||||
return (new OrderItem(fn() => $this->billable->request('POST', sprintf('v1/orders/%s', $orderId), $attributes)))
|
||||
->setBillable($this->billable)
|
||||
->setParent($this->parent);
|
||||
}
|
||||
@@ -45,13 +43,8 @@ class OrderItems extends BaseCollection
|
||||
*/
|
||||
public function find(string $id): ?OrderItem
|
||||
{
|
||||
/** @var Result $result */
|
||||
$result = $this->parent->request('GET', sprintf('v1/orders/%s/items/%s', $this->parent->id, $id));
|
||||
|
||||
return $result->success() ?
|
||||
(new OrderItem($result))
|
||||
->setBillable($this->billable)
|
||||
->setParent($this->parent)
|
||||
: null;
|
||||
return (new OrderItem(fn() => $this->parent->request('GET', sprintf('v1/orders/%s/items/%s', $this->parent->id, $id))))
|
||||
->setBillable($this->billable)
|
||||
->setParent($this->parent);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user