<?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\Products\DeleteProduct as DeleteProductCommand;
use Automattic\WooCommerce\Internal\Api\QueryInfoExtractor;
use Automattic\WooCommerce\Internal\Api\Utils;
use Automattic\WooCommerce\Internal\Api\Schema\ResolveInfo;
use Automattic\WooCommerce\Internal\Api\Schema\Type;

class DeleteProduct {
	public static function get_field_definition(): array {
		return array(
			'type'        => Type::nonNull(
				new \Automattic\WooCommerce\Internal\Api\Schema\ObjectType(
					array(
						'name'   => 'DeleteProductResult',
						'fields' => array(
							'result' => array( 'type' => Type::nonNull( Type::boolean() ) ),
						),
					)
				)
			),
			'description' => __( 'Delete a product.', 'woocommerce' ),
			'args'        => array(
				'id'    => array(
					'type'        => Type::nonNull( Type::int() ),
					'description' => __( 'The ID of the product to delete.', 'woocommerce' ),
				),
				'force' => array(
					'type'         => Type::nonNull( Type::boolean() ),
					'description'  => __( 'Whether to permanently delete the product (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( DeleteProductCommand::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 array( 'result' => $result );
	}
}
