From 7fdd7eb9a2964174cb1592d4ac493ca14331b9b9 Mon Sep 17 00:00:00 2001 From: Nikita Brytkov Date: Fri, 7 Sep 2018 18:33:14 +0300 Subject: [PATCH] add language property to config --- config/config.php | 6 +++++- src/SteamInventory.php | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/config/config.php b/config/config.php index 506e8ba..dce0a6c 100644 --- a/config/config.php +++ b/config/config.php @@ -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' ]; \ No newline at end of file diff --git a/src/SteamInventory.php b/src/SteamInventory.php index d94fe9d..b397925 100644 --- a/src/SteamInventory.php +++ b/src/SteamInventory.php @@ -30,6 +30,11 @@ class SteamInventory */ protected $cacheTag; + /** + * @var string $language + */ + protected $language; + /** * @var mixed The last inventory that was pulled */ @@ -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; } @@ -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; @@ -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);