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 | namespace SevenShores\Hubspot\Resources; |
||
| 3 | |||
| 4 | use SevenShores\Hubspot\Exceptions\HubspotException; |
||
| 5 | |||
| 6 | class Deals extends Resource |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * @param array $deal Array of deal properties. |
||
| 10 | * @return mixed |
||
| 11 | * @throws HubSpotException |
||
| 12 | */ |
||
| 13 | function create(array $deal) |
||
|
0 ignored issues
–
show
|
|||
| 14 | { |
||
| 15 | $endpoint = "https://api.hubapi.com/deals/v1/deal"; |
||
| 16 | |||
| 17 | $options['json'] = $deal; |
||
|
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...
|
|||
| 18 | |||
| 19 | return $this->client->request('post', $endpoint, $options); |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param int $id The deal id. |
||
| 24 | * @param array $deal The deal properties to update. |
||
| 25 | * @return mixed |
||
| 26 | */ |
||
| 27 | View Code Duplication | function update($id, array $deal) |
|
|
0 ignored issues
–
show
|
|||
| 28 | { |
||
| 29 | $endpoint = "https://api.hubapi.com/deals/v1/deal/{$id}"; |
||
| 30 | |||
| 31 | $options['json'] = $deal; |
||
|
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...
|
|||
| 32 | |||
| 33 | return $this->client->request('put', $endpoint, $options); |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Update a group of existing deal records by their dealId. |
||
| 38 | * |
||
| 39 | * @see https://developers.hubspot.com/docs/methods/deals/batch-update-deals |
||
| 40 | * |
||
| 41 | * @param array $deals The deals and properties. |
||
| 42 | * @return \SevenShores\Hubspot\Http\Response |
||
| 43 | */ |
||
| 44 | function updateBatch(array $deals) |
||
|
0 ignored issues
–
show
|
|||
| 45 | { |
||
| 46 | $endpoint = "https://api.hubapi.com/deals/v1/batch-async/update"; |
||
| 47 | |||
| 48 | $options['json'] = $deals; |
||
|
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...
|
|||
| 49 | |||
| 50 | return $this->client->request('post', $endpoint, $options); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @param array $params |
||
| 55 | * |
||
| 56 | * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response |
||
| 57 | * @throws \SevenShores\Hubspot\Exceptions\BadRequest |
||
| 58 | */ |
||
| 59 | function getAll(array $params = []){ |
||
|
0 ignored issues
–
show
|
|||
| 60 | $endpoint = "https://api.hubapi.com/deals/v1/deal/paged"; |
||
| 61 | |||
| 62 | $queryString = build_query_string($params); |
||
| 63 | |||
| 64 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 65 | } |
||
| 66 | |||
| 67 | |||
| 68 | /** |
||
| 69 | * @param int $id |
||
| 70 | * @return mixed |
||
| 71 | */ |
||
| 72 | function delete($id) |
||
|
0 ignored issues
–
show
|
|||
| 73 | { |
||
| 74 | $endpoint = "https://api.hubapi.com/deals/v1/deal/{$id}"; |
||
| 75 | |||
| 76 | return $this->client->request('delete', $endpoint); |
||
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @param array $params Optional parameters ['limit', 'offset'] |
||
| 81 | * @return mixed |
||
| 82 | */ |
||
| 83 | function getRecentlyModified(array $params = []) |
||
|
0 ignored issues
–
show
|
|||
| 84 | { |
||
| 85 | $endpoint = "https://api.hubapi.com/deals/v1/deal/recent/modified"; |
||
| 86 | $queryString = build_query_string($params); |
||
| 87 | |||
| 88 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 89 | } |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @param array $params Optional parameters ['limit', 'offset'] |
||
| 93 | * @return mixed |
||
| 94 | */ |
||
| 95 | function getRecentlyCreated(array $params = []) |
||
|
0 ignored issues
–
show
|
|||
| 96 | { |
||
| 97 | $endpoint = "https://api.hubapi.com/deals/v1/deal/recent/created"; |
||
| 98 | $queryString = build_query_string($params); |
||
| 99 | |||
| 100 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 101 | } |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @param int $id |
||
| 105 | * @return mixed |
||
| 106 | */ |
||
| 107 | function getById($id) |
||
|
0 ignored issues
–
show
|
|||
| 108 | { |
||
| 109 | $endpoint = "https://api.hubapi.com/deals/v1/deal/{$id}"; |
||
| 110 | |||
| 111 | return $this->client->request('get', $endpoint); |
||
| 112 | } |
||
| 113 | |||
| 114 | /** |
||
| 115 | * @param int $dealId |
||
| 116 | * @param int|int[] $companyIds |
||
| 117 | * @return mixed |
||
| 118 | */ |
||
| 119 | function associateWithCompany($dealId, $companyIds) |
||
|
0 ignored issues
–
show
|
|||
| 120 | { |
||
| 121 | $endpoint = "https://api.hubapi.com/deals/v1/deal/{$dealId}/associations/COMPANY"; |
||
| 122 | |||
| 123 | $queryString = build_query_string(['id' => (array)$companyIds]); |
||
| 124 | |||
| 125 | return $this->client->request('put', $endpoint, [], $queryString); |
||
| 126 | } |
||
| 127 | |||
| 128 | /** |
||
| 129 | * @param int $dealId |
||
| 130 | * @param int|int[] $companyIds |
||
| 131 | * @return mixed |
||
| 132 | */ |
||
| 133 | function disassociateFromCompany($dealId, $companyIds) |
||
|
0 ignored issues
–
show
|
|||
| 134 | { |
||
| 135 | $endpoint = "https://api.hubapi.com/deals/v1/deal/{$dealId}/associations/COMPANY"; |
||
| 136 | |||
| 137 | $queryString = build_query_string(['id' => (array)$companyIds]); |
||
| 138 | |||
| 139 | return $this->client->request('delete', $endpoint, [], $queryString); |
||
| 140 | } |
||
| 141 | |||
| 142 | /** |
||
| 143 | * @param int $dealId |
||
| 144 | * @param int|int[] $contactIds |
||
| 145 | * @return mixed |
||
| 146 | */ |
||
| 147 | function associateWithContact($dealId, $contactIds) |
||
|
0 ignored issues
–
show
|
|||
| 148 | { |
||
| 149 | $endpoint = "https://api.hubapi.com/deals/v1/deal/{$dealId}/associations/CONTACT"; |
||
| 150 | |||
| 151 | $queryString = build_query_string(['id' => (array)$contactIds]); |
||
| 152 | |||
| 153 | return $this->client->request('put', $endpoint, [], $queryString); |
||
| 154 | } |
||
| 155 | |||
| 156 | /** |
||
| 157 | * @param int $contactId |
||
| 158 | * @param array $params Optional parameters ['limit', 'offset'] |
||
| 159 | * @return mixed |
||
| 160 | */ |
||
| 161 | function associatedWithContact($contactId, $params = []) |
||
|
0 ignored issues
–
show
|
|||
| 162 | { |
||
| 163 | $endpoint = "https://api.hubapi.com/deals/v1/deal/associated/contact/{$contactId}/paged"; |
||
| 164 | |||
| 165 | $queryString = build_query_string($params); |
||
| 166 | |||
| 167 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 168 | } |
||
| 169 | |||
| 170 | /** |
||
| 171 | * @param int $dealId |
||
| 172 | * @param int|int[] $contactIds |
||
| 173 | * @return mixed |
||
| 174 | */ |
||
| 175 | function disassociateFromContact($dealId, $contactIds) |
||
|
0 ignored issues
–
show
|
|||
| 176 | { |
||
| 177 | $endpoint = "https://api.hubapi.com/deals/v1/deal/{$dealId}/associations/CONTACT"; |
||
| 178 | |||
| 179 | $queryString = build_query_string(['id' => (array)$contactIds]); |
||
| 180 | |||
| 181 | return $this->client->request('delete', $endpoint, [], $queryString); |
||
| 182 | } |
||
| 183 | |||
| 184 | /** |
||
| 185 | * @param string $objectType |
||
| 186 | * @param int $objectId |
||
| 187 | * @param array $params |
||
| 188 | * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response |
||
| 189 | * |
||
| 190 | * @see https://developers.hubspot.com/docs/methods/deals/get-associated-deals |
||
| 191 | */ |
||
| 192 | public function getAssociatedDeals($objectType, $objectId, $params = []) |
||
| 193 | { |
||
| 194 | $endpoint = "https://api.hubapi.com/deals/v1/deal/associated/{$objectType}/{$objectId}/paged"; |
||
| 195 | |||
| 196 | $queryString = build_query_string($params); |
||
| 197 | |||
| 198 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 199 | } |
||
| 200 | } |
||
| 201 |
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.