<?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\AmountWithBreakdown;
use PaypalServerSdkLib\Models\Item;
use PaypalServerSdkLib\Models\PayeeBase;
use PaypalServerSdkLib\Models\PaymentInstruction;
use PaypalServerSdkLib\Models\PurchaseUnitRequest;
use PaypalServerSdkLib\Models\ShippingDetails;
use PaypalServerSdkLib\Models\SupplementaryData;

/**
 * Builder for model PurchaseUnitRequest
 *
 * @see PurchaseUnitRequest
 */
class PurchaseUnitRequestBuilder
{
    /**
     * @var PurchaseUnitRequest
     */
    private $instance;

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

    /**
     * Initializes a new Purchase Unit Request Builder object.
     *
     * @param AmountWithBreakdown $amount
     */
    public static function init(AmountWithBreakdown $amount): self
    {
        return new self(new PurchaseUnitRequest($amount));
    }

    /**
     * Sets reference id field.
     *
     * @param string|null $value
     */
    public function referenceId(?string $value): self
    {
        $this->instance->setReferenceId($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 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 ShippingDetails|null $value
     */
    public function shipping(?ShippingDetails $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;
    }

    /**
     * Initializes a new Purchase Unit Request object.
     */
    public function build(): PurchaseUnitRequest
    {
        return CoreHelper::clone($this->instance);
    }
}
