Jump to content

Too few arguments to function Clients::delete()


Martí B

Recommended Posts

Hi, I've been trying to make an api call in php to delete a client using its client id, but it's not working even though I've checked as many resources available as possible.

The PHP code I'm using is:

$query=$email;
$response = $api->get("clients", "search", array('query'=>$query));
$client = $response->response();
$response_decoded = $response->response();
echo "\n".json_encode($response_decoded);
$client = $client[0];
$user_id = intval($client->id_value);

echo "<br>Client ID: $user_id"; //outputs "4983" (client id of the client account I'm using for testing)

$response = $api->delete("clients", "delete", array($user_id));
print_r($api);
$response_decoded = $response->response();
echo json_encode($response_decoded);


And it's returning the following error:

"Too few arguments to function Clients::delete(), 0 passed in \/path\/to\/blesta\/installation\/app\/controllers\/api.php on line 154 and exactly 1 expected


However, print_r($api) prints:

BlestaApi Object
(
    [url:BlestaApi:private] => api_url
    [user:BlestaApi:private] => api_user
    [key:BlestaApi:private] => api_key
    [last_request] => Array
        (
            [url] => https://path/to_blesta/api/clients/delete.json
            [args] => Array
                (
                    [0] => 4983
                )

        )

)

So it seems that there is indeed an argument passed.

 

The API Docs, in Clients Class, say:

Quote

delete( integer $client_id )

Permanently removes a client from the clients table. CAUTION: Deleting a client will cause all invoices, services, transactions, etc. attached to that client to become inaccessible.

Parameters

$client_id

The client ID to permanently remove from the system

 

I've tried passing the $user_id (client id) without using an array, but another error suggests to use an array.

What am I doing wrong? I've used the api for other cases and following the API docs all worked fine.

Link to comment
Share on other sites

Deleting a client within the interface also removes any/all data associated with that customer. Transactions, services, etc. Only clients with no active services or open invoices can be deleted via the UI. If you simply delete the client, you may be leaving orphaned data. I would recommend digging deeper into how the delete client code works, it's possible you need to perform some other steps also.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...