Skip to content

Commit

Permalink
add language property to config
Browse files Browse the repository at this point in the history
  • Loading branch information
invisnik committed Sep 7, 2018
1 parent d91720c commit 7fdd7eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
6 changes: 5 additions & 1 deletion config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@
/*
* The Cache tag that will be used for all items
*/
'cache_tag' => 'steam.inventory'
'cache_tag' => 'steam.inventory',
/*
* Items language
*/
'language' => 'english'
];
17 changes: 12 additions & 5 deletions src/SteamInventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class SteamInventory
*/
protected $cacheTag;

/**
* @var string $language
*/
protected $language;

/**
* @var mixed The last inventory that was pulled
*/
Expand All @@ -54,8 +59,9 @@ public function __construct(CacheManager $manager)
$this->cache = $manager->driver();
$this->collection = new Collection();

$this->cacheTag = Config::get('steam-inventory.cache_tag');
$this->cacheTime = Config::get('steam-inventory.cache_time');
$this->cacheTag = Config::get('steam-inventory.cache_tag', 'steam.inventory');
$this->cacheTime = Config::get('steam-inventory.cache_time', 60);
$this->language = Config::get('steam-inventory.language', 'english');

$this->guzzleClient = new GuzzleClient;
}
Expand All @@ -78,7 +84,7 @@ public function loadInventory($steamId, $appId = 730, $contextId = 2): SteamInve
return $this;
}

$inventory = $this->getSteamInventory($steamId, $appId, $contextId);
$inventory = $this->getSteamInventory($steamId, $appId, $contextId, $this->language);

if (is_array($inventory)) {
$minutes = $this->cacheTime;
Expand All @@ -96,14 +102,15 @@ public function loadInventory($steamId, $appId = 730, $contextId = 2): SteamInve
* @param integer $steamId
* @param integer $appId
* @param integer $contextId
* @param string $lang
* @return array
*/
private function getSteamInventory($steamId, $appId, $contextId): array
private function getSteamInventory($steamId, $appId, $contextId, $lang): array
{
$steamId = $this->cleanSteamId($steamId);
$this->checkInfo($steamId, $appId, $contextId);

$url = $this->steamApiUrl($steamId, $appId, $contextId);
$url = $this->steamApiUrl($steamId, $appId, $contextId, $lang);

$response = $this->guzzleClient->get($url);
$json = json_decode($response->getBody(), true);
Expand Down

0 comments on commit 7fdd7eb

Please sign in to comment.