<?php

namespace Sibs\Sibs\Block;

use Magento\Checkout\Model\Session as CheckoutSession;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Sibs\Sibs\Helper\DataHelper as SibsHelper;

class Success extends Template
{
    /**
     * @var \Magento\Checkout\Model\Session
     */
    protected $_checkoutSession;

    protected $_mainHelper;

    protected $_priceCurrency;

    public function __construct(
        Context $context,
        CheckoutSession $checkoutSession,
        SibsHelper $mainHelper,
        PriceCurrencyInterface $priceCurrency,
        array $data = []
    ) {
        $this->_mainHelper      = $mainHelper;
        $this->_checkoutSession = $checkoutSession;
        $this->_priceCurrency   = $priceCurrency;
        parent::__construct($context, $data);
    }

    public function getOrder()
    {
        $order = $this->_checkoutSession->getLastRealOrder();

        return $order;
    }

    public function getOrderAdditionalInformation()
    {
        return $this->getOrder()->getPayment()->getAdditionalInformation();
    }

    /**
     * Get current currency symbol.
     *
     * @return string
     */
    public function getCurrentCurrencySymbol()
    {
        return $this->_priceCurrency->getCurrency()->getCurrencySymbol();
    }

    public function getInstructions()
    {
        $code = $this->getOrder()->getPayment()->getMethodInstance()->getCode();

        return $this->_mainHelper->getInstructionByCode($code);
    }
}
