update resources

Signed-off-by: Maurice Preuß (envoyr) <hello@envoyr.com>
This commit is contained in:
envoyr committed 2025-05-02 06:27:53 +02:00
1 parent 1725ec68de
commit 1d2119a32b
33 files changed
+303 -320

No files matched your search

+6 -13
View File
@@ -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);
}
}