<?php

namespace Oney\ThreeByFour\Gateway\Request;

use Magento\Payment\Gateway\Helper\SubjectReader;
use Magento\Payment\Gateway\Request\BuilderInterface;
use Oney\ThreeByFour\Logger\Logger;

/**
 * Cancel Data Builder
 * 
 * Builds cancel request data for Oney payment gateway.
 * Handles order cancellation payload construction.
 * 
 * @package Oney\ThreeByFour\Gateway\Request
 * @version 1.0.0
 * @author Oney
 * @since 1.0.0
 */
class CancelDataBuilder implements BuilderInterface
{
    /**
     * Subject reader instance
     * 
     * @var SubjectReader
     * @version 1.0.0
     */
    protected $_subjectReader;
    
    /**
     * Logger instance
     * 
     * @var Logger
     * @version 1.0.0
     */
    protected $_logger;

    /**
     * Constructor
     * 
     * @param SubjectReader $subjectReader Subject reader
     * @param Logger $logger Logger instance
     * @version 1.0.0
     */
    public function __construct(
        SubjectReader $subjectReader,
        Logger $logger
    ) {
        $this->_logger = $logger;
        $this->_subjectReader = $subjectReader;
    }

    /**
     * Build cancel request data
     * 
     * @param array $buildSubject Build subject data
     * @return array Cancel request payload
     * @version 1.0.0
     */
    public function build(array $buildSubject): array
    {
        $paymentDO = $this->_subjectReader::readPayment($buildSubject);
        $order = $paymentDO->getOrder();
        $this->_logger->info('[SUCCESS] [REQUEST] Payment API 1.2 - Cancel order: ', [
            'order' => $order->getData()
        ]);
        $payment = $paymentDO->getPayment();
        $this->_logger->info('[SUCCESS] [REQUEST] Payment API 1.2 - Cancel payment: ', [
            'payment' => $payment->getData()
        ]);

        $response = [
            "purchase" => [

            ]
        ];

        $this->_logger->info('[SUCCESS] [REQUEST] Payment API 1.2 - Cancel payload built: ', [
            'payload' => $response
        ]);
        return $response;
    }
}
