Files
2025-08-02 16:30:27 +02:00

77 lines
2.0 KiB
PHP

<?php
namespace KupShop\GraphQLBundle\ApiAdmin\Controller;
use KupShop\GraphQLBundle\ApiAdmin\Annotation\Module;
use KupShop\GraphQLBundle\ApiAdmin\Types\Coupon\Coupon;
use KupShop\GraphQLBundle\ApiAdmin\Types\Coupon\Response\CouponMutateResponse;
use KupShop\GraphQLBundle\ApiAdmin\Types\OrderDiscount\DiscountCoupon;
use KupShop\GraphQLBundle\ApiAdmin\Util\CouponUtil;
use TheCodingMachine\GraphQLite\Annotations\Mutation;
use TheCodingMachine\GraphQLite\Annotations\Query;
class CouponController
{
/**
* @var CouponUtil
*/
private $couponUtil;
/**
* @required
*/
public function setOrderUtil(CouponUtil $couponUtil): void
{
$this->couponUtil = $couponUtil;
}
/**
* @deprecated Use `discountCodeExists` OR `coupon` method
*/
#[Query]
public function checkCouponExists(string $coupon): ?Coupon
{
return $this->couponUtil->checkCouponExists($coupon);
}
/**
* Ověří, zda zadaný slevový kupón nebo dárkový poukaz existuje.
*/
#[Query]
#[Module(\Modules::ORDER_DISCOUNT)]
public function discountCodeExists(string $code): bool
{
return $this->couponUtil->checkCodeExists($code);
}
/**
* Informace o dárkovém poukazu (generovaný kód).
*/
#[Query]
#[Module(\Modules::ORDER_DISCOUNT)]
public function coupon(string $code): ?DiscountCoupon
{
return $this->couponUtil->getCoupon($code);
}
/**
* Nastaví generovaný kód jako použitý.
*/
#[Mutation]
#[Module(\Modules::ORDER_DISCOUNT)]
public function couponUse(string $code): CouponMutateResponse
{
return $this->couponUtil->useCoupon($code);
}
/**
* Znovu aktivuje už použitý generovaný kód.
*/
#[Mutation]
#[Module(\Modules::ORDER_DISCOUNT)]
public function couponReactivate(string $code): CouponMutateResponse
{
return $this->couponUtil->reactivateCoupon($code);
}
}