diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..5826402 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/vendor +composer.phar +composer.lock +.DS_Store diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f75bc9b --- /dev/null +++ b/LICENSE @@ -0,0 +1,191 @@ + Copyright 2011 HubSpot, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/README.md b/README.md old mode 100644 new mode 100755 index b5d8432..d6aba72 --- a/README.md +++ b/README.md @@ -1,6 +1,27 @@ -## haPiHP +# HubSpot PHP API client -### Overview +## Example + + +```php +$hapikey = "demo"; + +$hubspot = new HubSpot\HubSpot($hapikey); + +// get 5 contacts' firstnames, offset by 50 +$contacts = $hubspot->contacts()->get_all_contacts(array( + 'count' => 5, // defaults to 20 + 'property' => 'firstname', // only get the specified properties + 'vidOffset' => '50' // contact offset used for paging +)); +``` + +*Note:* The Hubspot class checks for a `HUBSPOT_APIKEY` environment variable if you don't include one during instantiation. + + +### haPiHP + +#### Overview A PHP client for HubSpot's APIs. Docs for this client: [https://github.com/HubSpot/haPiHP/wiki/haPiHP](https://github.com/HubSpot/haPiHP/wiki/haPiHP). @@ -14,3 +35,4 @@ General API reference documentation: [http://developers.hubspot.com/docs](http:/ * [ajorgensen](https://github.com/ajorgensen) (Andrew Jorgensen) * [jprado](https://github.com/jprado) * [thinkclay](https://github.com/thinkclay) (Clayton McIlrath) +* diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..f11ee78 --- /dev/null +++ b/composer.json @@ -0,0 +1,14 @@ +{ + "name": "hubspot/hubspot", + "description": "haPiHP - HubSpot PHP API client", + "license": "Apache-2.0", + "require": { + "php": ">=5.3.0" + }, + "autoload": { + "psr-0": { + "HubSpot\\HubSpot": "src/" + } + }, + "minimum-stability": "stable" +} diff --git a/src/HubSpot/HubSpot.php b/src/HubSpot/HubSpot.php new file mode 100644 index 0000000..537624d --- /dev/null +++ b/src/HubSpot/HubSpot.php @@ -0,0 +1,51 @@ +hapikey = $hapikey; + + if (is_null($hapikey)) + $this->hapikey = getenv('HUBSPOT_APIKEY'); + } + + public function blog() { return new Blog($this->hapikey); } + + public function contacts() { return new Contacts($this->hapikey); } + + public function forms() { return new Forms($this->hapikey); } + + public function keywords() { return new Keywords($this->hapikey); } + + public function leadNurturing() { return new LeadNurturing($this->hapikey); } + + public function leads() { return new Leads($this->hapikey); } + + public function lists() { return new Lists($this->hapikey); } + + public function marketPlace() { return new MarketPlace($this->hapikey); } + + public function properties() { return new Properties($this->hapikey); } + + public function settings() { return new Settings($this->hapikey); } + + public function socialMedia() { return new SocialMedia($this->hapikey); } + + public function workflows() { return new WorkFlows($this->hapikey); } +} diff --git a/class.baseclient.php b/src/HubSpot/HubSpot/BaseClient.php similarity index 91% rename from class.baseclient.php rename to src/HubSpot/HubSpot/BaseClient.php index 30e9a0a..11944af 100644 --- a/class.baseclient.php +++ b/src/HubSpot/HubSpot/BaseClient.php @@ -1,4 +1,7 @@ isBlank($this->API_PATH) ) - throw new HubSpot_Exception('API_PATH must be defined'); + throw new HubSpotException('API_PATH must be defined'); else return $this->API_PATH; } /** * Returns API_VERSION that is set in specific hapi clients. All - * clients that extend HubSpot_BaseClient should set $API_VERSION to the + * clients that extend BaseClient should set $API_VERSION to the * version that the client is developed for (e.g.: the leads v1 * client sets the value to 'v1') * - * @throws HubSpot_Exception + * @throws HubSpotException */ protected function get_api_version() { if ( $this->isBlank($this->API_VERSION) ) - throw new HubSpot_Exception('API_VERSION must be defined'); + throw new HubSpotException('API_VERSION must be defined'); else return $this->API_VERSION; } @@ -175,7 +179,7 @@ protected function get_forms_request_url($url_base,$params) * * @return Body of request result * - * @throws HubSpot_Exception + * @throws HubSpotException */ protected function execute_get_request($url) { @@ -191,7 +195,7 @@ protected function execute_get_request($url) curl_close($ch); if ( $errno > 0 ) - throw new HubSpot_Exception('cURL error: ' . $error); + throw new HubSpotException('cURL error: ' . $error); else return $output; } @@ -204,7 +208,7 @@ protected function execute_get_request($url) * * @return Body of request result * - * @throws HubSpot_Exception + * @throws HubSpotException */ protected function execute_post_request($url, $body, $formenc = FALSE) { @@ -228,7 +232,7 @@ protected function execute_post_request($url, $body, $formenc = FALSE) curl_close($ch); if ( $errno > 0 ) - throw new HubSpot_Exception('cURL error: ' . $error); + throw new HubSpotException('cURL error: ' . $error); else return $output; } @@ -241,7 +245,7 @@ protected function execute_post_request($url, $body, $formenc = FALSE) * * @return Body of request result * - * @throws HubSpot_Exception + * @throws HubSpotException */ protected function execute_JSON_post_request($url, $body) { @@ -260,7 +264,7 @@ protected function execute_JSON_post_request($url, $body) curl_close($ch); if ( $errno > 0 ) - throw new HubSpot_Exception('cURL error: ' . $error); + throw new HubSpotException('cURL error: ' . $error); else return $output; } @@ -273,7 +277,7 @@ protected function execute_JSON_post_request($url, $body) * * @return Body of request result * - * @throws HubSpot_Exception + * @throws HubSpotException */ protected function execute_xml_post_request($url, $body) { @@ -292,7 +296,7 @@ protected function execute_xml_post_request($url, $body) curl_close($ch); if ( $errno > 0 ) - throw new HubSpot_Exception('cURL error: ' . $error); + throw new HubSpotException('cURL error: ' . $error); else return $output; } @@ -305,7 +309,7 @@ protected function execute_xml_post_request($url, $body) * * @return Body of request result * - * @throws HubSpot_Exception + * @throws HubSpotException */ protected function execute_put_request($url, $body) { @@ -324,7 +328,7 @@ protected function execute_put_request($url, $body) curl_close($ch); if ( $apierr > 0 ) - throw new HubSpot_Exception('cURL error: ' . $errmsg); + throw new HubSpotException('cURL error: ' . $errmsg); else return $result; } @@ -337,7 +341,7 @@ protected function execute_put_request($url, $body) * * @return Body of request result * - * @throws HubSpot_Exception + * @throws HubSpotException */ protected function execute_xml_put_request($url, $body) { @@ -356,7 +360,7 @@ protected function execute_xml_put_request($url, $body) curl_close($ch); if ( $apierr > 0 ) - throw new HubSpot_Exception('cURL error: ' . $errmsg); + throw new HubSpotException('cURL error: ' . $errmsg); else return $result; } @@ -369,7 +373,7 @@ protected function execute_xml_put_request($url, $body) * * @return Body of request result * - * @throws HubSpot_Exception + * @throws HubSpotException */ protected function execute_delete_request($url, $body) { @@ -388,7 +392,7 @@ protected function execute_delete_request($url, $body) curl_close($ch); if ( $apierr > 0 ) - throw new HubSpot_Exception('cURL error: ' . $errmsg); + throw new HubSpotException('cURL error: ' . $errmsg); else return $result; } diff --git a/class.blog.php b/src/HubSpot/HubSpot/Blog.php similarity index 78% rename from class.blog.php rename to src/HubSpot/HubSpot/Blog.php index 15fb799..beed6cf 100644 --- a/class.blog.php +++ b/src/HubSpot/HubSpot/Blog.php @@ -1,4 +1,7 @@ execute_get_request($this->get_request_url($endpoint,$params))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve blogs: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve blogs: ' . $e); } } else if ($content_type == 'atom') { try { return $this->execute_get_request($this->get_request_url($endpoint,$params)); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve blogs: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve blogs: ' . $e); } } else { - throw new HubSpot_Exception('Invalid content type, please choose either "json" or "atom"'); + throw new HubSpotException('Invalid content type, please choose either "json" or "atom"'); } } @@ -66,7 +68,7 @@ public function get_blogs($params, $content_type) { * * @returns list of blogs in JSON or XML format. * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_blog($params, $guid, $content_type) { $endpoint = $guid . '.' . $content_type; @@ -74,17 +76,17 @@ public function get_blog($params, $guid, $content_type) { if ($content_type == 'json') { try { return json_decode($this->execute_get_request($this->get_request_url($endpoint, $params))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve blogs: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve blogs: ' . $e); } } else if ($content_type == 'atom') { try { return $this->execute_get_request($this->get_request_url($endpoint, $params)); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve blogs: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve blogs: ' . $e); } } else { - throw new HubSpot_Exception('Invalid content type, please choose either "json" or "atom"'); + throw new HubSpotException('Invalid content type, please choose either "json" or "atom"'); } } @@ -98,7 +100,7 @@ public function get_blog($params, $guid, $content_type) { * * @returns list of blogs in JSON or XML format. * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_posts($params, $guid, $content_type) { $endpoint = $guid . '/posts.' . $content_type; @@ -106,17 +108,17 @@ public function get_posts($params, $guid, $content_type) { if ($content_type == 'json') { try { return json_decode($this->execute_get_request($this->get_request_url($endpoint, $params))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve blogs: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve blogs: ' . $e); } } else if ($content_type == 'atom') { try { return $this->execute_get_request($this->get_request_url($endpoint, $params)); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve blogs: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve blogs: ' . $e); } } else { - throw new HubSpot_Exception('Invalid content type, please choose either "json" or "atom"'); + throw new HubSpotException('Invalid content type, please choose either "json" or "atom"'); } } @@ -130,7 +132,7 @@ public function get_posts($params, $guid, $content_type) { * * @returns list of blogs in JSON or XML format. * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_comments($params, $guid, $content_type) { $endpoint = $guid . '/comments.' . $content_type; @@ -138,17 +140,17 @@ public function get_comments($params, $guid, $content_type) { if ($content_type == 'json') { try { return json_decode($this->execute_get_request($this->get_request_url($endpoint, $params))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve blogs: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve blogs: ' . $e); } } else if ($content_type == 'atom') { try { return $this->execute_get_request($this->get_request_url($endpoint, $params)); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve blogs: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve blogs: ' . $e); } } else { - throw new HubSpot_Exception('Invalid content type, please choose either "json" or "atom"'); + throw new HubSpotException('Invalid content type, please choose either "json" or "atom"'); } } @@ -162,7 +164,7 @@ public function get_comments($params, $guid, $content_type) { * * @returns list of blogs in JSON or XML format. * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_post($params, $guid, $content_type) { $endpoint = 'posts/' . $guid . '.' . $content_type; @@ -170,17 +172,17 @@ public function get_post($params, $guid, $content_type) { if ($content_type == 'json') { try { return json_decode($this->execute_get_request($this->get_request_url($endpoint, $params))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve blogs: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve blogs: ' . $e); } } else if ($content_type == 'atom') { try { return $this->execute_get_request($this->get_request_url($endpoint, $params)); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve blogs: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve blogs: ' . $e); } } else { - throw new HubSpot_Exception('Invalid content type, please choose either "json" or "atom"'); + throw new HubSpotException('Invalid content type, please choose either "json" or "atom"'); } } @@ -194,7 +196,7 @@ public function get_post($params, $guid, $content_type) { * * @returns list of blogs in JSON or XML format. * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_post_comments($params, $post_guid, $content_type) { $endpoint = 'posts/' . $post_guid . '/comments.' . $content_type; @@ -202,17 +204,17 @@ public function get_post_comments($params, $post_guid, $content_type) { if ($content_type == 'json') { try { return json_decode($this->execute_get_request($this->get_request_url($endpoint, $params))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve blogs: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve blogs: ' . $e); } } else if ($content_type == 'atom') { try { return $this->execute_get_request($this->get_request_url($endpoint, $params)); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve blogs: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve blogs: ' . $e); } } else { - throw new HubSpot_Exception('Invalid content type, please choose either "json" or "atom"'); + throw new HubSpotException('Invalid content type, please choose either "json" or "atom"'); } } @@ -226,7 +228,7 @@ public function get_post_comments($params, $post_guid, $content_type) { * * @returns list of blogs in JSON or XML format. * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_comment($params, $comment_guid, $content_type) { $endpoint = 'comments/' . $comment_guid . '.' . $content_type; @@ -234,17 +236,17 @@ public function get_comment($params, $comment_guid, $content_type) { if ($content_type == 'json') { try { return json_decode($this->execute_get_request($this->get_request_url($endpoint, $params))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve blogs: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve blogs: ' . $e); } } else if ($content_type == 'atom') { try { return $this->execute_get_request($this->get_request_url($endpoint, $params)); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve blogs: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve blogs: ' . $e); } } else { - throw new HubSpot_Exception('Invalid content type, please choose either "json" or "atom"'); + throw new HubSpotException('Invalid content type, please choose either "json" or "atom"'); } } @@ -264,17 +266,17 @@ public function get_comment($params, $comment_guid, $content_type) { * * @returns Body of POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function create_post($blog_guid, $author_name, $author_email, $title, $summary, $post_content, $tags) { $endpoint = $blog_guid . '/posts.atom'; if ($this->isBlank($title)) { - throw new HubSpot_Exception('Blog title is required!'); + throw new HubSpotException('Blog title is required!'); } else if ($this->isBlank($post_content)) { - throw new HubSpot_Exception('Blog content is required!'); + throw new HubSpotException('Blog content is required!'); } else if ($this->isBlank($author_email)) { - throw new HubSpot_Exception('Author email is required!'); + throw new HubSpotException('Author email is required!'); } $tag_to_input = ''; @@ -296,8 +298,8 @@ public function create_post($blog_guid, $author_name, $author_email, $title, $su try { return $this->execute_xml_post_request($this->get_request_url($endpoint,null), $body); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to add blog post: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to add blog post: ' . $e); } } @@ -315,13 +317,13 @@ public function create_post($blog_guid, $author_name, $author_email, $title, $su * * @returns Body of POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function update_post($post_guid, $title, $summary, $post_content, $tags, $meta_desc, $keywords) { $endpoint = 'posts/' . $post_guid . '.atom'; if ($this->isBlank($post_guid)) { - throw new HubSpot_Exception('Post guid is required!'); + throw new HubSpotException('Post guid is required!'); } $tag_to_input = ''; @@ -346,8 +348,8 @@ public function update_post($post_guid, $title, $summary, $post_content, $tags, try { return $this->execute_xml_put_request($this->get_request_url($endpoint,null), $body); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to update blog post: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to update blog post: ' . $e); } } @@ -361,13 +363,13 @@ public function update_post($post_guid, $title, $summary, $post_content, $tags, * * @returns Body of POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function publish_post($post_guid, $publish_time, $should_notify) { $endpoint = 'posts/' . $post_guid . '.atom'; if ($this->isBlank($post_guid)) { - throw new HubSpot_Exception('Post guid is required!'); + throw new HubSpotException('Post guid is required!'); } $body = ' @@ -379,8 +381,8 @@ public function publish_post($post_guid, $publish_time, $should_notify) { try { return $this->execute_xml_put_request($this->get_request_url($endpoint,null), $body); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to publish blog post: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to publish blog post: ' . $e); } } @@ -395,7 +397,7 @@ public function publish_post($post_guid, $publish_time, $should_notify) { * * @returns Body of POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function create_comment($post_guid, $author_name, $author_email, $url, $comment) { $endpoint = 'posts/' . $post_guid . '/comments.atom'; @@ -412,8 +414,8 @@ public function create_comment($post_guid, $author_name, $author_email, $url, $c try { return $this->execute_xml_post_request($this->get_request_url($endpoint,null), $body); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to add blog post: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to add blog post: ' . $e); } } } \ No newline at end of file diff --git a/class.contacts.php b/src/HubSpot/HubSpot/Contacts.php similarity index 77% rename from class.contacts.php rename to src/HubSpot/HubSpot/Contacts.php index a28532a..841582d 100644 --- a/class.contacts.php +++ b/src/HubSpot/HubSpot/Contacts.php @@ -1,4 +1,7 @@ $properties)); try{ return json_decode($this->execute_JSON_post_request($this->get_request_url($endpoint,null),$properties)); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to create contact: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to create contact: ' . $e); } } @@ -57,7 +59,7 @@ public function create_contact($params){ * * @return Response body from HTTP POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function update_contact($vid, $params){ $endpoint = 'contact/vid/'.$vid.'/profile'; @@ -68,8 +70,8 @@ public function update_contact($vid, $params){ $properties = json_encode(array("properties"=>$properties)); try{ return json_decode($this->execute_JSON_post_request($this->get_request_url($endpoint,null),$properties)); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to update contact: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to update contact: ' . $e); } } @@ -80,15 +82,15 @@ public function update_contact($vid, $params){ * * @return Response body from HTTP POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function delete_contact($vid){ $endpoint = 'contact/vid/'.$vid; try{ return json_decode($this->execute_delete_request($this->get_request_url($endpoint,null),null)); } - catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to delete contact: ' . $e); + catch (HubSpotException $e) { + throw new HubSpotException('Unable to delete contact: ' . $e); } } @@ -99,34 +101,34 @@ public function delete_contact($vid){ * * @return JSON objects for all Contacts in portal * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_all_contacts($params){ $endpoint = 'lists/all/contacts/all'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,$params))); } - catch(HubSpot_Exception $e){ - throw new HubSpot_Exception('Unable to get contacts: '.$e); + catch(HubSpotException $e){ + throw new HubSpotException('Unable to get contacts: '.$e); } } /** * Get recently updated Contacts * - *@param params: array of 'count', 'time-offset', or 'vid-offset' for results + *@param params: array of 'count', 'time-offset', or 'vid-offset' for results * * @return JSON objects for recently updated Contacts in portal * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_recent_contacts($params){ $endpoint = 'lists/recently_updated/contacts/recent'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,$params))); } - catch(HubSpot_Exception $e){ - throw new HubSpot_Exception('Unable to get contacts: '.$e); + catch(HubSpotException $e){ + throw new HubSpotException('Unable to get contacts: '.$e); } } @@ -137,15 +139,15 @@ public function get_recent_contacts($params){ * * @return JSON object for requested Contact * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_contact_by_id($vid){ $endpoint = 'contact/vid/'.$vid.'/profile'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ - throw new HubSpot_Exception('Unable to get contact: '.$e); + catch(HubSpotException $e){ + throw new HubSpotException('Unable to get contact: '.$e); } } @@ -156,15 +158,15 @@ public function get_contact_by_id($vid){ * * @return JSON object for requested contact * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_contact_by_email($email){ $endpoint = 'contact/email/'.$email.'/profile'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ - throw new HubSpot_Exception('Unable to get contact: '.$e); + catch(HubSpotException $e){ + throw new HubSpotException('Unable to get contact: '.$e); } } @@ -175,15 +177,15 @@ public function get_contact_by_email($email){ * * @return JSON object for requested contact * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_contact_by_usertoken($token){ $endpoint = 'contact/utk/'.$token.'/profile'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ - throw new HubSpot_Exception('Unable to get contact: '.$e); + catch(HubSpotException $e){ + throw new HubSpotException('Unable to get contact: '.$e); } } @@ -194,16 +196,16 @@ public function get_contact_by_usertoken($token){ * * @return JSON object for requested contact * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function search_contacts($params){ $endpoint = 'search/query'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,$params))); } - catch(HubSpot_Exception $e){ - throw new HubSpot_Exception("Unable to search contacts: ".$e); - + catch(HubSpotException $e){ + throw new HubSpotException("Unable to search contacts: ".$e); + } } @@ -213,15 +215,15 @@ public function search_contacts($params){ * * @return JSON object with Contacts statistics * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_contacts_statistics(){ $endpoint = 'contacts/statistics'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ - throw new HubSpot_Exception('Unable to get contact: '.$e); + catch(HubSpotException $e){ + throw new HubSpotException('Unable to get contact: '.$e); } } diff --git a/class.forms.php b/src/HubSpot/HubSpot/Forms.php similarity index 86% rename from class.forms.php rename to src/HubSpot/HubSpot/Forms.php index cc21dea..ad6cb26 100644 --- a/class.forms.php +++ b/src/HubSpot/HubSpot/Forms.php @@ -1,4 +1,7 @@ execute_post_request($this->get_forms_request_url($url_base,null),$param_string,TRUE)); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r("Unable to submit form: ".$e); } @@ -54,14 +56,14 @@ public function submit_form($portalId, $guid, $form_fields, $hs_context){ * * *@return returns JSON objects for all forms in portal - *@throws HubSpot_Exception + *@throws HubSpotException **/ public function get_forms(){ $endpoint = 'forms'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r("Unable to retrieve forms: ".$e); } } @@ -72,28 +74,28 @@ public function get_forms(){ *@param guid: the unique ID for the Form * *@return returns JSON objects for all forms in portal - *@throws HubSpot_Exception + *@throws HubSpotException **/ public function get_form_by_id($guid){ $endpoint = 'forms/'.$guid; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r("Unable to retrieve form: ".$e); } } /** - * Create a Form + * Create a Form * *@param form_data: Data in array format for the form being created. * fields: Array of arrays for fields to be added to the form. - * These arrays will be added to the form_data array, + * These arrays will be added to the form_data array, * no need to include a 'fields' entry in the form_data array passed to function * *@return Response body from HTTP POST request - *@throws HubSpot_Exception + *@throws HubSpotException **/ public function create_form($form_data, $fields){ $endpoint = 'forms'; @@ -101,22 +103,22 @@ public function create_form($form_data, $fields){ try{ return json_decode($this->execute_JSON_post_request($this->get_request_url($endpoint,null),json_encode($form_data))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r("Unable to create form: ".$e); } } /** - * Create a Form + * Create a Form * *@param guid: Unique ID for the form * form_data: Data in array format for the form being created. * fields: Array of arrays for fields to be added to the form. - * These arrays will be added to the form_data array, + * These arrays will be added to the form_data array, * no need to include a 'fields' entry in the form_data array passed to function * *@return Response body from HTTP POST request - *@throws HubSpot_Exception + *@throws HubSpotException **/ public function update_form($guid, $form_data, $fields){ $endpoint = 'forms/'.$guid; @@ -124,7 +126,7 @@ public function update_form($guid, $form_data, $fields){ try{ return json_decode($this->execute_JSON_post_request($this->get_request_url($endpoint,null),json_encode($form_data))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r("Unable to update form: ".$e); } } @@ -135,14 +137,14 @@ public function update_form($guid, $form_data, $fields){ *@param guid: the unique ID for the Form * *@return Response body from HTTP POST request - *@throws HubSpot_Exception + *@throws HubSpotException **/ public function delete_form($guid){ $endpoint = 'forms/'.$guid; try{ return json_decode($this->execute_delete_request($this->get_request_url($endpoint,null),null)); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r("Unable to delete form: ".$e); } } @@ -153,14 +155,14 @@ public function delete_form($guid){ *@param guid: the unique ID for the Form * *@return JSON formatted array of fields - *@throws HubSpot_Exception + *@throws HubSpotException **/ public function get_form_fields($guid){ $endpoint = 'fields/'.$guid; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r("Unable to retrieve fields: ".$e); } } @@ -172,14 +174,14 @@ public function get_form_fields($guid){ * field_name: the key for the field * *@return JSON formatted array of fields - *@throws HubSpot_Exception + *@throws HubSpotException **/ public function get_single_form_field($guid, $field_name){ $endpoint = 'fields/'.$guid.'/'.$field_name; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r("Unable to retrieve field: ".$e); } } diff --git a/class.exception.php b/src/HubSpot/HubSpot/HubSpotException.php similarity index 87% rename from class.exception.php rename to src/HubSpot/HubSpot/HubSpotException.php index 647a0bd..7a9e48c 100644 --- a/class.exception.php +++ b/src/HubSpot/HubSpot/HubSpotException.php @@ -1,4 +1,7 @@ * @see https://github.com/chrishoult */ -class HubSpot_Exception extends Exception {} \ No newline at end of file +class HubSpotException extends Exception {} \ No newline at end of file diff --git a/class.hubspotmarketplace.php b/src/HubSpot/HubSpot/HubSpotMarketplace.php similarity index 99% rename from class.hubspotmarketplace.php rename to src/HubSpot/HubSpot/HubSpotMarketplace.php index 79130a7..466cda0 100644 --- a/class.hubspotmarketplace.php +++ b/src/HubSpot/HubSpot/HubSpotMarketplace.php @@ -1,5 +1,7 @@ execute_get_request($this->get_request_url($endpoint,null))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve keywords: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve keywords: ' . $e); } } @@ -48,14 +50,14 @@ public function get_keywords() { * * @returns Keyword as stdObject * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_keyword($keywordGuid) { $endpoint = 'keywords/' . $keywordGuid; try { return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve keyword: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve keyword: ' . $e); } } @@ -66,7 +68,7 @@ public function get_keyword($keywordGuid) { * * @returns Body of PUT request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function add_keyword($keyword) { $endpoint = 'keywords'; @@ -74,8 +76,8 @@ public function add_keyword($keyword) { $body = '{"keyword":"' . $keyword . '"}'; try { return $this->execute_put_request($this->get_request_url($endpoint,null), $body); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to add keyword: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to add keyword: ' . $e); } } @@ -87,14 +89,14 @@ public function add_keyword($keyword) { * * @returns Body of DELETE request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function delete_keyword($keywordGuid) { $endpoint = 'keywords/' . $keywordGuid; try { return $this->execute_delete_request($this->get_request_url($endpoint,null), null); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to delete keyword: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to delete keyword: ' . $e); } } } \ No newline at end of file diff --git a/class.leadnurturing.php b/src/HubSpot/HubSpot/LeadNurturing.php similarity index 78% rename from class.leadnurturing.php rename to src/HubSpot/HubSpot/LeadNurturing.php index 0d81937..2f8ad7e 100644 --- a/class.leadnurturing.php +++ b/src/HubSpot/HubSpot/LeadNurturing.php @@ -1,4 +1,7 @@ execute_get_request($this->get_request_url($endpoint,$params))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve campaigns: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve campaigns: ' . $e); } } @@ -53,14 +55,14 @@ public function get_campaigns($excludeInactive) { * @param campaignGuid: String value of guid of campaign to list * @returns Array of Campaign Members as stdObjects * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_campaign_members($campaignGuid) { $endpoint = 'campaign/' . $campaignGuid . '/list'; try { return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve campaign members: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve campaign members: ' . $e); } } @@ -70,14 +72,14 @@ public function get_campaign_members($campaignGuid) { * @param leadGuid: String value of guid of lead to list * @returns Array of Campaign Members as stdObjects * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_campaign_history($leadGuid) { $endpoint = 'lead/' . $leadGuid; try { return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve campaign history: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve campaign history: ' . $e); } } @@ -88,15 +90,15 @@ public function get_campaign_history($leadGuid) { * @param leadGuid: String value of guid of lead to add to campaign * @returns POST request body * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function enroll_lead_in_campaign($campaignGuid, $leadGuid) { $endpoint = 'campaign/' . $campaignGuid . '/add'; $body = $leadGuid; try { return $this->execute_post_request($this->get_request_url($endpoint,null), $body); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to add lead to campaign: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to add lead to campaign: ' . $e); } } @@ -107,15 +109,15 @@ public function enroll_lead_in_campaign($campaignGuid, $leadGuid) { * @param leadGuid: String value of guid of lead to remove from campaign * @returns POST request body * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function remove_lead_from_campaign($campaignGuid, $leadGuid) { $endpoint = 'campaign/' . $campaignGuid . '/remove'; $body = $leadGuid; try { return $this->execute_post_request($this->get_request_url($endpoint,null), $body); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to remove lead to campaign: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to remove lead to campaign: ' . $e); } } diff --git a/class.leads.php b/src/HubSpot/HubSpot/Leads.php similarity index 77% rename from class.leads.php rename to src/HubSpot/HubSpot/Leads.php index 9785c40..2870efe 100644 --- a/class.leads.php +++ b/src/HubSpot/HubSpot/Leads.php @@ -1,4 +1,7 @@ execute_get_request($this->get_request_url($endpoint,$params))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve list: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve list: ' . $e); } } @@ -52,15 +54,15 @@ public function get_leads($params) { * * @returns single Lead as stdObject * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_lead($leadGuid) { $endpoint = 'lead/' . $leadGuid; try { $leadArray = json_decode('[' . $this->execute_get_request($this->get_request_url($endpoint,null)) . ']'); return $leadArray[0]; - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve lead: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve lead: ' . $e); } } @@ -72,7 +74,7 @@ public function get_lead($leadGuid) { * * @returns Response body from HTTP PUT request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function update_lead($leadGuid, $updateData) { $endpoint = 'lead/' . $leadGuid; @@ -80,8 +82,8 @@ public function update_lead($leadGuid, $updateData) { $body = json_encode($updateData); try { return $this->execute_put_request($this->get_request_url($endpoint,null), $body); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to update lead: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to update lead: ' . $e); } } @@ -93,7 +95,7 @@ public function update_lead($leadGuid, $updateData) { * * @returns Response body from HTTP PUT request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function close_lead($leadGuid, $closeDate) { $endpoint = 'lead/' . $leadGuid; @@ -104,8 +106,8 @@ public function close_lead($leadGuid, $closeDate) { $body = json_encode($updateData); try { return $this->execute_put_request($this->get_request_url($endpoint,null), $body); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to close lead: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to close lead: ' . $e); } } @@ -117,14 +119,14 @@ public function close_lead($leadGuid, $closeDate) { * * @returns Response body from HTTP PUT request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function add_lead($formURL, $postFields) { $body = $this->array_to_params($postFields); try { return $this->execute_post_request($formURL, $body); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to add lead: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to add lead: ' . $e); } } @@ -133,14 +135,14 @@ public function add_lead($formURL, $postFields) { * * @returns Array of webhooks as stdObjects * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_webhooks() { $endpoint = 'callback-url'; try { return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve webhooks: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve webhooks: ' . $e); } } @@ -151,19 +153,19 @@ public function get_webhooks() { * * @returns Body of POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function register_webhook($callbackURL) { $endpoint = 'callback-url'; if ($this->isBlank($callbackURL)) { - throw new HubSpot_Exception('callbackURL is required'); + throw new HubSpotException('callbackURL is required'); } $params = array('url'=>$callbackURL); $body = $this->array_to_params($params); try { return $this->execute_post_request($this->get_request_url($endpoint,null), $body, true); // new - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to register webhook: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to register webhook: ' . $e); } } @@ -174,17 +176,17 @@ public function register_webhook($callbackURL) { * * @returns Body of DELETE request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function delete_webhook($webhookGuid) { if ($this->isBlank($webhookGuid)) { - throw new HubSpot_Exception('callbackGuid is required'); + throw new HubSpotException('callbackGuid is required'); } $endpoint = 'callback-url/' . $webhookGuid; try { return $this->execute_delete_request($this->get_request_url($endpoint,null), null); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to delete webhook: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to delete webhook: ' . $e); } } diff --git a/class.lists.php b/src/HubSpot/HubSpot/Lists.php similarity index 89% rename from class.lists.php rename to src/HubSpot/HubSpot/Lists.php index 59cd7fa..7cca0a9 100644 --- a/class.lists.php +++ b/src/HubSpot/HubSpot/Lists.php @@ -1,4 +1,7 @@ execute_JSON_post_request($this->get_request_url($endpoint,null),json_encode($params))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r("Unable to create list: ".$e); } } @@ -54,14 +55,14 @@ public function create_list($params){ * * @return Response body from HTTP POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function update_list($id, $params){ $endpoint = 'lists/'.$id; try{ return json_decode($this->execute_JSON_post_request($this->get_request_url($endpoint,null),json_encode($params))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r("Unable to update list: ".$e); } } @@ -70,18 +71,18 @@ public function update_list($id, $params){ * Delete a List * *@param id: Unique ID of the list to delete - * + * * * @return Response body from HTTP POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function delete_list($id){ $endpoint = 'lists/'.$id; try{ return json_decode($this->execute_delete_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r("Unable to delete list: ".$e); } } @@ -90,18 +91,18 @@ public function delete_list($id){ * Get a contact List by ID * *@param id: Unique ID of the list to retrieve - * + * * * @return JSON object for the requested List * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_list($id){ $endpoint = 'lists/'.$id; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to retrieve list: '.$e); } } @@ -112,21 +113,21 @@ public function get_list($id){ *@param params: Array of parameters for request URL * count: number of lists to return * offset: offset number at which to start the list query - * The list results will have a 'has-more' field which will indicate + * The list results will have a 'has-more' field which will indicate * if there are more lists to be returned, as well as an 'offset' field * to indicate where to start the next query if there are more results - * + * * * @return JSON objects for the requested Lists * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_lists($params){ $endpoint = 'lists'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,$params))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to get lists: '.$e); } } @@ -137,21 +138,21 @@ public function get_lists($params){ *@param params: Array of parameters for request URL * count: number of lists to return * offset: offset number at which to start the list query - * The list results will have a 'has-more' field which will indicate + * The list results will have a 'has-more' field which will indicate * if there are more lists to be returned, as well as an 'offset' field * to indicate where to start the next query if there are more results - * + * * * @return JSON objects for the requested Lists * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_static_lists($params){ $endpoint = 'lists/static'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,$params))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to get lists: '.$e); } } @@ -162,21 +163,21 @@ public function get_static_lists($params){ *@param params: Array of parameters for request URL * count: number of lists to return * offset: offset number at which to start the list query - * The list results will have a 'has-more' field which will indicate + * The list results will have a 'has-more' field which will indicate * if there are more lists to be returned, as well as an 'offset' field * to indicate where to start the next query if there are more results - * + * * * @return JSON objects for the requested Lists * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_dynamic_lists($params){ $endpoint = 'lists/dynamic'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,$params))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to get lists: '.$e); } } @@ -187,23 +188,23 @@ public function get_dynamic_lists($params){ *@param params: Array of parameters for request URL * count: number of lists to return * vidOffset: offset contact vid at which to start the query - * The results will have a 'has-more' field which will indicate + * The results will have a 'has-more' field which will indicate * if there are more contacts to be returned, as well as a 'vid-offset' field * to indicate where to start the next query if there are more results * property: Use this to return only one contact property in the results * id: ID of the list to return - * + * * * @return JSON objects for the requested Contacts * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_contacts_in_list($params, $id){ $endpoint = 'lists/'.$id.'/contacts/all'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,$params))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to get contacts: '.$e); } } @@ -214,23 +215,23 @@ public function get_contacts_in_list($params, $id){ *@param params: Array of parameters for request URL * count: number of lists to return * timeOffset: time offset at which to start the query - * The results will have a 'has-more' field which will indicate + * The results will have a 'has-more' field which will indicate * if there are more contacts to be returned, as well as a 'time-offset' field * to indicate where to start the next query if there are more results * property: Use this to return only one contact property in the results * id: ID of the list to return - * + * * * @return JSON objects for the requested Contacts * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_recent_contacts_in_list($params, $id){ $endpoint = 'lists/'.$id.'/contacts/recent'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,$params))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to get contacts: '.$e); } } @@ -240,18 +241,18 @@ public function get_recent_contacts_in_list($params, $id){ * Refresh a Contact List * *@param id: Unique ID of the list to refresh - * + * * * @return Resonse body from HTTP POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function refresh_list($id){ $endpoint = 'lists/'.$id.'/refresh'; try{ return $this->execute_post_request($this->get_request_url($endpoint,null),null); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r("Unable to refresh list: ".$e); } } @@ -261,11 +262,11 @@ public function refresh_list($id){ * *@param vids: Unassociated array of vids for contacts to add to list * id: ID of list to add contacts to - * + * * * @return Resonse body from HTTP POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function add_contacts_to_list($vids,$id){ $endpoint = 'lists/'.$id.'/add'; @@ -273,7 +274,7 @@ public function add_contacts_to_list($vids,$id){ try{ return $this->execute_JSON_post_request($this->get_request_url($endpoint,null),json_encode($request_body)); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r("Unable to add contacts: ".$e); } } @@ -283,11 +284,11 @@ public function add_contacts_to_list($vids,$id){ * *@param vids: Unassociated array of vids for contacts to remove from * id: ID of list to remove contacts from - * + * * * @return Resonse body from HTTP POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function remove_contacts_from_list($vids,$id){ $endpoint = 'lists/'.$id.'/remove'; @@ -295,7 +296,7 @@ public function remove_contacts_from_list($vids,$id){ try{ return $this->execute_JSON_post_request($this->get_request_url($endpoint,null),json_encode($request_body)); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r("Unable to add contacts: ".$e); } } diff --git a/class.properties.php b/src/HubSpot/HubSpot/Properties.php similarity index 88% rename from class.properties.php rename to src/HubSpot/HubSpot/Properties.php index bb9c7b9..4262754 100644 --- a/class.properties.php +++ b/src/HubSpot/HubSpot/Properties.php @@ -1,4 +1,7 @@ execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to retrieve properties: '.$e); } } @@ -47,7 +49,7 @@ public function get_all_properties(){ * *@param name: Name for the new property * params: Array of info for the new property. Example of fields to include: - * + * * "name": "newcustomproperty", * "label": "A New Custom Property", * "description": "A new property for you", @@ -57,11 +59,11 @@ public function get_all_properties(){ * "formField": true, * "displayOrder": 6, * "options": [] - * + * * * @return Response body from HTTP PUT request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function create_property($name,$params){ $endpoint = 'properties/'.$name; @@ -69,7 +71,7 @@ public function create_property($name,$params){ try{ return json_decode($this->execute_put_request($this->get_request_url($endpoint,null),json_encode($params))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to create property: '.$e); } } @@ -79,7 +81,7 @@ public function create_property($name,$params){ * *@param name: Name for the new property * params: Array of info for the property. Example of fields to include: - * + * * "name": "newcustomproperty", * "label": "A New Custom Property", * "description": "A new property for you", @@ -89,11 +91,11 @@ public function create_property($name,$params){ * "formField": true, * "displayOrder": 6, * "options": [] - * + * * * @return Response body of HTTP POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function update_property($name,$params){ $endpoint = 'properties/'.$name; @@ -101,7 +103,7 @@ public function update_property($name,$params){ try{ return json_decode($this->execute_JSON_post_request($this->get_request_url($endpoint,null),json_encode($params))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to update property: '.$e); } } @@ -109,12 +111,12 @@ public function update_property($name,$params){ /** * Delete a Property - * + * * @param name: Name of property to delete * * @return Response body from HTTP DELETE request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function delete_property($name){ $endpoint = 'properties/'.$name; @@ -122,7 +124,7 @@ public function delete_property($name){ try{ return $this->new_execute_delete_request($this->get_request_url($endpoint,null)); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to delete property: '.$e); } } @@ -133,14 +135,14 @@ public function delete_property($name){ * * @return Array of all property groups in portal * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_property_groups(){ $endpoint = 'groups'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to retrieve property groups: '.$e); } @@ -153,14 +155,14 @@ public function get_property_groups(){ * * @return Array containing requested property group * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_property_group($name){ $endpoint = 'groups/'.$name; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to retrieve property group: '.$e); } @@ -179,7 +181,7 @@ public function get_property_group($name){ * * @return Array containing requested property group * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function create_property_group($name,$params){ $endpoint = 'groups/'.$name; @@ -187,7 +189,7 @@ public function create_property_group($name,$params){ try{ return json_decode($this->execute_put_request($this->get_request_url($endpoint,null),json_encode($params))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to create property group: '.$e); } } @@ -205,7 +207,7 @@ public function create_property_group($name,$params){ * * @return Array containing requested property group * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function update_property_group($name,$params){ $endpoint = 'groups/'.$name; @@ -213,7 +215,7 @@ public function update_property_group($name,$params){ try{ return json_decode($this->execute_JSON_post_request($this->get_request_url($endpoint,null),json_encode($params))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to update property group: '.$e); } } @@ -225,14 +227,14 @@ public function update_property_group($name,$params){ * * @return Array containing requested property group * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function delete_property_group($name){ $endpoint = 'groups/'.$name; try{ return json_decode($this->execute_delete_request($this->get_request_url($endpoint,null),null)); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to delete property group: '.$e); } diff --git a/class.prospects.php b/src/HubSpot/HubSpot/Prospects.php similarity index 73% rename from class.prospects.php rename to src/HubSpot/HubSpot/Prospects.php index 568b0b3..5ff1a50 100644 --- a/class.prospects.php +++ b/src/HubSpot/HubSpot/Prospects.php @@ -1,4 +1,7 @@ execute_get_request($this->get_request_url($endpoint,$params))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve timeline: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve timeline: ' . $e); } } @@ -48,14 +50,14 @@ public function get_timeline($params) { * @param organization: Organization to retrieve * @returns Array of Organization details as stdObjects * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_organization_details($organization) { $endpoint = 'timeline/' . $organization; try { return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve organization details: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve organization details: ' . $e); } } @@ -65,15 +67,15 @@ public function get_organization_details($organization) { * @param query: Query string * @returns Array of typeahead results * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_typeahead($query) { $endpoint = 'typeahead'; $params = array('q'=>$query); try { return json_decode($this->execute_get_request($this->get_request_url($endpoint,$params))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve typeahead information: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve typeahead information: ' . $e); } } @@ -84,18 +86,18 @@ public function get_typeahead($query) { * @param query: Query string * @returns Array of search results * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_search_results($type, $query) { if (($type != 'city')&&($type!='region')&&($type!='country')) { - throw new HubSpot_Exception('Invalid type: ' . $type . ' Type must be equal to city, region, or country'); + throw new HubSpotException('Invalid type: ' . $type . ' Type must be equal to city, region, or country'); } $endpoint = 'search/' . $type; $params = array('q'=>$query); try { return json_decode($this->execute_get_request($this->get_request_url($endpoint,$params))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve search results: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve search results: ' . $e); } } @@ -104,14 +106,14 @@ public function get_search_results($type, $query) { * * @returns Array of filters as stdObjects * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_filters() { $endpoint = 'filters'; try { return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve filters: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve filters: ' . $e); } } @@ -122,13 +124,13 @@ public function get_filters() { * * @returns Body of POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function add_filter($organization) { $endpoint = 'filters'; if ($this->isBlank($organization)) { - throw new HubSpot_Exception('Organization is required'); + throw new HubSpotException('Organization is required'); } $params = array('organization'=>$organization); @@ -136,8 +138,8 @@ public function add_filter($organization) { $body = $this->array_to_params($params); try { return $this->execute_post_request($this->get_request_url($endpoint,null), $body); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to add filter: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to add filter: ' . $e); } } @@ -148,13 +150,13 @@ public function add_filter($organization) { * * @returns Body of POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function delete_filter($organization) { $endpoint = 'filters'; if ($this->isBlank($organization)) { - throw new HubSpot_Exception('Organization is required'); + throw new HubSpotException('Organization is required'); } $params = array('organization'=>$organization); @@ -162,8 +164,8 @@ public function delete_filter($organization) { $body = $this->array_to_params($params); try { return $this->execute_delete_request($this->get_request_url($endpoint,null), $body); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to delete filter: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to delete filter: ' . $e); } } diff --git a/class.settings.php b/src/HubSpot/HubSpot/Settings.php similarity index 78% rename from class.settings.php rename to src/HubSpot/HubSpot/Settings.php index 4b53a3c..a6a2af7 100644 --- a/class.settings.php +++ b/src/HubSpot/HubSpot/Settings.php @@ -1,4 +1,7 @@ execute_get_request($this->get_request_url($endpoint,null))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve settings: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve settings: ' . $e); } } @@ -48,15 +50,15 @@ public function get_settings() { * * @returns Setting as stdObject * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_setting($settingName) { $endpoint = 'settings'; $params = array('name'=>$settingName); try { return json_decode($this->execute_get_request($this->get_request_url($endpoint,$params))); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to retrieve setting: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to retrieve setting: ' . $e); } } @@ -68,7 +70,7 @@ public function get_setting($settingName) { * * @returns Body of POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function update_setting($settingName, $value) { $endpoint = 'settings'; @@ -76,8 +78,8 @@ public function update_setting($settingName, $value) { $body = $this->array_to_params($params); try { return $this->execute_post_request($this->get_request_url($endpoint,null), $body); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to update setting: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to update setting: ' . $e); } } @@ -89,7 +91,7 @@ public function update_setting($settingName, $value) { * * @returns Body of DELETE request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function delete_setting($settingName) { $endpoint = 'settings'; @@ -97,8 +99,8 @@ public function delete_setting($settingName) { $body = $this->array_to_params($params); try { return $this->execute_delete_request($this->get_request_url($endpoint,null), $body); - } catch (HubSpot_Exception $e) { - throw new HubSpot_Exception('Unable to delete setting: ' . $e); + } catch (HubSpotException $e) { + throw new HubSpotException('Unable to delete setting: ' . $e); } } } \ No newline at end of file diff --git a/class.socialmedia.php b/src/HubSpot/HubSpot/SocialMedia.php similarity index 87% rename from class.socialmedia.php rename to src/HubSpot/HubSpot/SocialMedia.php index e07ddae..3f09b9f 100644 --- a/class.socialmedia.php +++ b/src/HubSpot/HubSpot/SocialMedia.php @@ -1,4 +1,7 @@ execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to retrieve channels: '.$e); } } @@ -50,7 +52,7 @@ public function get_publishing_channels(){ * *@return returns object for requested publishing channel * - *@throws HubSpot_Exception + *@throws HubSpotException **/ public function get_publishing_channel($guid){ $endpoint = 'channels/'.$guid; @@ -58,7 +60,7 @@ public function get_publishing_channel($guid){ try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to retrieve channel: '.$e); } @@ -72,7 +74,7 @@ public function get_publishing_channel($guid){ * *@return returns objects for requested broadcasts * - *@throws HubSpot_Exception + *@throws HubSpotException **/ public function get_broadcasts($params){ $endpoint = 'broadcasts'; @@ -80,7 +82,7 @@ public function get_broadcasts($params){ try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,$params))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to retrieve broadcasts: '.$e); } } @@ -92,7 +94,7 @@ public function get_broadcasts($params){ * *@return returns object for requested broadcast message * - *@throws HubSpot_Exception + *@throws HubSpotException **/ public function get_broadcast($guid){ $endpoint = 'broadcasts/'.$guid; @@ -100,11 +102,11 @@ public function get_broadcast($guid){ try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to retrieve broadcast: '.$e); } - } + } /** * Create a Broadcast Message @@ -116,7 +118,7 @@ public function get_broadcast($guid){ * *@return returns object for the created broadcast message * - *@throws HubSpot_Exception + *@throws HubSpotException **/ public function create_broadcast($broadcast){ $endpoint = 'broadcasts'; @@ -124,7 +126,7 @@ public function create_broadcast($broadcast){ try{ return json_decode($this->execute_JSON_post_request($this->get_request_url($endpoint,null),json_encode($broadcast))); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to create broadcast: '.$e); } } @@ -137,7 +139,7 @@ public function create_broadcast($broadcast){ * *@return returns response body for DELETE request * - *@throws HubSpot_Exception + *@throws HubSpotException **/ public function delete_broadcast($guid){ $endpoint = 'broadcasts/'.$guid; @@ -145,14 +147,14 @@ public function delete_broadcast($guid){ try{ return json_decode($this->execute_delete_request($this->get_request_url($endpoint,null),null)); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to delete broadcast: '.$e); } - } + } } -?> \ No newline at end of file +?> diff --git a/class.workflows.php b/src/HubSpot/HubSpot/Workflows.php similarity index 77% rename from class.workflows.php rename to src/HubSpot/HubSpot/Workflows.php index fc4eb1e..809e6d6 100644 --- a/class.workflows.php +++ b/src/HubSpot/HubSpot/Workflows.php @@ -1,4 +1,7 @@ execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ - throw new HubSpot_Exception('Unable to get workflows: '.$e); + catch(HubSpotException $e){ + throw new HubSpotException('Unable to get workflows: '.$e); } } @@ -49,15 +51,15 @@ public function get_all_workflows(){ * * @return JSON object for requested Workflow * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_workflow_by_ID($id){ $endpoint = 'workflows/'.$id; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ - throw new HubSpot_Exception('Unable to get workflow: '.$e); + catch(HubSpotException $e){ + throw new HubSpotException('Unable to get workflow: '.$e); } } @@ -69,14 +71,14 @@ public function get_workflow_by_ID($id){ * * @return Response body from HTTP POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function enroll_contact_in_workflow($wfID, $email){ $endpoint = 'workflows/'.$wfID.'/enrollments/contacts/'.$email; try{ return $this->execute_post_request($this->get_request_url($endpoint,null),null); } - catch(HubSpot_Exception $e){ + catch(HubSpotException $e){ print_r('Unable to enroll contact: '.$e); } } @@ -89,13 +91,13 @@ public function enroll_contact_in_workflow($wfID, $email){ * * @return Response body from HTTP POST request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function unenroll_contact_from_workflow($wfID, $email){ $endpoint = 'workflows/'.$wfID.'/enrollments/contacts/'.$email; try { return $this->execute_delete_request($this->get_request_url($endpoint,null),null); - } catch (HubSpot_Exception $e) { + } catch (HubSpotException $e) { print_r('Unable to unenroll contact: '.$e); } } @@ -107,15 +109,15 @@ public function unenroll_contact_from_workflow($wfID, $email){ * * @return Response body from HTTP GET request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_current_enrollments($vid){ $endpoint = 'workflows/enrollments/contacts/'.$vid; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,null))); } - catch(HubSpot_Exception $e){ - throw new HubSpot_Exception('Unable get enrollments for contact: '.$e); + catch(HubSpotException $e){ + throw new HubSpotException('Unable get enrollments for contact: '.$e); } } @@ -125,21 +127,21 @@ public function get_current_enrollments($vid){ *@param wfID: Unique ID for Workflow * vid: Unique ID for contact * params: offset: timestamp from which results should start - * limitDate: timstamp for which events should not be past + * limitDate: timstamp for which events should not be past * * @return Response body from HTTP GET request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_log_events($wfID, $vid, $params){ $endpoint = 'workflows/'.$wfID.'/logevents/contacts/'.$vid.'/past'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,$params))); } - catch(HubSpot_Exception $e){ - throw new HubSpot_Exception('Unable get log events for contact: '.$e); + catch(HubSpotException $e){ + throw new HubSpotException('Unable get log events for contact: '.$e); } - } + } /** * Get upcoming(scheduled) events for Contact in given Workflow @@ -147,19 +149,19 @@ public function get_log_events($wfID, $vid, $params){ *@param wfID: Unique ID for Workflow * vid: Unique ID for contact * params: offset: timestamp from which results should start - * limitDate: timstamp for which events should not be past + * limitDate: timstamp for which events should not be past * * @return Response body from HTTP GET request * - * @throws HubSpot_Exception + * @throws HubSpotException **/ public function get_upcoming_events($wfID, $vid, $params){ $endpoint = 'workflows/'.$wfID.'/logevents/contacts/'.$vid.'/upcoming'; try{ return json_decode($this->execute_get_request($this->get_request_url($endpoint,$params))); } - catch(HubSpot_Exception $e){ - throw new HubSpot_Exception('Unable get upcoming events for contact: '.$e); + catch(HubSpotException $e){ + throw new HubSpotException('Unable get upcoming events for contact: '.$e); } } diff --git a/example.php b/src/HubSpot/HubSpot/example.php similarity index 99% rename from example.php rename to src/HubSpot/HubSpot/example.php index 5fd6982..da11907 100644 --- a/example.php +++ b/src/HubSpot/HubSpot/example.php @@ -339,9 +339,9 @@ print_r($new_list); //Update a contact List - $updated_list_array = array('name'=>'Tweeters and Hubspotters','dynamic'=>false,'portalId'=>'62515','filters'=> + $updated_list_array = array('name'=>'Tweeters and HubSpotters','dynamic'=>false,'portalId'=>'62515','filters'=> array(array(array('operator'=>'IS_NOT_EMPTY','property'=>'twitterhandle','type'=>'string'), - array('operator'=>'EQ','value'=>'Hubspot','property'=>'company','type'=>'string')))); + array('operator'=>'EQ','value'=>'HubSpot','property'=>'company','type'=>'string')))); $updated_list = $lists->update_list($list_id,$updated_list_array); print_r($updated_list); diff --git a/sdk.php b/src/HubSpot/HubSpot/sdk.php similarity index 97% rename from sdk.php rename to src/HubSpot/HubSpot/sdk.php index cbb2271..fa4fbcc 100644 --- a/sdk.php +++ b/src/HubSpot/HubSpot/sdk.php @@ -1,4 +1,7 @@