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 ContactProperties extends Resource |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Get all Contact properties. |
||
| 9 | * |
||
| 10 | * Properties in HubSpot are fields that have been created, in this case for deals in a given portal. |
||
| 11 | * This endpoint will return all of the contacts properties, including their definition, for a given portal. |
||
| 12 | * |
||
| 13 | * @see http://developers.hubspot.com/docs/methods/contacts/v2/get_contacts_properties |
||
| 14 | * |
||
| 15 | * @return \SevenShores\Hubspot\Http\Response |
||
| 16 | */ |
||
| 17 | function all() |
||
|
0 ignored issues
–
show
|
|||
| 18 | { |
||
| 19 | $endpoint = 'https://api.hubapi.com/contacts/v2/properties'; |
||
| 20 | |||
| 21 | return $this->client->request('get', $endpoint); |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Get a Contact Property. |
||
| 26 | * |
||
| 27 | * Returns a JSON object representing the definition for a given contact property. |
||
| 28 | * |
||
| 29 | * @see http://developers.hubspot.com/docs/methods/companies/get_contact_property |
||
| 30 | * |
||
| 31 | * @param string $name The name of the property. |
||
| 32 | * @return \SevenShores\Hubspot\Http\Response |
||
| 33 | */ |
||
| 34 | function get($name) |
||
|
0 ignored issues
–
show
|
|||
| 35 | { |
||
| 36 | $endpoint = "https://api.hubapi.com/contacts/v2/properties/named/{$name}"; |
||
| 37 | |||
| 38 | return $this->client->request('get', $endpoint); |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Create a contact property. |
||
| 43 | * |
||
| 44 | * Create a property on every contact object to store a specific piece of data. In the example below, |
||
| 45 | * we want to store an invoice number on a separate field on deals. |
||
| 46 | * |
||
| 47 | * @see http://developers.hubspot.com/docs/methods/contacts/v2/create_contacts_property |
||
| 48 | * |
||
| 49 | * @param array $property |
||
| 50 | * @return \SevenShores\Hubspot\Http\Response |
||
| 51 | */ |
||
| 52 | function create($property) |
||
|
0 ignored issues
–
show
|
|||
| 53 | { |
||
| 54 | $endpoint = "https://api.hubapi.com/contacts/v2/properties"; |
||
| 55 | |||
| 56 | $options['json'] = $property; |
||
|
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...
|
|||
| 57 | |||
| 58 | return $this->client->request('post', $endpoint, $options); |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Update a contact property. |
||
| 63 | * |
||
| 64 | * Update a specified contact property. |
||
| 65 | * |
||
| 66 | * @see http://developers.hubspot.com/docs/methods/contacts/v2/update_contact_property |
||
| 67 | * |
||
| 68 | * @param string $name |
||
| 69 | * @param array $property |
||
| 70 | * @return \SevenShores\Hubspot\Http\Response |
||
| 71 | */ |
||
| 72 | function update($name, $property) |
||
|
0 ignored issues
–
show
|
|||
| 73 | { |
||
| 74 | $endpoint = "https://api.hubapi.com/contacts/v2/properties/named/{$name}"; |
||
| 75 | |||
| 76 | $property['name'] = $name; |
||
| 77 | $options['json'] = $property; |
||
| 78 | |||
| 79 | return $this->client->request('put', $endpoint, $options); |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Delete a contact property. |
||
| 84 | * |
||
| 85 | * For a portal, delete an existing contact property. |
||
| 86 | * |
||
| 87 | * @see http://developers.hubspot.com/docs/methods/contacts/v2/delete_contact_property |
||
| 88 | * |
||
| 89 | * @param string $name |
||
| 90 | * @return \SevenShores\Hubspot\Http\Response |
||
| 91 | */ |
||
| 92 | function delete($name) |
||
|
0 ignored issues
–
show
|
|||
| 93 | { |
||
| 94 | $endpoint = "https://api.hubapi.com/contacts/v2/properties/named/{$name}"; |
||
| 95 | |||
| 96 | return $this->client->request('delete', $endpoint); |
||
| 97 | } |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Get contact property groups. |
||
| 101 | * |
||
| 102 | * Returns all of the contact property groups for a given portal. |
||
| 103 | * |
||
| 104 | * @see http://developers.hubspot.com/docs/methods/contacts/v2/get_contact_property_groups |
||
| 105 | * |
||
| 106 | * @param bool $includeProperties |
||
| 107 | * @return \SevenShores\Hubspot\Http\Response |
||
| 108 | */ |
||
| 109 | function getGroups($includeProperties = false) |
||
|
0 ignored issues
–
show
|
|||
| 110 | { |
||
| 111 | $endpoint = "https://api.hubapi.com/contacts/v2/groups"; |
||
| 112 | |||
| 113 | $queryString = build_query_string(['includeProperties' => $includeProperties]); |
||
| 114 | |||
| 115 | return $this->client->request('get', $endpoint, [], $queryString); |
||
| 116 | } |
||
| 117 | |||
| 118 | /** |
||
| 119 | * Create a contact property group. |
||
| 120 | * |
||
| 121 | * Create a new contact property group to gather like contact-level data. Property groups allow you to more |
||
| 122 | * easily manage properties in a given portal and make contact records easier to parse for the user. |
||
| 123 | * |
||
| 124 | * @see http://developers.hubspot.com/docs/methods/contacts/v2/create_contacts_property_group |
||
| 125 | * |
||
| 126 | * @param array $group Group properties |
||
| 127 | * @return \SevenShores\Hubspot\Http\Response |
||
| 128 | */ |
||
| 129 | function createGroup($group) |
||
|
0 ignored issues
–
show
|
|||
| 130 | { |
||
| 131 | $endpoint = "https://api.hubapi.com/contacts/v2/groups"; |
||
| 132 | |||
| 133 | $options['json'] = $group; |
||
| 134 | |||
| 135 | return $this->client->request('post', $endpoint, $options); |
||
| 136 | } |
||
| 137 | |||
| 138 | /** |
||
| 139 | * Update a property group. |
||
| 140 | * |
||
| 141 | * Update a previously created contact property group. |
||
| 142 | * |
||
| 143 | * @see http://developers.hubspot.com/docs/methods/contacts/v2/update_contact_property_group |
||
| 144 | * |
||
| 145 | * @param string $name |
||
| 146 | * @param array $group |
||
| 147 | * @return \SevenShores\Hubspot\Http\Response |
||
| 148 | */ |
||
| 149 | function updateGroup($name, $group) |
||
|
0 ignored issues
–
show
|
|||
| 150 | { |
||
| 151 | $endpoint = "https://api.hubapi.com/contacts/v2/groups/named/{$name}"; |
||
| 152 | |||
| 153 | $group['name'] = $name; |
||
| 154 | $options['json'] = $group; |
||
| 155 | |||
| 156 | return $this->client->request('put', $endpoint, $options); |
||
| 157 | } |
||
| 158 | |||
| 159 | /** |
||
| 160 | * Delete a property group. |
||
| 161 | * |
||
| 162 | * Delete an existing contact property group. |
||
| 163 | * |
||
| 164 | * @see http://developers.hubspot.com/docs/methods/contacts/v2/delete_contact_property_group |
||
| 165 | * |
||
| 166 | * @param string $name |
||
| 167 | * @return \SevenShores\Hubspot\Http\Response |
||
| 168 | */ |
||
| 169 | function deleteGroup($name) |
||
|
0 ignored issues
–
show
|
|||
| 170 | { |
||
| 171 | $endpoint = "https://api.hubapi.com/contacts/v2/groups/named/{$name}"; |
||
| 172 | |||
| 173 | return $this->client->request('delete', $endpoint); |
||
| 174 | } |
||
| 175 | } |
||
| 176 |
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.