<?php

declare(strict_types=1);

/*
 * PaypalServerSDKLib
 *
 * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
 */

namespace PaypalServerSDKLib\Models\Builders;

use Core\Utils\CoreHelper;
use PaypalServerSDKLib\Models\LineItem;
use PaypalServerSDKLib\Models\Money;
use PaypalServerSDKLib\Models\UniversalProductCode;

/**
 * Builder for model LineItem
 *
 * @see LineItem
 */
class LineItemBuilder
{
    /**
     * @var LineItem
     */
    private $instance;

    private function __construct(LineItem $instance)
    {
        $this->instance = $instance;
    }

    /**
     * Initializes a new line item Builder object.
     */
    public static function init(string $name, string $quantity): self
    {
        return new self(new LineItem($name, $quantity));
    }

    /**
     * Sets description field.
     */
    public function description(?string $value): self
    {
        $this->instance->setDescription($value);
        return $this;
    }

    /**
     * Sets sku field.
     */
    public function sku(?string $value): self
    {
        $this->instance->setSku($value);
        return $this;
    }

    /**
     * Sets url field.
     */
    public function url(?string $value): self
    {
        $this->instance->setUrl($value);
        return $this;
    }

    /**
     * Sets image url field.
     */
    public function imageUrl(?string $value): self
    {
        $this->instance->setImageUrl($value);
        return $this;
    }

    /**
     * Sets upc field.
     */
    public function upc(?UniversalProductCode $value): self
    {
        $this->instance->setUpc($value);
        return $this;
    }

    /**
     * Sets unit amount field.
     */
    public function unitAmount(?Money $value): self
    {
        $this->instance->setUnitAmount($value);
        return $this;
    }

    /**
     * Sets tax field.
     */
    public function tax(?Money $value): self
    {
        $this->instance->setTax($value);
        return $this;
    }

    /**
     * Sets commodity code field.
     */
    public function commodityCode(?string $value): self
    {
        $this->instance->setCommodityCode($value);
        return $this;
    }

    /**
     * Sets discount amount field.
     */
    public function discountAmount(?Money $value): self
    {
        $this->instance->setDiscountAmount($value);
        return $this;
    }

    /**
     * Sets total amount field.
     */
    public function totalAmount(?Money $value): self
    {
        $this->instance->setTotalAmount($value);
        return $this;
    }

    /**
     * Sets unit of measure field.
     */
    public function unitOfMeasure(?string $value): self
    {
        $this->instance->setUnitOfMeasure($value);
        return $this;
    }

    /**
     * Initializes a new line item object.
     */
    public function build(): LineItem
    {
        return CoreHelper::clone($this->instance);
    }
}
