<?php

declare (strict_types=1);
/*
 * PaypalServerSdkLib
 *
 * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
 */
namespace FormGent\PaypalServerSdkLib\Models\Builders;

use FormGent\Core\Utils\CoreHelper;
use FormGent\PaypalServerSdkLib\Models\AmountWithBreakdown;
use FormGent\PaypalServerSdkLib\Models\Item;
use FormGent\PaypalServerSdkLib\Models\PayeeBase;
use FormGent\PaypalServerSdkLib\Models\PaymentCollection;
use FormGent\PaypalServerSdkLib\Models\PaymentInstruction;
use FormGent\PaypalServerSdkLib\Models\PurchaseUnit;
use FormGent\PaypalServerSdkLib\Models\ShippingWithTrackingDetails;
use FormGent\PaypalServerSdkLib\Models\SupplementaryData;
/**
 * Builder for model PurchaseUnit
 *
 * @see PurchaseUnit
 */
class PurchaseUnitBuilder
{
    /**
     * @var PurchaseUnit
     */
    private $instance;
    private function __construct(PurchaseUnit $instance)
    {
        $this->instance = $instance;
    }
    /**
     * Initializes a new Purchase Unit Builder object.
     */
    public static function init() : self
    {
        return new self(new PurchaseUnit());
    }
    /**
     * Sets reference id field.
     *
     * @param string|null $value
     */
    public function referenceId(?string $value) : self
    {
        $this->instance->setReferenceId($value);
        return $this;
    }
    /**
     * Sets amount field.
     *
     * @param AmountWithBreakdown|null $value
     */
    public function amount(?AmountWithBreakdown $value) : self
    {
        $this->instance->setAmount($value);
        return $this;
    }
    /**
     * Sets payee field.
     *
     * @param PayeeBase|null $value
     */
    public function payee(?PayeeBase $value) : self
    {
        $this->instance->setPayee($value);
        return $this;
    }
    /**
     * Sets payment instruction field.
     *
     * @param PaymentInstruction|null $value
     */
    public function paymentInstruction(?PaymentInstruction $value) : self
    {
        $this->instance->setPaymentInstruction($value);
        return $this;
    }
    /**
     * Sets description field.
     *
     * @param string|null $value
     */
    public function description(?string $value) : self
    {
        $this->instance->setDescription($value);
        return $this;
    }
    /**
     * Sets custom id field.
     *
     * @param string|null $value
     */
    public function customId(?string $value) : self
    {
        $this->instance->setCustomId($value);
        return $this;
    }
    /**
     * Sets invoice id field.
     *
     * @param string|null $value
     */
    public function invoiceId(?string $value) : self
    {
        $this->instance->setInvoiceId($value);
        return $this;
    }
    /**
     * Sets id field.
     *
     * @param string|null $value
     */
    public function id(?string $value) : self
    {
        $this->instance->setId($value);
        return $this;
    }
    /**
     * Sets soft descriptor field.
     *
     * @param string|null $value
     */
    public function softDescriptor(?string $value) : self
    {
        $this->instance->setSoftDescriptor($value);
        return $this;
    }
    /**
     * Sets items field.
     *
     * @param Item[]|null $value
     */
    public function items(?array $value) : self
    {
        $this->instance->setItems($value);
        return $this;
    }
    /**
     * Sets shipping field.
     *
     * @param ShippingWithTrackingDetails|null $value
     */
    public function shipping(?ShippingWithTrackingDetails $value) : self
    {
        $this->instance->setShipping($value);
        return $this;
    }
    /**
     * Sets supplementary data field.
     *
     * @param SupplementaryData|null $value
     */
    public function supplementaryData(?SupplementaryData $value) : self
    {
        $this->instance->setSupplementaryData($value);
        return $this;
    }
    /**
     * Sets payments field.
     *
     * @param PaymentCollection|null $value
     */
    public function payments(?PaymentCollection $value) : self
    {
        $this->instance->setPayments($value);
        return $this;
    }
    /**
     * Sets most recent errors field.
     *
     * @param array $value
     */
    public function mostRecentErrors(array $value) : self
    {
        $this->instance->setMostRecentErrors($value);
        return $this;
    }
    /**
     * Initializes a new Purchase Unit object.
     */
    public function build() : PurchaseUnit
    {
        return CoreHelper::clone($this->instance);
    }
}
