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 | class Companies extends Resource |
||
| 6 | { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Create a company |
||
| 10 | * @param array $properties Array of company properties. |
||
| 11 | * |
||
| 12 | * @see http://developers.hubspot.com/docs/methods/companies/create_company |
||
| 13 | * |
||
| 14 | * @return \SevenShores\Hubspot\Http\Response |
||
| 15 | */ |
||
| 16 | function create($properties) |
||
|
0 ignored issues
–
show
|
|||
| 17 | { |
||
| 18 | $endpoint = 'https://api.hubapi.com/companies/v2/companies/'; |
||
| 19 | $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...
|
|||
| 20 | |||
| 21 | return $this->client->request('post', $endpoint, $options); |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Updates a company |
||
| 26 | * @param int $id The company id. |
||
| 27 | * @param array $properties The company properties to update. |
||
| 28 | * |
||
| 29 | * @see http://developers.hubspot.com/docs/methods/companies/update_company |
||
| 30 | * |
||
| 31 | * @return \SevenShores\Hubspot\Http\Response |
||
| 32 | */ |
||
| 33 | function update($id, $properties) |
||
|
0 ignored issues
–
show
|
|||
| 34 | { |
||
| 35 | $endpoint = "https://api.hubapi.com/companies/v2/companies/{$id}"; |
||
| 36 | $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...
|
|||
| 37 | |||
| 38 | return $this->client->request('put', $endpoint, $options); |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @param array $companies The companies and properties. |
||
| 43 | * @return \SevenShores\Hubspot\Http\Response |
||
| 44 | */ |
||
| 45 | function updateBatch($companies) |
||
|
0 ignored issues
–
show
|
|||
| 46 | { |
||
| 47 | $endpoint = "https://api.hubapi.com/companies/v1/batch-async/update"; |
||
| 48 | $options['json'] = $companies; |
||
| 49 | |||
| 50 | return $this->client->request('post', $endpoint, $options); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Deletes a company |
||
| 55 | * @param int $id The company id |
||
| 56 | * |
||
| 57 | * @see http://developers.hubspot.com/docs/methods/companies/delete_company |
||
| 58 | * |
||
| 59 | * @return \SevenShores\Hubspot\Http\Response |
||
| 60 | */ |
||
| 61 | function delete($id) |
||
|
0 ignored issues
–
show
|
|||
| 62 | { |
||
| 63 | $endpoint = "https://api.hubapi.com/companies/v2/companies/{$id}"; |
||
| 64 | |||
| 65 | return $this->client->request('delete', $endpoint); |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Returns all companies |
||
| 70 | * @param array $params Array of optional parameters ['limit', 'offset', 'properties'] |
||
| 71 | * |
||
| 72 | * @see http://developers.hubspot.com/docs/methods/companies/get-all-companies |
||
| 73 | * |
||
| 74 | * @return \SevenShores\Hubspot\Http\Response |
||
| 75 | */ |
||
| 76 | function all($params = []) |
||
|
0 ignored issues
–
show
|
|||
| 77 | { |
||
| 78 | $endpoint = 'https://api.hubapi.com/companies/v2/companies/paged'; |
||
| 79 | |||
| 80 | $queryString = build_query_string($params); |
||
| 81 | |||
| 82 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Returns the recently modified companies |
||
| 87 | * @param array $params Array of optional parameters ['count', 'offset'] |
||
| 88 | * |
||
| 89 | * @see http://developers.hubspot.com/docs/methods/companies/get_companies_modified |
||
| 90 | * |
||
| 91 | * @return \SevenShores\Hubspot\Http\Response |
||
| 92 | */ |
||
| 93 | function getRecentlyModified($params = []) |
||
|
0 ignored issues
–
show
|
|||
| 94 | { |
||
| 95 | $endpoint = 'https://api.hubapi.com/companies/v2/companies/recent/modified'; |
||
| 96 | |||
| 97 | $queryString = build_query_string($params); |
||
| 98 | |||
| 99 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 100 | } |
||
| 101 | |||
| 102 | /** |
||
| 103 | * Returns the recently created companies |
||
| 104 | * @param array $params Array of optional parameters ['count', 'offset'] |
||
| 105 | * |
||
| 106 | * @see http://developers.hubspot.com/docs/methods/companies/get_companies_created |
||
| 107 | * |
||
| 108 | * @return \SevenShores\Hubspot\Http\Response |
||
| 109 | */ |
||
| 110 | function getRecentlyCreated($params = []) |
||
|
0 ignored issues
–
show
|
|||
| 111 | { |
||
| 112 | $endpoint = 'https://api.hubapi.com/companies/v2/companies/recent/created'; |
||
| 113 | |||
| 114 | $queryString = build_query_string($params); |
||
| 115 | |||
| 116 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 117 | } |
||
| 118 | |||
| 119 | /** |
||
| 120 | * Returns an array of companies that have a matching domain |
||
| 121 | * @deprecated use searchByDomain instead |
||
| 122 | * @param string $domain The domain of the company eq. 'example.com'. |
||
| 123 | * |
||
| 124 | * @see http://developers.hubspot.com/docs/methods/companies/get_companies_by_domain |
||
| 125 | * |
||
| 126 | * @return \SevenShores\Hubspot\Http\Response |
||
| 127 | */ |
||
| 128 | function getByDomain($domain) |
||
|
0 ignored issues
–
show
|
|||
| 129 | { |
||
| 130 | $endpoint = "https://api.hubapi.com/companies/v2/companies/domain/{$domain}"; |
||
| 131 | |||
| 132 | return $this->client->request('get', $endpoint); |
||
| 133 | } |
||
| 134 | |||
| 135 | /** |
||
| 136 | * @param string $domain |
||
| 137 | * @param array $properties |
||
| 138 | * @param int $limit |
||
| 139 | * @param int $offset |
||
| 140 | * |
||
| 141 | * @see https://developers.hubspot.com/docs/methods/companies/search_companies_by_domain |
||
| 142 | * |
||
| 143 | * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response |
||
| 144 | */ |
||
| 145 | public function searchByDomain($domain, $properties = [], $limit = 100, $offset = 0) |
||
| 146 | { |
||
| 147 | $endpoint = "https://api.hubapi.com/companies/v2/domains/{$domain}/companies"; |
||
| 148 | $options['json'] = [ |
||
|
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...
|
|||
| 149 | 'limit' => $limit, |
||
| 150 | 'offset' => [ |
||
| 151 | 'isPrimary' => true, |
||
| 152 | 'companyId' => $offset |
||
| 153 | ], |
||
| 154 | 'requestOptions' => [ |
||
| 155 | 'properties' => $properties |
||
| 156 | ] |
||
| 157 | ]; |
||
| 158 | return $this->client->request('post', $endpoint, $options); |
||
| 159 | } |
||
| 160 | |||
| 161 | /** |
||
| 162 | * Returns a company with id $id |
||
| 163 | * @param int $id |
||
| 164 | * |
||
| 165 | * @see http://developers.hubspot.com/docs/methods/companies/get_company |
||
| 166 | * |
||
| 167 | * @return \SevenShores\Hubspot\Http\Response |
||
| 168 | */ |
||
| 169 | function getById($id) |
||
|
0 ignored issues
–
show
|
|||
| 170 | { |
||
| 171 | $endpoint = "https://api.hubapi.com/companies/v2/companies/{$id}"; |
||
| 172 | |||
| 173 | return $this->client->request('get', $endpoint); |
||
| 174 | } |
||
| 175 | |||
| 176 | /** |
||
| 177 | * Associates a given contact to a given company |
||
| 178 | * If a contact is already associated to a different company, the contact will be added to the new company |
||
| 179 | * @param int $contactId |
||
| 180 | * @param int $companyId |
||
| 181 | * |
||
| 182 | * @see http://developers.hubspot.com/docs/methods/companies/add_contact_to_company |
||
| 183 | * |
||
| 184 | * @return \SevenShores\Hubspot\Http\Response |
||
| 185 | */ |
||
| 186 | function addContact($contactId, $companyId) |
||
|
0 ignored issues
–
show
|
|||
| 187 | { |
||
| 188 | $endpoint = "https://api.hubapi.com/companies/v2/companies/{$companyId}/contacts/{$contactId}"; |
||
| 189 | |||
| 190 | return $this->client->request('put', $endpoint); |
||
| 191 | } |
||
| 192 | |||
| 193 | /** |
||
| 194 | * Returns an array of the associated contacts for the given company |
||
| 195 | * @param int $companyId The id of the company. |
||
| 196 | * @param array $params Array of optional parameters ['count', 'vidOffset'] |
||
| 197 | * |
||
| 198 | * @see http://developers.hubspot.com/docs/methods/companies/get_company_contacts |
||
| 199 | * |
||
| 200 | * @return \SevenShores\Hubspot\Http\Response |
||
| 201 | */ |
||
| 202 | function getAssociatedContacts($companyId, $params = []) |
||
|
0 ignored issues
–
show
|
|||
| 203 | { |
||
| 204 | $endpoint = "https://api.hubapi.com/companies/v2/companies/{$companyId}/contacts"; |
||
| 205 | |||
| 206 | $queryString = build_query_string($params); |
||
| 207 | |||
| 208 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 209 | } |
||
| 210 | |||
| 211 | /** |
||
| 212 | * Returns all of the contact IDs who are associated with the given company |
||
| 213 | * @param int $companyId The id of the company. |
||
| 214 | * @param array $params Array of optional parameters ['count', 'vidOffset'] |
||
| 215 | * |
||
| 216 | * @see http://developers.hubspot.com/docs/methods/companies/get_company_contacts_by_id |
||
| 217 | * |
||
| 218 | * @return \SevenShores\Hubspot\Http\Response |
||
| 219 | */ |
||
| 220 | function getAssociatedContactIds($companyId, $params = []) |
||
|
0 ignored issues
–
show
|
|||
| 221 | { |
||
| 222 | $endpoint = "https://api.hubapi.com/companies/v2/companies/{$companyId}/vids"; |
||
| 223 | |||
| 224 | $queryString = build_query_string($params); |
||
| 225 | |||
| 226 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 227 | } |
||
| 228 | |||
| 229 | /** |
||
| 230 | * Removes a contact from a company |
||
| 231 | * @param int $contactId |
||
| 232 | * @param int $companyId |
||
| 233 | * |
||
| 234 | * @see http://developers.hubspot.com/docs/methods/companies/remove_contact_from_company |
||
| 235 | * |
||
| 236 | * @return \SevenShores\Hubspot\Http\Response |
||
| 237 | */ |
||
| 238 | function removeContact($contactId, $companyId) |
||
|
0 ignored issues
–
show
|
|||
| 239 | { |
||
| 240 | $endpoint = "https://api.hubapi.com/companies/v2/companies/{$companyId}/contacts/{$contactId}"; |
||
| 241 | |||
| 242 | return $this->client->request('delete', $endpoint); |
||
| 243 | } |
||
| 244 | |||
| 245 | |||
| 246 | |||
| 247 | } |
||
| 248 |
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.