Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
"name": "sparkpost/php-sparkpost",
"description": "Client library for interfacing with the SparkPost API.",
"license": "Apache 2.0",
"version": "1.1.0",
"authors": [
{
"name": "Message Systems, Inc."
"name": "SparkPost"
}
],
"minimum-stability": "stable",
Expand Down
11 changes: 6 additions & 5 deletions lib/SparkPost/SparkPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ class SparkPost {
public $transmission;
public $messageEvents;

/**
* Library version, used for setting User-Agent.
*/
private $version = '1.1.0';

/**
* Connection config for making requests.
*/
Expand Down Expand Up @@ -80,15 +85,11 @@ public function getHttpHeaders() {
* @return Configuration
*/
private function getHttpConfig($config) {
// get composer.json to extract version number
$composerFile = file_get_contents(dirname(__FILE__) . '/../../composer.json');
$composer = json_decode($composerFile, true);

// create Configuration for http adapter
$httpConfig = new Configuration();
$baseUrl = $config['protocol'] . '://' . $config['host'] . ($config['port'] ? ':' . $config['port'] : '') . '/api/' . $config['version'];
$httpConfig->setBaseUri($baseUrl);
$httpConfig->setUserAgent('php-sparkpost/' . $composer['version']);
$httpConfig->setUserAgent('php-sparkpost/' . $this->version);
return $httpConfig;
}

Expand Down