<?php
declare(strict_types=1);

// THIS FILE IS AUTO-GENERATED. DO NOT EDIT MANUALLY.

namespace Automattic\WooCommerce\Internal\Api\Autogenerated\GraphQLMutations;

use Automattic\WooCommerce\Api\Mutations\Coupons\DeleteCoupon as DeleteCouponCommand;
use Automattic\WooCommerce\Internal\Api\QueryInfoExtractor;
use Automattic\WooCommerce\Internal\Api\Utils;
use Automattic\WooCommerce\Internal\Api\Autogenerated\GraphQLTypes\Output\DeleteCouponResult as DeleteCouponResultType;
use Automattic\WooCommerce\Internal\Api\Schema\ResolveInfo;
use Automattic\WooCommerce\Internal\Api\Schema\Type;

class DeleteCoupon {
	public static function get_field_definition(): array {
		return array(
			'type'        => Type::nonNull( DeleteCouponResultType::get() ),
			'description' => __( 'Delete a coupon.', 'woocommerce' ),
			'args'        => array(
				'id'    => array(
					'type'        => Type::nonNull( Type::int() ),
					'description' => __( 'The ID of the coupon to delete.', 'woocommerce' ),
				),
				'force' => array(
					'type'         => Type::nonNull( Type::boolean() ),
					'description'  => __( 'Whether to permanently delete the coupon (bypass trash).', 'woocommerce' ),
					'defaultValue' => false,
				),
			),
			'resolve'     => array( self::class, 'resolve' ),
		);
	}

	public static function resolve( mixed $root, array $args, mixed $context, ResolveInfo $info ): mixed {
		Utils::check_current_user_can( 'manage_woocommerce' );

		$command = \Automattic\WooCommerce\Api\Container::get( DeleteCouponCommand::class );

		$execute_args = array();
		if ( array_key_exists( 'id', $args ) ) {
			$execute_args['id'] = $args['id'];
		}
		if ( array_key_exists( 'force', $args ) ) {
			$execute_args['force'] = $args['force'];
		}

		$result = Utils::execute_command( $command, $execute_args );

		return $result;
	}
}
