<?php
/**
 * Product service interface
 *
 * @package    SeQura/WC
 * @subpackage SeQura/WC/Services
 */

namespace SeQura\WC\Services\Product;

use DateTime;
use WC_Product;

/**
 * Handle use cases related to products
 */
interface Interface_Product_Service {

	/**
	 * Get desired first charge date for a product
	 * 
	 * @param int|WC_Product $product The product ID or product object
	 * @return DateTime|null|string
	 */
	public function get_desired_first_charge_date( $product, bool $raw_value = false );

	/**
	 * Get product instance
	 * 
	 * @param int|WC_Product $product The product ID or product object
	 */
	public function get_product_instance( $product ): ?WC_Product;

	/**
	 * Check if product is a service
	 * 
	 * @param int|WC_Product $product The product ID or product object
	 */
	public function is_service( $product ): bool;

	/**
	 * Update is service value
	 */
	public function set_is_service( int $product_id, ?string $value ): void;

	/**
	 * Check if product is banned
	 * 
	 * @param int|WC_Product $product The product ID or product object
	 */
	public function is_banned( $product ): bool;

	/**
	 * Check if product and category ban lists are empty
	 */
	public function is_ban_list_empty(): bool;

	/**
	 * Update is_banned value
	 */
	public function set_is_banned( int $product_id, ?string $value ): void;

	/**
	 * Get product is_banned value
	 * 
	 * @param int|WC_Product $product The product ID or product object
	 */
	public function get_is_banned( $product ): bool;

	/**
	 * Get product service end date
	 *
	 * @param WC_Product|int $product the product we are building item info for.
	 */
	public function get_service_end_date( $product, bool $raw_value = false ): string;

	/**
	 * Update service end date value
	 */
	public function set_service_end_date( int $product_id, ?string $value ): void;

	/**
	 * Update desired_first_charge_date value
	 */
	public function set_desired_first_charge_date( int $product_id, ?string $value ): void;

	/**
	 * Get registration amount
	 *
	 * @param WC_Product|int $product the product we are building item info for.
	 */
	public function get_registration_amount( $product, bool $to_cents = false ): float;

	/**
	 * Update registration amount value
	 */
	public function set_registration_amount( int $product_id, ?float $value ): void;

	/**
	 * Check if we can display widget of a payment method for a product
	 * 
	 * @param WC_Product|int $product the product.
	 * @param array<string, string> $method the payment method. See PaymentMethodsResponse::toArray() output
	 */
	public function can_display_widget_for_method( $product, $method ): bool;

	/**
	 * Get enabledForServices from general settings.
	 */
	public function is_enabled_for_services( ?string $country = null ): bool;

	/**
	 * Get allowFirstServicePaymentDelay from general settings.
	 */
	public function is_allow_first_service_payment_delay( ?string $country = null ): bool;

	/**
	 * Get allowServiceRegistrationItems from general settings.
	 */
	public function is_allow_service_registration_items( ?string $country = null ): bool;

	/**
	 * Get defaultServicesEndDate from general settings.
	 */
	public function get_default_services_end_date(): string;

	/**
	 * Get the reference of a given product
	 */
	public function get_reference( WC_Product $product ): string;

	/**
	 * Get product name
	 */
	public function get_name( WC_Product $product ): string;
}
