Skip to content

Commit 31cc29e

Browse files
Pull request #13: Added tracking to requests
Merge in SDK/php_telesign from feature/97092 to developer * commit '590287d16dd6ac97dce750d901a89702d1a6b602': Add changelog to 3.0.4 and 3.0.3 versions Added tracking to requests
2 parents de0722f + 590287d commit 31cc29e

File tree

6 files changed

+43
-11
lines changed

6 files changed

+43
-11
lines changed

RELEASE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
3.0.5
2+
- Added tracking to requests
3+
4+
3.0.4
5+
- Remove overloading of Phone ID
6+
7+
3.0.3
8+
- Added support for request bodies with application/json content-type
9+
110
3.0.2
211
- Added dependency for extension mbstring
312
- Fixed deprecated function utf8_encode() in RestClient.php, changed it with mb_convert_encoding()

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
},
2929
"autoload": {
3030
"psr-4": { "telesign\\sdk\\": "src/" },
31-
"files": [ "src/util.php", "src/version/version.php" ]
31+
"files": [ "src/util.php" ]
3232
},
3333
"autoload-dev": {
34-
"psr-4": { "telesign\\sdk\\": "test/", "telesign\\sdk\\version\\": "./" }
34+
"psr-4": { "telesign\\sdk\\": "test/"}
3535
},
3636
"scripts": {
3737
"test": "phpunit --bootstrap ./vendor/autoload.php test/ --coverage-clover coverage.xml --whitelist src/",

src/config.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace telesign\sdk;
4+
use Composer\InstalledVersions;
5+
6+
class Config {
7+
public static function getVersion()
8+
{
9+
return InstalledVersions::getPrettyVersion('telesign/telesign');
10+
}
11+
}

src/rest/RestClient.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
use Eloquent\Composer\Configuration\ConfigurationReader;
66
use GuzzleHttp\Client;
77
use Ramsey\Uuid\Uuid;
8-
9-
use const telesign\sdk\version\VERSION;
8+
use telesign\sdk\Config;
109

1110
/**
1211
* The TeleSign RestClient is a generic HTTP REST client that can be extended to make requests against any of
@@ -31,6 +30,8 @@ class RestClient {
3130
* @param string $customer_id Your customer_id string associated with your account
3231
* @param string $api_key Your api_key string associated with your account
3332
* @param string $rest_endpoint Override the default rest_endpoint to target another endpoint string
33+
* @param string $source Indicates from where requests are made (Fs or SS)
34+
* @param string $sdk_version Indicate the version of SDK
3435
* @param float $timeout How long to wait for the server to send data before giving up
3536
* @param string $proxy URL of the proxy
3637
* @param callable $handler Guzzle's HTTP transfer override
@@ -39,6 +40,8 @@ function __construct (
3940
$customer_id,
4041
$api_key,
4142
$rest_endpoint = "https://rest-api.telesign.com",
43+
$source = "php_telesign",
44+
$sdk_version = null,
4245
$timeout = 10,
4346
$proxy = null,
4447
$handler = null
@@ -53,11 +56,11 @@ function __construct (
5356
"handler" => $handler
5457
]);
5558

56-
$sdk_version = VERSION;
59+
$current_version = $sdk_version ?? Config::getVersion();
5760
$php_version = PHP_VERSION;
5861
$guzzle_version = Client::MAJOR_VERSION;
5962

60-
$this->user_agent = "TeleSignSDK/php-$sdk_version PHP/$php_version Guzzle/$guzzle_version";
63+
$this->user_agent = "TeleSignSDK/php PHP/$php_version Guzzle/$guzzle_version OriginatingSDK/$source SDKVersion/$current_version";
6164
}
6265

6366
function setRestEndpoint($rest_endpoint) {

src/version/version.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/ConfigTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace telesign\sdk;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use telesign\sdk\Config;
7+
8+
final class ConfigTest extends TestCase {
9+
10+
function testGetVersion () {
11+
$currentVersion = Config::getVersion();
12+
$this->assertEquals($currentVersion, 'dev-master');
13+
}
14+
}

0 commit comments

Comments
 (0)