diff --git a/README.md b/README.md index 3eeee23..ab081ac 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ If installing from git or composer run `composer install` before activating. ### Setup -Add your HubSpot API Key in `Settings > WCHub` +Add your HubSpot Private App Access Token in `Settings > WCHub` ### Usage @@ -24,19 +24,16 @@ To manually update a Hubspot Contact use the function `wc_hub_update_hubspot_con $wc_hub_contact_id = wc_hub_create_or_update_hubspot_contact( $user ); // Get an existing WCHub Contact record for current user -// @see https://developers.hubspot.com/docs/methods/contacts/get_contact_by_email $contact = wc_hub_get_current_contact(); // Get an existing WCHub Contact from a WP_User object -// @see https://developers.hubspot.com/docs/methods/contacts/get_contact_by_email $contact = wc_hub_get_hubspot_contact( $user ); // Update an existing wc-hub contact -// @see https://legacydocs.hubspot.com/docs/methods/contacts/update_contact-by-email $properties = [ - ['property' => 'firstname', 'value' => 'Sam'], - ['property' => 'lastname', 'value' => 'Iam'], - ['property' => 'custom_property', 'value' => 'custom value'] + ['firstname' => 'Sam'], + ['lastname' => 'Iam'], + ['custom_property' => 'custom value'] ] wc_hub_update_hubspot_contact( $current_user->user_email, $properties); ``` @@ -60,9 +57,8 @@ add_filter( 'wc_hub_hubspot_contact_properties', 'handle_hubspot_contact_props_f function handle_hubspot_contact_props_filter( $properties, $user ) { - $properties[] = [ - 'property' => 'wordpress_username', - 'value' => $user->user_login + $properties = [ + 'property_name' => 'property_value', ]; return $properties; @@ -72,13 +68,12 @@ function handle_hubspot_contact_props_filter( $properties, $user ) { ``` // Modify what HubSpot Contact Properties are returned use the `wc_hub_hubspot_get_contact_parameters` filter. -// See https://developers.hubspot.com/docs/methods/contacts/get_contact_by_email for more details. add_filter( 'wc_hub_hubspot_get_contact_parameters', 'handle_wc_hub_hubspot_get_contact_parameters', 10, 1 ); function handle_wc_hub_hubspot_get_contact_parameters( $parameters ) { - - $parameters = ['showListMemberships' => 1, 'property' => 'lastname']; - - return $parameters; + return array_merge($parameters, [ + 'custom_property_key1', + 'custom_property_key2', + ]); } ``` diff --git a/composer.json b/composer.json index f231d23..39675a1 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "require": { "php": ">=7.1.0", "composer/installers": "v1.0.6", - "hubspot/hubspot-php": "^3.1" + "hubspot/api-client": "^8.3" }, "autoload" : { "psr-4" : { @@ -23,7 +23,9 @@ } }, "config": { - "vendor-dir": "lib" + "vendor-dir": "lib", + "allow-plugins": { + "composer/installers": true + } } } - \ No newline at end of file diff --git a/composer.lock b/composer.lock index d368b41..8bb4277 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2a75feddcbcbdce0b2d44a0d0ca77834", + "content-hash": "9c417d2d09c7029ef57350b7f3590441", "packages": [ { "name": "composer/installers", @@ -322,37 +322,39 @@ "time": "2021-06-30T20:03:07+00:00" }, { - "name": "hubspot/hubspot-php", - "version": "3.1.0", + "name": "hubspot/api-client", + "version": "8.3.1", "source": { "type": "git", - "url": "https://github.com/HubSpot/hubspot-php.git", - "reference": "87dcd275d5fe971a67f0a095994966ad23930e59" + "url": "https://github.com/HubSpot/hubspot-api-php.git", + "reference": "3d9fd4a367be5e80bb307090a429ed53af0dc852" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/HubSpot/hubspot-php/zipball/87dcd275d5fe971a67f0a095994966ad23930e59", - "reference": "87dcd275d5fe971a67f0a095994966ad23930e59", + "url": "https://api.github.com/repos/HubSpot/hubspot-api-php/zipball/3d9fd4a367be5e80bb307090a429ed53af0dc852", + "reference": "3d9fd4a367be5e80bb307090a429ed53af0dc852", "shasum": "" }, "require": { + "ext-curl": "*", "ext-json": "*", - "guzzlehttp/guzzle": "~6.0 | ^7.0", - "php": ">=7.2" + "ext-mbstring": "*", + "guzzlehttp/guzzle": "^7.3", + "guzzlehttp/psr7": "^1.7 || ^2.0", + "php": ">=7.3" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.13", - "phpspec/phpspec": "^3.4", - "phpunit/phpunit": "~5.0" + "friendsofphp/php-cs-fixer": "^3.4", + "phpspec/phpspec": "^7.1", + "phpunit/phpunit": "^9.5" }, "type": "library", "autoload": { "psr-4": { - "SevenShores\\Hubspot\\": "src/" - }, - "files": [ - "src/helpers.php" - ] + "HubSpot\\": "lib/", + "Hubspot\\Tests\\": "tests/", + "HubSpot\\Client\\": "codegen/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -360,21 +362,24 @@ ], "authors": [ { - "name": "Ryan Winchester", - "email": "fungku@gmail.com", - "homepage": "http://ryanwinchester.ca" + "name": "HubSpot", + "homepage": "https://hubspot.com/" } ], - "description": "HubSpot PHP API client", + "description": "Hubspot API client", + "homepage": "https://hubspot.com/", "keywords": [ "api", - "hubspot" + "hubspot", + "php", + "sdk", + "swagger" ], "support": { - "issues": "https://github.com/HubSpot/hubspot-php/issues", - "source": "https://github.com/HubSpot/hubspot-php/tree/3.1.0" + "issues": "https://github.com/HubSpot/hubspot-api-php/issues", + "source": "https://github.com/HubSpot/hubspot-api-php/tree/8.3.1" }, - "time": "2021-07-02T13:01:33+00:00" + "time": "2022-09-01T14:41:04+00:00" }, { "name": "psr/http-client", @@ -591,5 +596,5 @@ "php": ">=7.1.0" }, "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.2.0" } diff --git a/readme.txt b/readme.txt index 422e318..7831c6a 100644 --- a/readme.txt +++ b/readme.txt @@ -2,8 +2,8 @@ Contributors: Kerkness Tags: hubspot, crm, woocommerce, customers Requires at least: 5.4 -Tested up to: 5.8 -Stable tag: 1.0.4 +Tested up to: 6.0.2 +Stable tag: 1.1.0 Requires PHP: 7.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -38,6 +38,9 @@ Yes. The plugin loads your complete HubSpot contact record and makes all propert == Changelog == += 1.1.0 = +* upgraded to use HubSpot V3 SDK and Private APP Token authentication. Requires the creation of a HubSpot private app. + = 1.0.4 = * updating stable tag diff --git a/src/Admin/WCHubOptions.php b/src/Admin/WCHubOptions.php index 7730238..e92918f 100644 --- a/src/Admin/WCHubOptions.php +++ b/src/Admin/WCHubOptions.php @@ -37,8 +37,8 @@ public function wc_hub_activation_hook() */ public function wc_hub_deactivation_hook() { - delete_option( 'wc_hub_hubspot_api_key' ); - delete_site_option('wc_hub_hubspot_api_key'); + delete_option( 'wc_hub_hubspot_access_token' ); + delete_site_option('wc_hub_hubspot_access_token'); } /** @@ -86,7 +86,7 @@ public function wc_hub_register_settings() { register_setting( 'wc_hub_settings', - 'wc_hub_hubspot_api_key', + 'wc_hub_hubspot_access_token', array( 'type' => 'string', 'show_in_rest' => false, @@ -112,15 +112,15 @@ public function wc_hub_options_page()
create an HubSpot API key and then enter the key below.', 'wc-hub'), 'https://knowledge.hubspot.com/integrations/how-do-i-get-my-hubspot-api-key') ?>
+copy your private app acccess-token and then enter the token below.', 'wc-hub'), 'https://developers.hubspot.com/docs/api/migrate-an-api-key-integration-to-a-private-app') ?>