Пример #1
0
 protected function updateGame(\Morpheus\SteamGame $game, \GuzzleHttp\Psr7\Response $response)
 {
     $body = json_decode($response->getBody());
     $result = reset($body);
     if ($response->getStatusCode() == 200 && isset($result->success) && $result->success === true) {
         $game->steam_store_data = json_encode($result->data);
     } elseif ($response->getStatusCode() !== 200) {
         \Log::warning('Steam Store API call failed', ['status code' => $response->getStatusCode(), 'game' => $game]);
     } elseif (!isset($result->success)) {
         \Log::warning('Unexpected Steam Store API response', ['body' => $result, 'game' => $game]);
     } else {
         \Log::notice('Game not found in Steam Store database', ['game' => $game]);
     }
     $game->steam_store_updated = date('Y-m-d H:i:s');
     $game->save();
 }
Пример #2
0
 protected function updateGame(\Morpheus\SteamGame $game, \GuzzleHttp\Psr7\Response $response)
 {
     $body = json_decode($response->getBody());
     if ($response->getStatusCode() == 200 && isset($body->result) && $body->result !== false) {
         $game->metacritic_name = $body->result->name;
         $game->metacritic_score = $body->result->score;
         $game->metacritic_userscore = $body->result->userscore;
         $game->metacritic_genre = $body->result->genre[0];
         $game->metacritic_publisher = $body->result->publisher;
         $game->metacritic_developer = $body->result->developer;
         $game->metacritic_rating = $body->result->rating;
         $game->metacritic_url = $body->result->url;
         $game->metacritic_rlsdate = $body->result->rlsdate;
         $game->metacritic_summary = $body->result->summary;
     } elseif ($response->getStatusCode() !== 200) {
         \Log::warning('Metacritic API call failed', ['status code' => $response->getStatusCode(), 'game' => $game]);
     } elseif (!isset($body->result)) {
         \Log::warning('Unexpected Metacritic API response', ['body' => $body, 'game' => $game]);
     } else {
         \Log::notice('Game not found in Metacritic database', ['game' => $game]);
     }
     $game->metacritic_updated = date('Y-m-d H:i:s');
     $game->save();
 }