Skip to content
This repository was archived by the owner on Jun 1, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/CRM.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
Expand Down Expand Up @@ -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') {
Expand Down