<?php

namespace Fifa\ConnectId\Sdk\Model;

use Exception;
use Fifa\ConnectId\Sdk\Api\Model\PersonDuplicateType;

/**
 * Class PersonDuplicateWithDetails
 * @package Fifa\ConnectId\Sdk\Model
 */
class PersonDuplicateWithDetails
{
    /**
     * @var PersonDuplicateType
     */
    private $duplicate;

    /**
     * @var string
     */
    private $requestRecipientOrganisationId;

    /**
     * @var PersonDetails
     */
    private $personDetails;

    /**
     * @var Exception|null
     */
    private $exception;

    /**
     * @var null|string
     */
    private $requestRecipientOrganisationSystemId;

    /**
     * Constructor
     *
     * @param PersonDuplicateType $duplicate
     * @param string|null $requestRecipientOrganisationId
     * @param string|null $requestRecipientOrganisationSystemId
     * @param Exception|null $providerException
     */
    public function __construct(PersonDuplicateType $duplicate, ?string $requestRecipientOrganisationId, ?string $requestRecipientOrganisationSystemId = null, ?Exception $providerException = null)
    {
        $this->duplicate = $duplicate;
        $this->requestRecipientOrganisationId = $requestRecipientOrganisationId;
        $this->exception = $providerException;
        $this->requestRecipientOrganisationSystemId = $requestRecipientOrganisationSystemId;
    }

    /**
     * String representation of the object
     *
     * @return string
     */
    public function __toString()
    {
        return 'WasRequestSent: ' . ($this->wasRequestSend() ? 'true' : 'false') . ', RequestRecipientOrganisationId: ' . $this->getRequestRecipientOrganisationId() .
            ', RequestRecipientOrganisationSystemId: ' . (!is_null($this->requestRecipientOrganisationSystemId) ? $this->requestRecipientOrganisationSystemId : 'null');
    }

    /**
     * Getter for wasRequestSend
     *
     * @return boolean
     */
    public function wasRequestSend(): bool
    {
        return is_null($this->exception);
    }

    /**
     * Getter for duplicate
     *
     * @return PersonDuplicateType
     */
    public function getDuplicate(): PersonDuplicateType
    {
        return $this->duplicate;
    }

    /**
     * Getter for requestRecipientOrganisationId
     *
     * @return string|null
     */
    public function getRequestRecipientOrganisationId(): ?string
    {
        return $this->requestRecipientOrganisationId;
    }

    /**
     * Getter for person details
     *
     * @return PersonDetails|null
     */
    public function getPersonDetails(): ?PersonDetails
    {
        return $this->personDetails;
    }

    /**
     * Setter for person details
     *
     * @param PersonDetails $personDetails
     * @return PersonDuplicateWithDetails
     */
    public function setPersonDetails(PersonDetails $personDetails): PersonDuplicateWithDetails
    {
        $this->personDetails = $personDetails;
        return $this;
    }

    /**
     * Getter for duplicate exception
     *
     * @return Exception|null
     */
    public function getException(): ?Exception
    {
        return $this->exception;
    }

    /**
     * @return null|string
     */
    public function getRequestRecipientOrganisationSystemId(): ?string
    {
        return $this->requestRecipientOrganisationSystemId;
    }
}