ryanwinchester /
hubspot-php
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SevenShores\Hubspot\Resources; |
||
| 4 | |||
| 5 | |||
| 6 | class Contacts extends Resource |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * @param array $properties Array of contact properties. |
||
| 10 | * @return \SevenShores\Hubspot\Http\Response |
||
| 11 | */ |
||
| 12 | function create($properties) |
||
|
0 ignored issues
–
show
|
|||
| 13 | { |
||
| 14 | $endpoint = "https://api.hubapi.com/contacts/v1/contact"; |
||
| 15 | |||
| 16 | $options['json'] = ['properties' => $properties]; |
||
| 17 | |||
| 18 | return $this->client->request('post', $endpoint, $options); |
||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param int $id The contact id. |
||
| 23 | * @param array $properties The contact properties to update. |
||
| 24 | * @return \SevenShores\Hubspot\Http\Response |
||
| 25 | */ |
||
| 26 | function update($id, $properties) |
||
|
0 ignored issues
–
show
|
|||
| 27 | { |
||
| 28 | $endpoint = "https://api.hubapi.com/contacts/v1/contact/vid/{$id}/profile"; |
||
| 29 | |||
| 30 | $options['json'] = ['properties' => $properties]; |
||
| 31 | |||
| 32 | return $this->client->request('post', $endpoint, $options); |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param string $email The contact's email address. |
||
| 37 | * @param array $properties The contact properties to update. |
||
| 38 | * @return \SevenShores\Hubspot\Http\Response |
||
| 39 | */ |
||
| 40 | function updateByEmail($email, $properties) |
||
|
0 ignored issues
–
show
|
|||
| 41 | { |
||
| 42 | $endpoint = "https://api.hubapi.com/contacts/v1/contact/email/{$email}/profile"; |
||
| 43 | |||
| 44 | $options['json'] = ['properties' => $properties]; |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$options was never initialized. Although not strictly required by PHP, it is generally a good practice to add $options = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. Loading history...
|
|||
| 45 | |||
| 46 | return $this->client->request('post', $endpoint, $options); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @param string $email The contact's email address. |
||
| 51 | * @param array $properties The contact properties. |
||
| 52 | * @return \SevenShores\Hubspot\Http\Response |
||
| 53 | */ |
||
| 54 | function createOrUpdate($email, $properties = []) |
||
|
0 ignored issues
–
show
|
|||
| 55 | { |
||
| 56 | $endpoint = "https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/{$email}"; |
||
| 57 | |||
| 58 | $options['json'] = ['properties' => $properties]; |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$options was never initialized. Although not strictly required by PHP, it is generally a good practice to add $options = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. Loading history...
|
|||
| 59 | |||
| 60 | return $this->client->request('post', $endpoint, $options); |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @param array $contacts The contacts and properties. |
||
| 65 | * @param array $params Array of optional parameters ['auditId'] |
||
| 66 | * @return \SevenShores\Hubspot\Http\Response |
||
| 67 | */ |
||
| 68 | function createOrUpdateBatch($contacts, $params = []) |
||
|
0 ignored issues
–
show
|
|||
| 69 | { |
||
| 70 | $endpoint = "https://api.hubapi.com/contacts/v1/contact/batch"; |
||
| 71 | |||
| 72 | $queryString = build_query_string($params); |
||
| 73 | |||
| 74 | $options['json'] = $contacts; |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$options was never initialized. Although not strictly required by PHP, it is generally a good practice to add $options = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. Loading history...
|
|||
| 75 | |||
| 76 | return $this->client->request('post', $endpoint, $options, $queryString); |
||
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @param int $id |
||
| 81 | * @return \SevenShores\Hubspot\Http\Response |
||
| 82 | */ |
||
| 83 | function delete($id) |
||
|
0 ignored issues
–
show
|
|||
| 84 | { |
||
| 85 | $endpoint = "https://api.hubapi.com/contacts/v1/contact/vid/{$id}"; |
||
| 86 | |||
| 87 | return $this->client->request('delete', $endpoint); |
||
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * For a given portal, return all contacts that have been created in the portal. |
||
| 92 | * |
||
| 93 | * A paginated list of contacts will be returned to you, with a maximum of 100 contacts per page. |
||
| 94 | * |
||
| 95 | * Please Note: There are 2 fields here to pay close attention to: the "has-more" field that will let you know |
||
| 96 | * whether there are more contacts that you can pull from this portal, and the "vid-offset" field which will let |
||
| 97 | * you know where you are in the list of contacts. You can then use the "vid-offset" field in the "vidOffset" |
||
| 98 | * parameter described below. |
||
| 99 | * |
||
| 100 | * @see http://developers.hubspot.com/docs/methods/contacts/get_contacts |
||
| 101 | * |
||
| 102 | * @param array $params Array of optional parameters ['count', 'property', 'vidOffset'] |
||
| 103 | * @return \SevenShores\Hubspot\Http\Response |
||
| 104 | */ |
||
| 105 | function all($params = []) |
||
|
0 ignored issues
–
show
|
|||
| 106 | { |
||
| 107 | $endpoint = "https://api.hubapi.com/contacts/v1/lists/all/contacts/all"; |
||
| 108 | |||
| 109 | $queryString = build_query_string($params); |
||
| 110 | |||
| 111 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 112 | } |
||
| 113 | |||
| 114 | /** |
||
| 115 | * For a given portal, return all contacts that have been recently updated or created. |
||
| 116 | * A paginated list of contacts will be returned to you, with a maximum of 100 contacts per page, as specified by |
||
| 117 | * the "count" parameter. The endpoint only scrolls back in time 30 days. |
||
| 118 | * |
||
| 119 | * @see http://developers.hubspot.com/docs/methods/contacts/get_recently_updated_contacts |
||
| 120 | * |
||
| 121 | * @param array $params Array of optional parameters ['count', 'timeOffset', 'vidOffset', 'property', |
||
| 122 | * 'propertyMode', 'formSubmissionMode', 'showListMemberships'] |
||
| 123 | * @return \SevenShores\Hubspot\Http\Response |
||
| 124 | */ |
||
| 125 | function recent($params = []) |
||
|
0 ignored issues
–
show
|
|||
| 126 | { |
||
| 127 | $endpoint = "https://api.hubapi.com/contacts/v1/lists/recently_updated/contacts/recent"; |
||
| 128 | |||
| 129 | $queryString = build_query_string($params); |
||
| 130 | |||
| 131 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 132 | } |
||
| 133 | |||
| 134 | /** |
||
| 135 | * For a given portal, return all contacts that have been recently created. |
||
| 136 | * A paginated list of contacts will be returned to you, with a maximum of 100 contacts per page, as specified by |
||
| 137 | * the "count" parameter. The endpoint only scrolls back in time 30 days. |
||
| 138 | * |
||
| 139 | * @see http://developers.hubspot.com/docs/methods/contacts/get_recently_updated_contacts |
||
| 140 | * |
||
| 141 | * @param array $params Array of optional parameters ['count', 'timeOffset', 'vidOffset', 'property', |
||
| 142 | * 'propertyMode', 'formSubmissionMode', 'showListMemberships'] |
||
| 143 | * @return \SevenShores\Hubspot\Http\Response |
||
| 144 | */ |
||
| 145 | function recentNew($params = []) |
||
|
0 ignored issues
–
show
|
|||
| 146 | { |
||
| 147 | $endpoint = "https://api.hubapi.com/contacts/v1/lists/all/contacts/recent"; |
||
| 148 | |||
| 149 | $queryString = build_query_string($params); |
||
| 150 | |||
| 151 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 152 | } |
||
| 153 | |||
| 154 | /** |
||
| 155 | * @param int $id |
||
| 156 | * @param array $params Array of optional parameters ['property', 'propertyMode', 'formSubmissionMode', |
||
| 157 | * 'showListMemberships'] |
||
| 158 | * @return \SevenShores\Hubspot\Http\Response |
||
| 159 | */ |
||
| 160 | function getById($id, $params = []) |
||
|
0 ignored issues
–
show
|
|||
| 161 | { |
||
| 162 | $endpoint = "https://api.hubapi.com/contacts/v1/contact/vid/{$id}/profile"; |
||
| 163 | |||
| 164 | $queryString = build_query_string($params); |
||
| 165 | |||
| 166 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 167 | } |
||
| 168 | |||
| 169 | /** |
||
| 170 | * For a given portal, return information about a group of contacts by their unique ID's. A contact's unique ID's |
||
| 171 | * is stored in a field called 'vid' which stands for 'visitor ID'. |
||
| 172 | * |
||
| 173 | * This method will also return you much of the HubSpot lead "intelligence" for each requested contact record. The |
||
| 174 | * endpoint accepts many query parameters that allow for customization based on a variety of integration use cases. |
||
| 175 | * |
||
| 176 | * @see http://developers.hubspot.com/docs/methods/contacts/get_batch_by_vid |
||
| 177 | * |
||
| 178 | * @param array $vids Array of visitor IDs |
||
| 179 | * @param array $params Array of optional parameters ['property', 'propertyMode', 'formSubmissionMode', |
||
| 180 | * 'showListMemberships', 'includeDeletes'] |
||
| 181 | * @return \SevenShores\Hubspot\Http\Response |
||
| 182 | */ |
||
| 183 | function getBatchByIds($vids, $params = []) |
||
|
0 ignored issues
–
show
|
|||
| 184 | { |
||
| 185 | $endpoint = "https://api.hubapi.com/contacts/v1/contact/vids/batch/"; |
||
| 186 | |||
| 187 | $params['vid'] = $vids; |
||
| 188 | |||
| 189 | $queryString = build_query_string($params); |
||
| 190 | |||
| 191 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 192 | } |
||
| 193 | |||
| 194 | /** |
||
| 195 | * @param string $email |
||
| 196 | * @param array $params Array of optional parameters ['property', 'propertyMode', 'formSubmissionMode', |
||
| 197 | * 'showListMemberships'] |
||
| 198 | * @return \SevenShores\Hubspot\Http\Response |
||
| 199 | */ |
||
| 200 | function getByEmail($email, $params = []) |
||
|
0 ignored issues
–
show
|
|||
| 201 | { |
||
| 202 | $endpoint = "https://api.hubapi.com/contacts/v1/contact/email/{$email}/profile"; |
||
| 203 | |||
| 204 | $queryString = build_query_string($params); |
||
| 205 | |||
| 206 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 207 | } |
||
| 208 | |||
| 209 | /** |
||
| 210 | * For a given portal, return information about a group of contacts by their email addresses. |
||
| 211 | * |
||
| 212 | * This method will also return you much of the HubSpot lead "intelligence" for each requested contact record. The |
||
| 213 | * endpoint accepts many query parameters that allow for customization based on a variety of integration use cases. |
||
| 214 | * |
||
| 215 | * @see http://developers.hubspot.com/docs/methods/contacts/get_batch_by_email |
||
| 216 | * |
||
| 217 | * @param array $emails Array of email adresses |
||
| 218 | * @param array $params Array of optional parameters ['property', 'propertyMode', 'formSubmissionMode', |
||
| 219 | * 'showListMemberships', 'includeDeletes'] |
||
| 220 | * @return \SevenShores\Hubspot\Http\Response |
||
| 221 | */ |
||
| 222 | function getBatchByEmails($emails, $params = []) |
||
|
0 ignored issues
–
show
|
|||
| 223 | { |
||
| 224 | $endpoint = "https://api.hubapi.com/contacts/v1/contact/emails/batch/"; |
||
| 225 | |||
| 226 | $params['email'] = $emails; |
||
| 227 | |||
| 228 | $queryString = build_query_string($params); |
||
| 229 | |||
| 230 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 231 | } |
||
| 232 | |||
| 233 | /** |
||
| 234 | * @param string $utk |
||
| 235 | * @param array $params Array of optional parameters ['property', 'propertyMode', 'formSubmissionMode', |
||
| 236 | * 'showListMemberships'] |
||
| 237 | * @return \SevenShores\Hubspot\Http\Response |
||
| 238 | */ |
||
| 239 | function getByToken($utk, $params = []) |
||
|
0 ignored issues
–
show
|
|||
| 240 | { |
||
| 241 | $endpoint = "https://api.hubapi.com/contacts/v1/contact/utk/{$utk}/profile"; |
||
| 242 | |||
| 243 | $queryString = build_query_string($params); |
||
| 244 | |||
| 245 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 246 | } |
||
| 247 | |||
| 248 | /** |
||
| 249 | * For a given portal, return information about a group of contacts by their user tokens (hubspotutk). |
||
| 250 | * |
||
| 251 | * This method will also return you much of the HubSpot lead "intelligence" for each requested contact |
||
| 252 | * record. The endpoint accepts many query parameters that allow for customization based on a variety of |
||
| 253 | * integration use cases. |
||
| 254 | * |
||
| 255 | * The endpoint does not allow for CORS, so if you are looking up contacts from their user token on the client, |
||
| 256 | * you'll need to spin up a proxy server to interact with the API. |
||
| 257 | * |
||
| 258 | * @see http://developers.hubspot.com/docs/methods/contacts/get_batch_by_utk |
||
| 259 | * |
||
| 260 | * @param array $utks Array of hubspot user tokens (hubspotutk) |
||
| 261 | * @param array $params Array of optional parameters ['property', 'propertyMode', 'formSubmissionMode', |
||
| 262 | * 'showListMemberships', 'includeDeletes'] |
||
| 263 | * @return \SevenShores\Hubspot\Http\Response |
||
| 264 | */ |
||
| 265 | function getBatchByTokens($utks, $params = []) |
||
|
0 ignored issues
–
show
|
|||
| 266 | { |
||
| 267 | $endpoint = "https://api.hubapi.com/contacts/v1/contact/utks/batch/"; |
||
| 268 | |||
| 269 | $params['utk'] = $utks; |
||
| 270 | |||
| 271 | $queryString = build_query_string($params); |
||
| 272 | |||
| 273 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 274 | } |
||
| 275 | |||
| 276 | /** |
||
| 277 | * For a given portal, return contacts and some data associated with |
||
| 278 | * those contacts by the contact's email address or name. |
||
| 279 | * |
||
| 280 | * Please note that you should expect this method to only return a small |
||
| 281 | * subset of data about the contact. One piece of data that the method will |
||
| 282 | * return is the contact ID (vid) that you can then use to look up much |
||
| 283 | * more data about that particular contact by its ID. |
||
| 284 | * |
||
| 285 | * @see http://developers.hubspot.com/docs/methods/contacts/search_contacts |
||
| 286 | * |
||
| 287 | * @param string $query Search query |
||
| 288 | * @param array $params Array of optional parameters ['count', 'offset'] |
||
| 289 | * @return \SevenShores\Hubspot\Http\Response |
||
| 290 | */ |
||
| 291 | function search($query, $params = []) |
||
|
0 ignored issues
–
show
|
|||
| 292 | { |
||
| 293 | $endpoint = "https://api.hubapi.com/contacts/v1/search/query"; |
||
| 294 | |||
| 295 | $params['q'] = $query; |
||
| 296 | |||
| 297 | $queryString = build_query_string($params); |
||
| 298 | |||
| 299 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 300 | } |
||
| 301 | |||
| 302 | /** |
||
| 303 | * @return \SevenShores\Hubspot\Http\Response |
||
| 304 | */ |
||
| 305 | function statistics() |
||
|
0 ignored issues
–
show
|
|||
| 306 | { |
||
| 307 | $endpoint = "https://api.hubapi.com/contacts/v1/contacts/statistics"; |
||
| 308 | |||
| 309 | return $this->client->request('get', $endpoint); |
||
| 310 | } |
||
| 311 | |||
| 312 | /** |
||
| 313 | * Merge two contact records. The contact ID in the URL will be treated as the |
||
| 314 | * primary contact, and the contact ID in the request body will be treated as |
||
| 315 | * the secondary contact. |
||
| 316 | * |
||
| 317 | * @param int $id Primary contact id. |
||
| 318 | * @param int $vidToMerge Contact ID of the secondary contact. |
||
| 319 | * @return \SevenShores\Hubspot\Http\Response |
||
| 320 | */ |
||
| 321 | function merge($id, $vidToMerge) |
||
|
0 ignored issues
–
show
|
|||
| 322 | { |
||
| 323 | $endpoint = "https://api.hubapi.com/contacts/v1/contact/merge-vids/{$id}/"; |
||
| 324 | |||
| 325 | $options['json'] = ['vidToMerge' => $vidToMerge]; |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$options was never initialized. Although not strictly required by PHP, it is generally a good practice to add $options = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. Loading history...
|
|||
| 326 | |||
| 327 | return $this->client->request('post', $endpoint, $options); |
||
| 328 | } |
||
| 329 | |||
| 330 | } |
||
| 331 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.