*/ protected function input_properties(): array { return array( 'threshold' => array( 'type' => 'integer', 'default' => 5, 'minimum' => 0, 'description' => __( 'Quantity at or below which a product counts as low.', 'acrossai-abilities-manager' ) ), 'limit' => array( 'type' => 'integer', 'default' => 50, 'minimum' => 1, 'maximum' => 200, 'description' => __( 'How many products to examine.', 'acrossai-abilities-manager' ) ), ); } /** * @since 0.0.34 * @return array */ protected function required_input(): array { return array(); } /** * @since 0.0.34 * @return array */ protected function output_properties(): array { return array( 'threshold' => array( 'type' => 'integer' ), 'products' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'additionalProperties' => true ) ), 'count' => array( 'type' => 'integer' ), ); } /** * @since 0.0.34 * @return array */ protected function annotations(): array { return array( 'readonly' => true, 'destructive' => false, 'idempotent' => true, ); } /** * @since 0.0.34 * @param array $input Input. * @return array|WP_Error */ protected function run( array $input ) { return Product_Repository::low_stock( (int) ( $input['threshold'] ?? 5 ), (int) ( $input['limit'] ?? 50 ) ); } }