EFL
Builders

OfferItemBuilder

Fluent builder for constructing OfferItem entries used in calculation baskets.

Namespace and purpose

Imoli\EflLeasingSdk\Builder\OfferItemBuilder is a fluent helper for building OfferItem instances. It is used when populating the offerItems list inside AssetToCalculation.

Class definition

  • Namespace: Imoli\EflLeasingSdk\Builder
  • Class: final OfferItemBuilder
  • Builds: Imoli\EflLeasingSdk\Model\Calculation\OfferItem
namespace Imoli\EflLeasingSdk\Builder;

use Imoli\EflLeasingSdk\Model\Calculation\ItemDetail;
use Imoli\EflLeasingSdk\Model\Calculation\OfferItem;

final class OfferItemBuilder
{
    public function withCount(int $count): self;

    public function withId(string $id): self;

    public function withVatRate(float $vatRate): self;

    /** @return $this */
    public function addItemDetail(ItemDetail $detail): self;

    /**
     * @param ItemDetail[] $details
     * @return $this
     */
    public function withItemDetails(array $details): self;

    public function withSupplierId(?string $supplierId): self;

    public function withType(?string $type): self;

    public function withCategory(?string $category): self;

    public function withTotalAmountNet(?float $totalAmountNet): self;

    public function withNetValue(?float $netValue): self;

    public function withGrossValue(?float $grossValue): self;

    public function build(): OfferItem;

    /**
     * @param ItemDetail[] $itemDetails
     */
    public static function create(int $count, string $id, float $vatRate, array $itemDetails): self;
}

Fluent API

  • withCount(int $count): self
    Sets the quantity of the asset.
  • withId(string $id): self
    Sets the asset identifier (e.g. GUID from your system or EFL catalogue).
  • withVatRate(float $vatRate): self
    Sets the VAT rate for this asset.
  • addItemDetail(ItemDetail $detail): self / withItemDetails(ItemDetail $details): self
    Adds or replaces the list of ItemDetail metadata entries.
  • withSupplierId(?string $supplierId): self
    Optionally sets the supplier identifier.
  • withType(?string $type): self / withCategory(?string $category): self
    Optionally sets classification fields used by the EFL API.
  • withTotalAmountNet(?float $totalAmountNet): self
    Optionally sets the total net amount for this item.
  • withNetValue(?float $netValue): self / withGrossValue(?float $grossValue): self
    Optionally sets net/gross values of the item.
  • build(): OfferItem
    • Requires count, id, vatRate and at least one ItemDetail.
    • Throws \LogicException if any of these are missing.
    • Returns a fully‑initialised OfferItem.
  • static create(int $count, string $id, float $vatRate, ItemDetail $itemDetails): self
    Convenience factory that pre‑populates the required fields and item details.

Usage examples

Building a single offer item

use Imoli\EflLeasingSdk\Builder\OfferItemBuilder;
use Imoli\EflLeasingSdk\Builder\ItemDetailBuilder;

$detail = ItemDetailBuilder::create('asset-code', 'Laptop X')->build();

$offerItem = OfferItemBuilder::create(1, 'asset-guid-1', 23.0, [$detail])
    ->withSupplierId('SUP-1')
    ->withType('IT')
    ->withCategory('EQUIPMENT')
    ->build();

Using inside AssetToCalculationBuilder

use Imoli\EflLeasingSdk\Builder\AssetToCalculationBuilder;

$basket = AssetToCalculationBuilder::create('tx-1')
    ->addOfferItem($offerItem)
    ->build();