<?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\Money;
use PaypalServerSDKLib\Models\RefundPaymentInstruction;
use PaypalServerSDKLib\Models\RefundRequest;

/**
 * Builder for model RefundRequest
 *
 * @see RefundRequest
 */
class RefundRequestBuilder
{
    /**
     * @var RefundRequest
     */
    private $instance;

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

    /**
     * Initializes a new refund request Builder object.
     */
    public static function init(): self
    {
        return new self(new RefundRequest());
    }

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

    /**
     * Sets custom id field.
     */
    public function customId(?string $value): self
    {
        $this->instance->setCustomId($value);
        return $this;
    }

    /**
     * Sets invoice id field.
     */
    public function invoiceId(?string $value): self
    {
        $this->instance->setInvoiceId($value);
        return $this;
    }

    /**
     * Sets note to payer field.
     */
    public function noteToPayer(?string $value): self
    {
        $this->instance->setNoteToPayer($value);
        return $this;
    }

    /**
     * Sets payment instruction field.
     */
    public function paymentInstruction(?RefundPaymentInstruction $value): self
    {
        $this->instance->setPaymentInstruction($value);
        return $this;
    }

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