Update API

This commit is contained in:
Hoang Huu 2019-10-15 13:48:53 +07:00
parent bafb8ae380
commit 0f2d07c65c
4 changed files with 33 additions and 33 deletions

View File

@ -2,7 +2,7 @@
/** /**
* REST API Authentication * REST API Authentication
* *
* @package WooCommerce/API * @package Opalestate/API
* @since 2.6.0 * @since 2.6.0
*/ */
@ -578,7 +578,7 @@ class Opalestate_REST_Authentication {
*/ */
public function send_unauthorized_headers( $response ) { public function send_unauthorized_headers( $response ) {
if ( is_wp_error( $this->get_error() ) && 'basic_auth' === $this->auth_method ) { if ( is_wp_error( $this->get_error() ) && 'basic_auth' === $this->auth_method ) {
$auth_message = __( 'WooCommerce API. Use a consumer key in the username field and a consumer secret in the password field.', 'opalestate-pro' ); $auth_message = __( 'Opalestate API. Use a consumer key in the username field and a consumer secret in the password field.', 'opalestate-pro' );
$response->header( 'WWW-Authenticate', 'Basic realm="' . $auth_message . '"', true ); $response->header( 'WWW-Authenticate', 'Basic realm="' . $auth_message . '"', true );
} }

View File

@ -57,10 +57,10 @@ class Opalestate_Agency_Api extends Opalestate_Base_API {
'/' . $this->base, '/' . $this->base,
[ [
[ [
'methods' => WP_REST_Server::READABLE, 'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_items' ], 'callback' => [ $this, 'get_items' ],
// 'permission_callback' => [ $this, 'get_items_permissions_check' ], 'permission_callback' => [ $this, 'get_items_permissions_check' ],
'args' => $this->get_collection_params(), 'args' => $this->get_collection_params(),
], ],
] ]
); );
@ -76,9 +76,9 @@ class Opalestate_Agency_Api extends Opalestate_Base_API {
], ],
], ],
[ [
'methods' => WP_REST_Server::READABLE, 'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_item' ], 'callback' => [ $this, 'get_item' ],
// 'permission_callback' => [ $this, 'get_item_permissions_check' ], 'permission_callback' => [ $this, 'get_item_permissions_check' ],
], ],
// [ // [
// 'methods' => WP_REST_Server::EDITABLE, // 'methods' => WP_REST_Server::EDITABLE,
@ -99,9 +99,9 @@ class Opalestate_Agency_Api extends Opalestate_Base_API {
], ],
], ],
[ [
'methods' => WP_REST_Server::READABLE, 'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_listings' ], 'callback' => [ $this, 'get_listings' ],
// 'permission_callback' => [ $this, 'get_item_permissions_check' ], 'permission_callback' => [ $this, 'get_item_permissions_check' ],
], ],
] ]
); );

View File

@ -48,10 +48,10 @@ class Opalestate_Agent_Api extends Opalestate_Base_API {
'/' . $this->base, '/' . $this->base,
[ [
[ [
'methods' => WP_REST_Server::READABLE, 'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_items' ], 'callback' => [ $this, 'get_items' ],
// 'permission_callback' => [ $this, 'get_items_permissions_check' ], 'permission_callback' => [ $this, 'get_items_permissions_check' ],
'args' => $this->get_collection_params(), 'args' => $this->get_collection_params(),
], ],
] ]
); );
@ -67,9 +67,9 @@ class Opalestate_Agent_Api extends Opalestate_Base_API {
], ],
], ],
[ [
'methods' => WP_REST_Server::READABLE, 'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_item' ], 'callback' => [ $this, 'get_item' ],
// 'permission_callback' => [ $this, 'get_item_permissions_check' ], 'permission_callback' => [ $this, 'get_item_permissions_check' ],
], ],
// [ // [
// 'methods' => WP_REST_Server::EDITABLE, // 'methods' => WP_REST_Server::EDITABLE,
@ -90,9 +90,9 @@ class Opalestate_Agent_Api extends Opalestate_Base_API {
], ],
], ],
[ [
'methods' => WP_REST_Server::READABLE, 'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_listings' ], 'callback' => [ $this, 'get_listings' ],
// 'permission_callback' => [ $this, 'get_item_permissions_check' ], 'permission_callback' => [ $this, 'get_item_permissions_check' ],
], ],
] ]
); );

View File

@ -47,10 +47,10 @@ class Opalestate_Property_Api extends Opalestate_Base_API {
'/' . $this->base, '/' . $this->base,
[ [
[ [
'methods' => WP_REST_Server::READABLE, 'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_items' ], 'callback' => [ $this, 'get_items' ],
'permission_callback' => [ $this, 'get_items_permissions_check' ], 'permission_callback' => [ $this, 'get_items_permissions_check' ],
'args' => $this->get_collection_params(), 'args' => $this->get_collection_params(),
], ],
// [ // [
// 'methods' => WP_REST_Server::CREATABLE, // 'methods' => WP_REST_Server::CREATABLE,
@ -71,9 +71,9 @@ class Opalestate_Property_Api extends Opalestate_Base_API {
], ],
], ],
[ [
'methods' => WP_REST_Server::READABLE, 'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_item' ], 'callback' => [ $this, 'get_item' ],
// 'permission_callback' => [ $this, 'get_item_permissions_check' ], 'permission_callback' => [ $this, 'get_item_permissions_check' ],
], ],
// [ // [
// 'methods' => WP_REST_Server::EDITABLE, // 'methods' => WP_REST_Server::EDITABLE,
@ -100,10 +100,10 @@ class Opalestate_Property_Api extends Opalestate_Base_API {
'/' . $this->base . '/search', '/' . $this->base . '/search',
[ [
[ [
'methods' => WP_REST_Server::READABLE, 'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_results' ], 'callback' => [ $this, 'get_results' ],
// 'permission_callback' => [ $this, 'get_items_permissions_check' ], 'permission_callback' => [ $this, 'get_items_permissions_check' ],
'args' => $this->get_search_params(), 'args' => $this->get_search_params(),
], ],
] ]
); );
@ -191,7 +191,7 @@ class Opalestate_Property_Api extends Opalestate_Base_API {
} }
public function get_results( $request ) { public function get_results( $request ) {
$properties = []; $properties = [];
$property_list = $this->get_search_results_query( $request ); $property_list = $this->get_search_results_query( $request );
if ( $property_list ) { if ( $property_list ) {