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