<?php

namespace Square\Types;

use Square\Core\Json\JsonSerializableType;
use Square\Core\Json\JsonProperty;

class RefundCreatedEventObject extends JsonSerializableType
{
    /**
     * @var ?PaymentRefund $refund The created refund.
     */
    #[JsonProperty('refund')]
    private ?PaymentRefund $refund;

    /**
     * @param array{
     *   refund?: ?PaymentRefund,
     * } $values
     */
    public function __construct(
        array $values = [],
    ) {
        $this->refund = $values['refund'] ?? null;
    }

    /**
     * @return ?PaymentRefund
     */
    public function getRefund(): ?PaymentRefund
    {
        return $this->refund;
    }

    /**
     * @param ?PaymentRefund $value
     */
    public function setRefund(?PaymentRefund $value = null): self
    {
        $this->refund = $value;
        $this->_setField('refund');
        return $this;
    }

    /**
     * @return string
     */
    public function __toString(): string
    {
        return $this->toJson();
    }
}
