diff --git a/composer.json b/composer.json index d26558e1..fa18bde7 100644 --- a/composer.json +++ b/composer.json @@ -1,18 +1,20 @@ { - "name": "hubspot/php-hubpost-3", + "name": "hubspot/php-hubspot-3", + "version": "0.1", "description": "", "keywords": [ + "hubspot", "swagger", "php", "sdk", "api" ], - "homepage": "http://swagger.io", + "homepage": "https://hubspot.com/", "license": "proprietary", "authors": [ { - "name": "Swagger and contributors", - "homepage": "https://github.com/swagger-api/swagger-codegen" + "name": "HubSpot", + "homepage": "https://hubspot.com/" } ], "require": { @@ -32,8 +34,5 @@ "HubSpot\\Client\\" : "codegen/", "HubSpot\\" : "lib/" } - }, - "autoload-dev": { - "psr-4": { "Swagger\\Client\\" : "test/" } } } diff --git a/composer.lock b/composer.lock index bf646bf4..c72c85de 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": "dcc657d0f6ed86d1f8ee15b77a1f0fda", + "content-hash": "242bd6c445950a5a92856c43df1b7f0f", "packages": [ { "name": "guzzlehttp/guzzle", @@ -2815,7 +2815,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.5", + "php": ">=7.0", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*" diff --git a/lib/Factory.php b/lib/Factory.php index 953e3bd8..4b99c348 100644 --- a/lib/Factory.php +++ b/lib/Factory.php @@ -12,13 +12,13 @@ */ class Factory { - const API_KEY_IDENTIFIED = 'hapikey'; + const API_KEY_IDENTIFIER = 'hapikey'; /** @var string */ - private $apiKey; + protected $apiKey; /** @var string */ - private $accessToken; + protected $accessToken; /** * @param string $name @@ -32,13 +32,17 @@ public function __call($name, $args) $configuration = '\\HubSpot\\Client\\Crm\\'.ucfirst($name).'\\Configuration'; /** @var Configuration $config */ $config = new $configuration(); + if (null !== $this->apiKey) { - $config->setApiKey(static::API_KEY_IDENTIFIED, $this->apiKey); + $config->setApiKey(static::API_KEY_IDENTIFIER, $this->apiKey); } if (null !== $this->accessToken) { $config->setAccessToken($this->accessToken); } + $package = json_decode(file_get_contents(__DIR__.'/../composer.json'), true); + $config->setUserAgent("{$package['name']}; {$package['version']}"); + return new $resource(new Client(), $config); }