<?php

namespace Storeplugin\PDFInvoice\Framework\Contracts;

defined('ABSPATH') || exit;

/**
 * Data Source Interface
 * All data sources must implement this interface
 */
interface DataSourceInterface {
    /**
     * Get items with pagination, sorting, and search
     *
     * @param int $perPage Items per page
     * @param int $pageNumber Current page
     * @param string $orderby Column to order by
     * @param string $order ASC or DESC
     * @param string $search Search term
     * @return array
     */
    public function getItems( $perPage, $pageNumber, $orderby, $order, $search );

    /**
     * Get total number of items
     *
     * @param string $search Search term
     * @return int
     */
    public function getTotalItems( $search );

    /**
     * Delete items by IDs
     *
     * @param array $ids
     * @return bool
     */
    public function deleteItems( array $ids );

    /**
     * Get available views/filters
     *
     * @return array
     */
    public function getViews();

    /**
     * Get the field name that uniquely identifies rows.
     *
     * @return string
     */
    public function getRowIdField(): string;

    /**
     * Update the order of items
     *
     * @param array $orderedIds Array of IDs in their new order
     * @return bool True on success, false on failure
     */
    public function updateOrder( array $orderedIds );
}
