| Current Path : /home/rtorresani/www/app/code/Amasty/RewardsGraphQl/Model/Resolver/ |
| Current File : //home/rtorresani/www/app/code/Amasty/RewardsGraphQl/Model/Resolver/UsedPointsInCart.php |
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Reward Points GraphQL (System)
*/
namespace Amasty\RewardsGraphQl\Model\Resolver;
use Amasty\Rewards\Api\Data\SalesQuote\EntityInterface;
use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
class UsedPointsInCart implements ResolverInterface
{
public const USED_POINTS = 'used_points';
/**
* @param Field $field
* @param $context
* @param ResolveInfo $info
* @param array|null $value
* @param array|null $args
* @return array
* @throws GraphQlInputException
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
{
if (!isset($value['model'])) {
throw new GraphQlInputException(__('"model" value must be specified'));
}
/** @var \Magento\Quote\Model\Quote $cart */
$cart = $value['model'];
return [
self::USED_POINTS => $cart->getData(EntityInterface::POINTS_SPENT)
];
}
}