<?php

declare(strict_types=1);

namespace KupShop\GraphQLBundle\ApiPos\Types\Order;

use KupShop\GraphQLBundle\ApiAdmin\Types\Coupon\Coupon;
use KupShop\GraphQLBundle\ApiPos\Types\Purchase\PosPurchaseDiscount;
use TheCodingMachine\GraphQLite\Annotations\Type;

#[Type]
class PosInvalidDiscountCoupon extends PosPurchaseDiscount implements \JsonSerializable
{
    public function __construct(
        array $note,
    ) {
        parent::__construct(null, false, $note);
    }

    public static function fromCoupon(Coupon $coupon): self
    {
        return new self([
            'coupon' => $coupon->getCode(),
        ]);
    }

    public function jsonSerialize(): array
    {
        return $this->note;
    }
}
