use DELETE instead of POST for delete action
This commit is contained in:
@@ -22,8 +22,8 @@ class Wiaas_REST_Customer_API {
|
|||||||
'permission_callback' => 'is_user_logged_in'
|
'permission_callback' => 'is_user_logged_in'
|
||||||
) );
|
) );
|
||||||
|
|
||||||
register_rest_route( self::$namespace, 'customer/(?P<id>\d+)/profile-addresses', array(
|
register_rest_route( self::$namespace, 'customer/(?P<id>\d+)/profile-addresses/(?P<address_id>\d+)', array(
|
||||||
'methods' => 'POST',
|
'methods' => 'DELETE',
|
||||||
'callback' => array(__CLASS__, 'delete_customer_profile_address'),
|
'callback' => array(__CLASS__, 'delete_customer_profile_address'),
|
||||||
'permission_callback' => 'is_user_logged_in'
|
'permission_callback' => 'is_user_logged_in'
|
||||||
) );
|
) );
|
||||||
@@ -34,8 +34,8 @@ class Wiaas_REST_Customer_API {
|
|||||||
'permission_callback' => 'is_user_logged_in'
|
'permission_callback' => 'is_user_logged_in'
|
||||||
) );
|
) );
|
||||||
|
|
||||||
register_rest_route( self::$namespace, 'customer/(?P<id>\d+)/billing-addresses', array(
|
register_rest_route( self::$namespace, 'customer/(?P<id>\d+)/billing-addresses/(?P<address_id>\d+)', array(
|
||||||
'methods' => 'POST',
|
'methods' => 'DELETE',
|
||||||
'callback' => array(__CLASS__, 'delete_customer_billing_addresses'),
|
'callback' => array(__CLASS__, 'delete_customer_billing_addresses'),
|
||||||
'permission_callback' => 'is_user_logged_in'
|
'permission_callback' => 'is_user_logged_in'
|
||||||
) );
|
) );
|
||||||
@@ -70,8 +70,7 @@ class Wiaas_REST_Customer_API {
|
|||||||
|
|
||||||
public static function delete_customer_profile_address(WP_REST_Request $request){
|
public static function delete_customer_profile_address(WP_REST_Request $request){
|
||||||
$customer_id = $request['id'];
|
$customer_id = $request['id'];
|
||||||
$params = $request->get_body_params();
|
$address_id = $request['address_id'];
|
||||||
$address_id = $params['address_id'];
|
|
||||||
|
|
||||||
if (!Wiaas_Customer::delete_customer_profile_address($customer_id, $address_id)){
|
if (!Wiaas_Customer::delete_customer_profile_address($customer_id, $address_id)){
|
||||||
return self::generate_wiaas_response('ADDRESS_ERROR', 'error', Wiaas_Customer::get_customer_info($customer_id));
|
return self::generate_wiaas_response('ADDRESS_ERROR', 'error', Wiaas_Customer::get_customer_info($customer_id));
|
||||||
@@ -95,8 +94,7 @@ class Wiaas_REST_Customer_API {
|
|||||||
|
|
||||||
public static function delete_customer_billing_addresses(WP_REST_Request $request){
|
public static function delete_customer_billing_addresses(WP_REST_Request $request){
|
||||||
$customer_id = $request['id'];
|
$customer_id = $request['id'];
|
||||||
$params = $request->get_body_params();
|
$address_id = $request['address_id'];
|
||||||
$address_id = json_decode($params['address_id']);
|
|
||||||
|
|
||||||
if (!Wiaas_Customer::delete_customer_billing_address($customer_id, $address_id)){
|
if (!Wiaas_Customer::delete_customer_billing_address($customer_id, $address_id)){
|
||||||
return self::generate_wiaas_response('ADDRESS_ERROR', 'error', Wiaas_Customer::get_customer_info($customer_id));
|
return self::generate_wiaas_response('ADDRESS_ERROR', 'error', Wiaas_Customer::get_customer_info($customer_id));
|
||||||
|
|||||||
@@ -52,11 +52,8 @@ export const removeProfileAddress = (idUser, idProfileAddress) => {
|
|||||||
return dispatch => {
|
return dispatch => {
|
||||||
dispatch(requestRemoveAddress());
|
dispatch(requestRemoveAddress());
|
||||||
return client.fetch({
|
return client.fetch({
|
||||||
url: `${API_SERVER}/wp-json/wiaas/customer/${idUser}/profile-addresses`,
|
url: `${API_SERVER}/wp-json/wiaas/customer/${idUser}/profile-addresses/${idProfileAddress}`,
|
||||||
method: 'post',
|
method: 'delete'
|
||||||
data: {
|
|
||||||
'address_id':idProfileAddress
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if(response.data){
|
if(response.data){
|
||||||
@@ -105,11 +102,8 @@ export const removeBillingAddress = (idUser, idBillingAddress) => {
|
|||||||
return dispatch => {
|
return dispatch => {
|
||||||
dispatch(requestRemoveBillingAddress());
|
dispatch(requestRemoveBillingAddress());
|
||||||
return client.fetch({
|
return client.fetch({
|
||||||
url: `${API_SERVER}/wp-json/wiaas/customer/${idUser}/billing-addresses`,
|
url: `${API_SERVER}/wp-json/wiaas/customer/${idUser}/billing-addresses/${idBillingAddress}`,
|
||||||
method: 'POST',
|
method: 'delete'
|
||||||
data: {
|
|
||||||
'address_id':idBillingAddress
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if(response.data){
|
if(response.data){
|
||||||
|
|||||||
Reference in New Issue
Block a user