Customers
3 months ago
Fulfillments
1 month ago
OrderNotes
3 months ago
Orders
1 month ago
Products
1 month ago
Refunds
1 month ago
Settings
3 months ago
ShippingZoneMethod
5 months ago
ShippingZones
3 months ago
AbstractCollectionQuery.php
7 months ago
AbstractController.php
7 months ago
AbstractSchema.php
7 months ago
AbstractCollectionQuery.php
72 lines
| 1 | <?php |
| 2 | /** |
| 3 | * AbstractCollectionQuery class. |
| 4 | * |
| 5 | * @package WooCommerce\RestApi |
| 6 | * @internal This file is for internal use only and should not be used by external code. |
| 7 | */ |
| 8 | |
| 9 | declare( strict_types=1 ); |
| 10 | |
| 11 | namespace Automattic\WooCommerce\Internal\RestApi\Routes\V4; |
| 12 | |
| 13 | defined( 'ABSPATH' ) || exit; |
| 14 | |
| 15 | use WP_REST_Request; |
| 16 | use WC_Order; |
| 17 | |
| 18 | /** |
| 19 | * AbstractCollectionQuery class. |
| 20 | * |
| 21 | * @internal This class is for internal use only and should not be used by external code. |
| 22 | */ |
| 23 | abstract class AbstractCollectionQuery { |
| 24 | /** |
| 25 | * Operator constants for easy access. |
| 26 | */ |
| 27 | const OPERATOR_IS = 'is'; |
| 28 | const OPERATOR_IS_NOT = 'isNot'; |
| 29 | const OPERATOR_LESS_THAN = 'lessThan'; |
| 30 | const OPERATOR_GREATER_THAN = 'greaterThan'; |
| 31 | const OPERATOR_LESS_THAN_OR_EQUAL = 'lessThanOrEqual'; |
| 32 | const OPERATOR_GREATER_THAN_OR_EQUAL = 'greaterThanOrEqual'; |
| 33 | const OPERATOR_BETWEEN = 'between'; |
| 34 | |
| 35 | /** |
| 36 | * Array of operators for validation. |
| 37 | */ |
| 38 | const OPERATORS = array( |
| 39 | self::OPERATOR_IS, |
| 40 | self::OPERATOR_IS_NOT, |
| 41 | self::OPERATOR_LESS_THAN, |
| 42 | self::OPERATOR_GREATER_THAN, |
| 43 | self::OPERATOR_LESS_THAN_OR_EQUAL, |
| 44 | self::OPERATOR_GREATER_THAN_OR_EQUAL, |
| 45 | self::OPERATOR_BETWEEN, |
| 46 | ); |
| 47 | |
| 48 | /** |
| 49 | * Get query schema for collection. |
| 50 | * |
| 51 | * @return array |
| 52 | */ |
| 53 | abstract public function get_query_schema(): array; |
| 54 | |
| 55 | /** |
| 56 | * Prepares query args. |
| 57 | * |
| 58 | * @param WP_REST_Request $request The request object. |
| 59 | * @return array |
| 60 | */ |
| 61 | abstract public function get_query_args( WP_REST_Request $request ): array; |
| 62 | |
| 63 | /** |
| 64 | * Get results of the query. |
| 65 | * |
| 66 | * @param array $query_args The query arguments. |
| 67 | * @param WP_REST_Request $request The request object. |
| 68 | * @return array |
| 69 | */ |
| 70 | abstract public function get_query_results( array $query_args, WP_REST_Request $request ): array; |
| 71 | } |
| 72 |