1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Syntax\SteamApi\Steam; |
4
|
|
|
|
5
|
|
|
use Syntax\SteamApi\Client; |
6
|
|
|
use Illuminate\Support\Collection; |
7
|
|
|
use Syntax\SteamApi\Containers\App as AppContainer; |
8
|
|
|
|
9
|
|
|
class App extends Client |
10
|
|
|
{ |
11
|
1 |
|
public function __construct() |
12
|
|
|
{ |
13
|
1 |
|
parent::__construct(); |
14
|
1 |
|
$this->url = 'http://store.steampowered.com/'; |
15
|
1 |
|
$this->interface = 'api'; |
16
|
1 |
|
} |
17
|
|
|
|
18
|
1 |
|
public function appDetails($appIds, $country = null, $language = null) |
19
|
|
|
{ |
20
|
|
|
// Set up the api details |
21
|
1 |
|
$this->method = 'appdetails'; |
22
|
1 |
|
$this->version = null; |
23
|
|
|
|
24
|
|
|
// Set up the arguments |
25
|
|
|
$arguments = [ |
26
|
1 |
|
'appids' => $appIds, |
27
|
1 |
|
'cc' => $country, |
28
|
1 |
|
'l' => $language, |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
// Get the client |
32
|
1 |
|
$client = $this->setUpClient($arguments); |
33
|
1 |
|
$apps = $this->convertToObjects($client); |
34
|
|
|
|
35
|
1 |
|
return $apps; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function GetAppList() |
39
|
|
|
{ |
40
|
|
|
// Set up the api details |
41
|
|
|
$this->url = 'http://api.steampowered.com/'; |
42
|
|
|
$this->interface = 'ISteamApps'; |
43
|
|
|
$this->method = __FUNCTION__; |
44
|
|
|
$this->version = 'v0001'; |
45
|
|
|
|
46
|
|
|
// Get the client |
47
|
|
|
$client = $this->setUpClient(); |
48
|
|
|
|
49
|
|
|
return $client->applist->apps->app; |
50
|
|
|
} |
51
|
|
|
|
52
|
1 |
|
protected function convertToObjects($apps) |
53
|
|
|
{ |
54
|
1 |
|
$convertedApps = $this->convertGames($apps); |
55
|
|
|
|
56
|
1 |
|
$apps = $this->sortObjects($convertedApps); |
57
|
|
|
|
58
|
1 |
|
return $apps; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param $apps |
63
|
|
|
* |
64
|
|
|
* @return Collection |
65
|
|
|
*/ |
66
|
1 |
|
protected function convertGames($apps) |
67
|
|
|
{ |
68
|
1 |
|
$convertedApps = new Collection(); |
69
|
|
|
|
70
|
1 |
|
foreach ($apps as $app) { |
71
|
1 |
|
if (isset($app->data)) { |
72
|
1 |
|
$convertedApps->add(new AppContainer($app->data)); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
1 |
|
return $convertedApps; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|