-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClient.php
63 lines (56 loc) · 1.71 KB
/
Client.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace IBM\Watson\ToneAnalyzer;
use IBM\Watson\Common\AbstractClient;
use IBM\Watson\Common\HttpClient\Builder;
/**
* Tone Analyzer service
*/
class Client extends AbstractClient
{
/**
* @var array
*/
protected static $locationEndpoints = [
'us_south' => 'https://gateway.watsonplatform.net/tone-analyzer/api',
'us_east' => 'https://gateway-wdc.watsonplatform.net/tone-analyzer/api',
'germany' => 'https://gateway-fra.watsonplatform.net/tone-analyzer/api',
'sydney' => 'https://gateway-syd.watsonplatform.net/tone-analyzer/api',
'uk' => 'https://gateway.watsonplatform.net/tone-analyzer/api'
];
/**
* Create new configured client with username and password
*
* @param string $username
* @param string $password
*
* @param string $version
* @param string $location
*
* @return \IBM\Watson\ToneAnalyzer\Client
*
* @throws \Exception
*/
public static function create($username, $password, $version = null, $location = 'us_south')
{
$httpClient = (new Builder())
->withCredentials($username, $password)
->withVersion($version)
->withHost(static::$locationEndpoints[$location])
->createConfiguredClient();
return new self($httpClient);
}
/**
* @return \IBM\Watson\ToneAnalyzer\Api\Tone
*/
public function tone()
{
return new Api\Tone($this->httpClient, $this->hydrator, $this->requestBuilder);
}
/**
* @return \IBM\Watson\ToneAnalyzer\Api\ToneChat
*/
public function toneChat()
{
return new Api\ToneChat($this->httpClient, $this->hydrator, $this->requestBuilder);
}
}