HubSpot / hubspot-php

HubSpot PHP API Client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple properties for a ContactList not possible in PHP?

njt1982 opened this issue · comments

According to what I've seen with the support forums/FAQ (the documentation is not clear on this), multiple properties should be achieved by repeating the property querystring key. For example:

https://api.hubapi.com/contacts/v1/lists/all/contacts/all?property=x&property=y

How is this possible in PHP when the parameters are a keyed array and you can only set one key once?

/**
* Get contacts in a list.
*
* @param int $id List id
* @param array $params Optional parameters
* { count, vidOffset, property, propertyMode, formSubmissionMode, showListMemberships }
*
* @see https://developers.hubspot.com/docs/methods/lists/get_list_contacts
*
* @return \SevenShores\Hubspot\Http\Response
*/
public function contacts($id, array $params = [])
{
$endpoint = "https://api.hubapi.com/contacts/v1/lists/{$id}/contacts/all";
return $this->client->request(
'get',
$endpoint,
[],
build_query_string($params)
);
}

(ie, once $params['property'] = 'x' is set, if I then to $params['property'] = 'y'it will overwrite'x'`).

Ah!! you can just set property to be an array! 🤦🏻‍♂️

$contactList->contacts(1, ['property' => ['x', 'y']]);

False alarm 😉
(although https://legacydocs.hubspot.com/docs/methods/lists/get_list_contacts should be update to reflect this)