From 59193529a8ef7a5eb96c4056525dd1a2ac1c5afc Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Thu, 10 Oct 2019 11:10:23 +0700 Subject: [PATCH] Update API --- inc/api/v1/property.php | 16 +++---- inc/api/v1/search-form.php | 89 ++++++++++++++++++++++++++++++++++---- 2 files changed, 88 insertions(+), 17 deletions(-) diff --git a/inc/api/v1/property.php b/inc/api/v1/property.php index c16a42d9..cb06f7a3 100644 --- a/inc/api/v1/property.php +++ b/inc/api/v1/property.php @@ -578,6 +578,14 @@ class Opalestate_Property_Api extends Opalestate_Base_API { 'validate_callback' => 'rest_validate_request_arg', ]; + $params['cat'] = [ + 'description' => __( 'Categories', 'opalestate-pro' ), + 'type' => 'array', + // 'default' => '', + // 'sanitize_callback' => 'sanitize_text_field', + 'validate_callback' => 'rest_validate_request_arg', + ]; + $params['types'] = [ 'description' => __( 'Types', 'opalestate-pro' ), 'type' => 'string', @@ -602,14 +610,6 @@ class Opalestate_Property_Api extends Opalestate_Base_API { 'validate_callback' => 'rest_validate_request_arg', ]; - $params['amenities'] = [ - 'description' => __( 'Amenities', 'opalestate-pro' ), - 'type' => 'array', - // 'default' => '', - // 'sanitize_callback' => 'sanitize_text_field', - 'validate_callback' => 'rest_validate_request_arg', - ]; - $params['info'] = [ 'description' => __( 'Info', 'opalestate-pro' ), 'type' => 'array', diff --git a/inc/api/v1/search-form.php b/inc/api/v1/search-form.php index 27b7e82f..ed25d42f 100644 --- a/inc/api/v1/search-form.php +++ b/inc/api/v1/search-form.php @@ -56,16 +56,87 @@ class Opalestate_Search_Form_Api extends Opalestate_Base_API { public function get_fields( $request ) { $response = []; - $fields = []; + $fields = []; + $fields['min_price'] = [ + 'enable' => opalestate_is_enable_price_field(), + 'default' => opalestate_options( 'search_min_price', 0 ), + ]; - $fields['types'] = Opalestate_Taxonomy_Type::get_list(); - $fields['status'] = Opalestate_Taxonomy_Status::get_list(); - $fields['cat'] = Opalestate_Taxonomy_Categories::get_list(); - $fields['amenities'] = Opalestate_Taxonomy_Amenities::get_list(); - $fields['location'] = Opalestate_Taxonomy_Location::get_list(); - $fields['city'] = Opalestate_Taxonomy_City::get_list(); - $fields['state'] = Opalestate_Taxonomy_State::get_list(); - $response['fields'] = $fields; + $fields['max_price'] = [ + 'enable' => opalestate_is_enable_price_field(), + 'default' => opalestate_options( 'search_max_price', 10000000 ), + ]; + + $fields['min_area'] = [ + 'enable' => opalestate_is_enable_areasize_field(), + 'default' => opalestate_options( 'search_min_area', 0 ), + ]; + + $fields['max_area'] = [ + 'enable' => opalestate_is_enable_areasize_field(), + 'default' => opalestate_options( 'search_max_area', 1000 ), + ]; + + $fields['search_text'] = [ + 'default' => '', + ]; + + $fields['location_text'] = [ + 'default' => '', + ]; + + $fields['geo_long'] = [ + 'default' => '', + ]; + + $fields['geo_lat'] = [ + 'default' => '', + ]; + + $fields['types'] = [ + 'enable' => true, + 'default' => -1, + 'data' => Opalestate_Taxonomy_Type::get_list(), + ]; + + $fields['status'] = [ + 'enable' => true, + 'default' => -1, + 'data' => Opalestate_Taxonomy_Status::get_list(), + ]; + + $fields['cat'] = [ + 'enable' => true, + 'default' => -1, + 'data' => Opalestate_Taxonomy_Categories::get_list(), + ]; + + $fields['location'] = [ + 'enable' => true, + 'default' => -1, + 'data' => Opalestate_Taxonomy_Location::get_list(), + ]; + + $fields['city'] = [ + 'enable' => true, + 'default' => -1, + 'data' => Opalestate_Taxonomy_City::get_list(), + ]; + + $fields['state'] = [ + 'enable' => true, + 'default' => -1, + 'data' => Opalestate_Taxonomy_State::get_list(), + ]; + + $fields['amenities'] = [ + 'enable' => true, + 'default' => [], + 'data' => Opalestate_Taxonomy_Amenities::get_list(), + ]; + + $fields['info'] = OpalEstate_Search::get_setting_search_fields(); + $response['fields'] = $fields; return $this->get_response( 200, $response ); }