22
33namespace Syntax \SteamApi ;
44
5+ use GuzzleHttp \Exception \GuzzleException ;
6+ use Illuminate \Support \Collection ;
7+ use Illuminate \Support \Facades \Config ;
58use stdClass ;
69use GuzzleHttp \Client as GuzzleClient ;
710use GuzzleHttp \Psr7 \Request ;
811use Exception ;
9- use GuzzleHttp \Exception \ClientErrorResponseException ;
10- use GuzzleHttp \Exception \ServerErrorResponseException ;
12+ use GuzzleHttp \Exception \ClientException ;
13+ use GuzzleHttp \Exception \ServerException ;
14+ use Syntax \SteamApi \Exceptions \ApiArgumentRequired ;
1115use Syntax \SteamApi \Exceptions \ApiCallFailedException ;
1216use Syntax \SteamApi \Exceptions \ClassNotFoundException ;
17+ use Syntax \SteamApi \Steam \App ;
18+ use Syntax \SteamApi \Steam \Group ;
19+ use Syntax \SteamApi \Steam \Item ;
20+ use Syntax \SteamApi \Steam \News ;
21+ use Syntax \Steamapi \Steam \Package ;
22+ use Syntax \SteamApi \Steam \Player ;
23+ use Syntax \SteamApi \Steam \User ;
24+ use Syntax \SteamApi \Steam \User \Stats ;
1325
1426/**
15- * @method \Syntax\SteamApi\Steam\ News news()
16- * @method \Syntax\SteamApi\Steam\ Player player($steamId)
17- * @method \Syntax\SteamApi\Steam\ User user($steamId)
18- * @method \Syntax\SteamApi\Steam\User\ Stats userStats($steamId)
19- * @method \Syntax\SteamApi\Steam\ App app()
20- * @method \Syntax\Steamapi\Steam\ Package package()
21- * @method \Syntax\SteamApi\Steam\ Group group()
22- * @method \Syntax\SteamApi\Steam\ Item item($appId)
27+ * @method News news()
28+ * @method Player player($steamId)
29+ * @method User user($steamId)
30+ * @method Stats userStats($steamId)
31+ * @method App app()
32+ * @method Package package()
33+ * @method Group group()
34+ * @method Item item($appId)
2335 */
2436class Client
2537{
@@ -73,6 +85,7 @@ public function getSteamId()
7385 *
7486 * @throws ApiArgumentRequired
7587 * @throws ApiCallFailedException
88+ * @throws GuzzleException
7689 */
7790 protected function setUpService ($ arguments = null )
7891 {
@@ -140,7 +153,6 @@ protected function setUpXml(array $arguments = [])
140153 $ parameters = http_build_query ($ arguments );
141154
142155 // Pass the results back
143- return simplexml_load_file ($ steamUrl . '? ' . $ parameters );
144156 libxml_use_internal_errors (true );
145157 $ result = simplexml_load_file ($ steamUrl . '? ' . $ parameters );
146158
@@ -165,10 +177,11 @@ public function getRedirectUrl()
165177 }
166178
167179 /**
168- * @param \GuzzleHttp\Psr7\ Request $request
180+ * @param Request $request
169181 *
170- * @return \stdClass
171- * @throws \Syntax\SteamApi\Exceptions\ApiCallFailedException
182+ * @return stdClass
183+ * @throws ApiCallFailedException
184+ * @throws GuzzleException
172185 */
173186 protected function sendRequest (Request $ request )
174187 {
@@ -179,9 +192,9 @@ protected function sendRequest(Request $request)
179192 $ result = new stdClass ();
180193 $ result ->code = $ response ->getStatusCode ();
181194 $ result ->body = json_decode ($ response ->getBody (true ));
182- } catch (ClientErrorResponseException $ e ) {
195+ } catch (ClientException $ e ) {
183196 throw new ApiCallFailedException ($ e ->getMessage (), $ e ->getResponse ()->getStatusCode (), $ e );
184- } catch (ServerErrorResponseException $ e ) {
197+ } catch (ServerException $ e ) {
185198 throw new ApiCallFailedException ('Api call failed to complete due to a server error. ' , $ e ->getResponse ()->getStatusCode (), $ e );
186199 } catch (Exception $ e ) {
187200 throw new ApiCallFailedException ($ e ->getMessage (), $ e ->getCode (), $ e );
@@ -236,7 +249,7 @@ public function __call($name, $arguments)
236249 /**
237250 * @param Collection $objects
238251 *
239- * @return $this
252+ * @return Collection
240253 */
241254 protected function sortObjects ($ objects )
242255 {
@@ -260,9 +273,7 @@ protected function getServiceResponse($arguments)
260273 $ arguments = json_encode ($ arguments );
261274
262275 // Get the client
263- $ client = $ this ->setUpService ($ arguments )->response ;
264-
265- return $ client ;
276+ return $ this ->setUpService ($ arguments )->response ;
266277 }
267278
268279 /**
@@ -271,7 +282,7 @@ protected function getServiceResponse($arguments)
271282 */
272283 protected function getApiKey ()
273284 {
274- $ apiKey = \ Config::get ('steam-api.steamApiKey ' );
285+ $ apiKey = Config::get ('steam-api.steamApiKey ' );
275286
276287 if ($ apiKey == 'YOUR-API-KEY ' ) {
277288 throw new Exceptions \InvalidApiKeyException ();
0 commit comments