pipedrive / client-php

Pipedrive API client for PHP
MIT License
49 stars 57 forks source link

updateAPerson without email address or phone fails #23

Closed digilist closed 3 years ago

digilist commented 4 years ago
$client->getPersons()->updateAPerson([
    'id' => 123,
    'name' => 'John Doe',
]);

results in

Warning: array_values() expects parameter 1 to be array, null given  

Exception trace:
  at vendor/pipedrive/pipedrive/src/Controllers/PersonsController.php:445

(or line 446 for phone) coming from this code:

        $_parameters = array (
            'name'       => $this->val($options, 'name'),
            'owner_id'   => $this->val($options, 'ownerId'),
            'org_id'     => $this->val($options, 'orgId'),
            'email'    => array_values($this->val($options, 'email')),
            'phone'    => array_values($this->val($options, 'phone')),
            'visible_to' => APIHelper::prepareFormFields($this->val($options, 'visibleTo'))
        );

array_values() is called with null if no email or phone is provided (which are optional)

ziimk commented 3 years ago

The changes implemented in https://github.com/pipedrive/client-php/pull/48 should fix the issues with updating optional and custom fields in deals, persons and organizations endpoints. Feel free to try it out before release