* } $attributes The order data: * - items: Array of order items, each with type, name, description, price, unit, and quantity * * Only trusted apps may add items, and only to draft orders. Returns the first created item. * * @throws Throwable */ public function create(string $orderId, array $attributes = []): OrderItem { return (new OrderItem(fn() => tap($this->billable->anikeenId() ->request('POST', sprintf('v1/orders/%s/items', $orderId), $attributes), function ($result) { if (is_array($result->data)) { $result->data = $result->data[0] ?? null; } }))) ->setBillable($this->billable) ->setParent($this->parent); } /** * {@inheritDoc} */ public function find(string $id): ?OrderItem { return (new OrderItem(fn() => $this->parent->anikeenId() ->request('GET', sprintf('v1/orders/%s/items/%s', $this->parent->id, $id)))) ->setBillable($this->billable) ->setParent($this->parent); } }