<?php
/**
 * 2026 Paysera
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * @author Paysera <plugins@paysera.com>
 * @copyright 2026 Paysera
 * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
 * International Registered Trademark & Property of Paysera
 */

declare(strict_types=1);

namespace Paysera\PrestashopPayments\Dto;

use Evp\Component\Money\Money;

if (!defined('_PS_VERSION_')) {
    exit;
}

class PaymentListItem
{
    public function __construct(
        private int $id,
        private string $reference,
        private Money $amount,
        private string $status,
        private string $dateAdd,
        private Customer $customer,
        private string $paymentMethod,
        private int $cartId,
        private ?string $payseraPaymentId = null,
        private ?string $payseraOrderId = null
    ) {
    }

    public function getId(): int
    {
        return $this->id;
    }

    public function getReference(): string
    {
        return $this->reference;
    }

    public function getAmount(): Money
    {
        return $this->amount;
    }

    public function getStatus(): string
    {
        return $this->status;
    }

    public function getDateAdd(): string
    {
        return $this->dateAdd;
    }

    public function getCustomer(): Customer
    {
        return $this->customer;
    }

    public function getPaymentMethod(): string
    {
        return $this->paymentMethod;
    }

    public function getCartId(): int
    {
        return $this->cartId;
    }

    public function getPayseraPaymentId(): ?string
    {
        return $this->payseraPaymentId;
    }

    public function getPayseraOrderId(): ?string
    {
        return $this->payseraOrderId;
    }

    /**
     * @return array<string, mixed>
     */
    public function toArray(): array
    {
        return [
            'id' => $this->id,
            'reference' => $this->reference,
            'amount' => [
                'value' => (float) $this->amount->getAmount(),
                'currency' => $this->amount->getCurrency(),
            ],
            'status' => $this->status,
            'date_add' => $this->dateAdd,
            'customer' => $this->customer->toArray(),
            'payment_method' => $this->paymentMethod,
            'cart_id' => $this->cartId,
            'paysera_payment_id' => $this->payseraPaymentId,
            'paysera_order_id' => $this->payseraOrderId,
        ];
    }
}
