1 | <?php |
||
17 | abstract class AbstractService implements ServiceInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var \Symfony\Component\HttpFoundation\ParameterBag |
||
21 | */ |
||
22 | protected $parameters; |
||
23 | |||
24 | /** |
||
25 | * @var \GuzzleHttp\ClientInterface |
||
26 | */ |
||
27 | protected $httpClient; |
||
28 | |||
29 | /** |
||
30 | * @var \Symfony\Component\HttpFoundation\Request |
||
31 | */ |
||
32 | protected $httpRequest; |
||
33 | |||
34 | /** |
||
35 | * Create a new service instance |
||
36 | * |
||
37 | * @param GuzzleClientInterface $httpClient A Guzzle client to make API calls with |
||
38 | * @param HttpRequest $httpRequest A Symfony HTTP request object |
||
39 | */ |
||
40 | 6 | public function __construct(GuzzleClientInterface $httpClient = null, HttpRequest $httpRequest = null) |
|
46 | |||
47 | /** |
||
48 | * Initialize the service with default parameters |
||
49 | * |
||
50 | * @param array $parameters |
||
51 | * @return $this |
||
52 | */ |
||
53 | 18 | public function initialize(array $parameters = []) |
|
69 | |||
70 | /** |
||
71 | * @return array |
||
72 | */ |
||
73 | 18 | public function getDefaultParameters() |
|
80 | |||
81 | /** |
||
82 | * @return array |
||
83 | */ |
||
84 | 12 | public function getParameters() |
|
88 | |||
89 | /** |
||
90 | * @param string $key |
||
91 | * @return mixed |
||
92 | */ |
||
93 | 6 | public function getParameter($key) |
|
97 | |||
98 | /** |
||
99 | * @param string $key |
||
100 | * @param mixed $value |
||
101 | * @return $this |
||
102 | */ |
||
103 | 6 | public function setParameter($key, $value) |
|
109 | |||
110 | /** |
||
111 | * @param string $value |
||
112 | * @return $this |
||
113 | */ |
||
114 | 3 | public function setUsername($value) |
|
118 | |||
119 | /** |
||
120 | * @return string |
||
121 | */ |
||
122 | 3 | public function getUsername() |
|
126 | |||
127 | /** |
||
128 | * @param string $value |
||
129 | * @return $this |
||
130 | */ |
||
131 | 3 | public function setPassword($value) |
|
135 | |||
136 | /** |
||
137 | * @return string |
||
138 | */ |
||
139 | 3 | public function getPassword() |
|
143 | |||
144 | /** |
||
145 | * @see \IBM\Watson\Common\Message\AbstractRequest |
||
146 | * @param string $class The request class name |
||
147 | * @param array $parameters |
||
148 | * @return \IBM\Watson\Common\Message\AbstractRequest |
||
149 | */ |
||
150 | 3 | protected function createRequest($class, array $parameters) |
|
156 | |||
157 | /** |
||
158 | * Get the global default HTTP client |
||
159 | * |
||
160 | * @return HttpClient |
||
161 | */ |
||
162 | 6 | protected function getDefaultHttpClient() |
|
170 | |||
171 | /** |
||
172 | * Get the global default HTTP request |
||
173 | * |
||
174 | * @return HttpRequest |
||
175 | */ |
||
176 | 6 | protected function getDefaultHttpRequest() |
|
180 | } |
||
181 |