<?php


namespace Fifa\ConnectId\Sdk\Model\Transfer;

use DateTime;
use Fifa\ConnectId\Sdk\Util\ToString\Exception\ToStringException;
use Fifa\ConnectId\Sdk\Util\ToString\ToString;

class PaymentDetails
{
    /**
     * @var float
     * @required
     */
    public $Amount;

    /**
     * @var string
     * @required
     */
    public $Currency;

    /**
     * Date in format "Y-m-d" (ref. http://php.net/manual/en/function.date.php)
     *
     * @var string
     * @required
     */
    public $DateOfPayment;

    /**
     * PaymentDetails constructor.
     * @param float $Amount
     * @param string $Currency
     * @param DateTime $DateOfPayment
     * @throws ToStringException
     */
    public function __construct(float $Amount, string $Currency, DateTime $DateOfPayment)
    {
        $this->Amount = $Amount;
        $this->Currency = $Currency;
        $this->setDateOfPayment($DateOfPayment);
    }

    /**
     * Gets DateTime object and sets its string representation to DateOfPayment property
     *
     * @param DateTime $dateOfPayment
     * @return PaymentDetails
     * @throws ToStringException
     */
    public function setDateOfPayment(DateTime $dateOfPayment): PaymentDetails
    {
        $this->DateOfPayment = ToString::getValue($dateOfPayment);
        return $this;
    }

    /**
     * @return string
     */
    public function __toString()
    {
        $required = sprintf('Amount: %s, Currency: %s, DateOfPayment: %s', $this->Amount, $this->Currency, $this->DateOfPayment);
        return sprintf('%s', $required);
    }
}