<?php
namespace API\Partenaire;

use Helpers\Trad\ITrad;

/**
 * Interface pour Partenaire capable de chercher des entité externe (généralement afin de les importer)
 */
interface IEntitySearch
{
    /**
     * @param class-string $entityClass
     * @param array<mixed> $data Current data raw (unvalidated) input data
     * @return ?array{count:?int,list:array<array<string>>,hasMore:bool} List of candidate (or null if not able to search)
     */
    public function entitySearch(string $entityClass, array $data) :?array;
    
    /**
     * If return true, then getDetail is used before sending data to the creation form
     * @param array<mixed> $mapping
     */
    public function needDetail(string $entityClass, array $mapping) :bool;
    
    /**
     * This is used in the case needDetail return true
     * @param array<string> $data Search data as reutrned in entitySearch list
     * @return array<string>
     */
    public function getDetail(string $entityClass, array $data) :array;
    
    /**
     * @param class-string $entityClass
     * @return array<string> if trad is defined return a map of choices label indexed by their values, else return an array of choices value
     */
    public function listMappingChoice(string $entityClass, string $field, ITrad $trad) :?array;
}
