diff --git a/src/CRM.php b/src/CRM.php index 9a2af91..a4f5f2c 100644 --- a/src/CRM.php +++ b/src/CRM.php @@ -73,20 +73,20 @@ abstract class CRM const RES_TASK = 'Task'; const RES_PROJECT = 'Project'; const RES_ACTIVITY = 'Activity'; - + static $container; - + public static function client() { static $client; - + self::$container = []; $history = Middleware::history(self::$container); - + $stack = HandlerStack::create(); // Add the history middleware to the handler stack. $stack->push($history); - + if (!$client) { $client = new Client([ 'base_uri' => 'https://api.prosperworks.com/developer_api/v1/', @@ -163,6 +163,11 @@ public static function fieldList(string $resource, $search = null, bool $detaile $list = array_merge($list->user, $list->system); } + // API does not return single element array when only one object in the response. + // The code after this assumes array and this is not always the case. + // This definitely requires PHP7 + if(!is_array($list)) { $list = [$list]; } + $result = array_column($list, $detailed ? null : 'name', 'id'); if ($detailed && $resource == 'customFieldDefinition') {