PlatformFetcherInterface.php
42 lines
| 1 | <?php |
| 2 | |
| 3 | declare( strict_types=1 ); |
| 4 | |
| 5 | namespace Automattic\WooCommerce\Internal\CLI\Migrator\Interfaces; |
| 6 | |
| 7 | /** |
| 8 | * Defines the contract for classes responsible for retrieving |
| 9 | * data (like products or orders) from a source platform API. |
| 10 | * |
| 11 | * Implementations should accept platform credentials via constructor: |
| 12 | * public function __construct(array $credentials) |
| 13 | */ |
| 14 | interface PlatformFetcherInterface { |
| 15 | |
| 16 | /** |
| 17 | * Fetches a batch of items from the source platform. |
| 18 | * |
| 19 | * @param array $args Arguments for fetching (e.g., limit, cursor, filters). |
| 20 | * Specific arguments depend on the implementation. |
| 21 | * |
| 22 | * @return array An array containing: |
| 23 | * 'items' => array Raw items fetched from the platform. |
| 24 | * 'cursor' => ?string The cursor for the next page, or null if no more pages. |
| 25 | * 'has_next_page' => bool Indicates if there are more pages to fetch. |
| 26 | */ |
| 27 | public function fetch_batch( array $args ): array; |
| 28 | |
| 29 | /** |
| 30 | * Fetches the estimated total count of items available for migration. |
| 31 | * |
| 32 | * Used primarily for progress indicators. If a total count is not available, |
| 33 | * this method should return 0. |
| 34 | * |
| 35 | * @param array $args Arguments for filtering the count (e.g., status, date range). |
| 36 | * Specific arguments depend on the implementation. |
| 37 | * |
| 38 | * @return int The total estimated count. |
| 39 | */ |
| 40 | public function fetch_total_count( array $args ): int; |
| 41 | } |
| 42 |