55 lines
1.7 KiB
PHP
55 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KupShop\GraphQLBundle\ApiAdmin\Controller;
|
|
|
|
use KupShop\GraphQLBundle\ApiAdmin\Annotation\Module;
|
|
use KupShop\GraphQLBundle\ApiAdmin\Types\Collection\OrderPaymentCollection;
|
|
use KupShop\GraphQLBundle\ApiAdmin\Types\OrderPayment\Input\OrderPaymentFilterInput;
|
|
use KupShop\GraphQLBundle\ApiAdmin\Types\OrderPayment\Input\OrderPaymentInput;
|
|
use KupShop\GraphQLBundle\ApiAdmin\Types\OrderPayment\OrderPayment;
|
|
use KupShop\GraphQLBundle\ApiAdmin\Types\OrderPayment\Response\OrderPaymentMutateResponse;
|
|
use KupShop\GraphQLBundle\ApiAdmin\Util\OrderPaymentUtil;
|
|
use TheCodingMachine\GraphQLite\Annotations\Mutation;
|
|
use TheCodingMachine\GraphQLite\Annotations\Query;
|
|
|
|
class OrderPaymentController
|
|
{
|
|
public function __construct(
|
|
private readonly ?OrderPaymentUtil $orderPaymentUtil,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Vrací detaily platby objednávky podle ID.
|
|
*/
|
|
#[Query]
|
|
#[Module(\Modules::ORDER_PAYMENT)]
|
|
public function orderPayment(int $paymentId): ?OrderPayment
|
|
{
|
|
return $this->orderPaymentUtil->getOrderPayment($paymentId);
|
|
}
|
|
|
|
/**
|
|
* Vrací všechny platby podle ID nebo kódu objednávky.
|
|
*/
|
|
#[Query]
|
|
#[Module(\Modules::ORDER_PAYMENT)]
|
|
public function orderPayments(?OrderPaymentFilterInput $filter = null): ?OrderPaymentCollection
|
|
{
|
|
return $this->orderPaymentUtil->getOrderPayments($filter?->getParameters());
|
|
}
|
|
|
|
/**
|
|
* Vloží platbu k objednávce.
|
|
*/
|
|
#[Mutation]
|
|
#[Module(\Modules::ORDER_PAYMENT)]
|
|
public function orderPaymentCreate(
|
|
OrderPaymentInput $orderPayment,
|
|
): OrderPaymentMutateResponse {
|
|
return $this->orderPaymentUtil->orderPaymentCreate($orderPayment);
|
|
}
|
|
}
|