+ ];
+}
+
+function buildDiscover(array $games)
+{
+ $data = [
+ 'title' => 'DISCOVER',
+ 'rows' => [],
+ 'tiles' => [],
+ ];
+ $tileMap = [];
+
+ $rowAll = [
+ 'title' => 'ALL GAMES',
+ 'showPrice' => false,
+ 'ranked' => false,
+ 'tiles' => [],
+ ];
+ foreach ($games as $game) {
+ $tilePos = count($tileMap);
+ $data['tiles'][$tilePos] = buildDiscoverGameTile($game);
+ $tileMap[$game->package] = $tilePos;
+
+ $rowAll['tiles'][] = $tilePos;
+ }
+ $data['rows'][] = $rowAll;
+
+ return $data;
+}
+
+function buildDiscoverHome(array $games)
+{
+ //we do not want anything here for now
+ $data = [
+ 'title' => 'home',
+ 'rows' => [
+ [
+ 'title' => 'FEATURED',
+ 'showPrice' => false,
+ 'ranked' => false,
+ 'tiles' => [],
+ ]
+ ],
+ 'tiles' => [],
+ ];
+ return $data;
+}
+
+function buildDiscoverGameTile($game)
+{
+ $latestRelease = getLatestRelease($game);
+ return [
+ 'gamerNumbers' => $game->players,
+ 'genres' => $game->genres,
+ 'url' => 'ouya://launcher/details?app=' . $game->package,
+ 'latestVersion' => [
+ 'apk' => [
+ 'md5sum' => $latestRelease->md5sum,
+ ],
+ 'versionNumber' => $latestRelease->name,
+ 'uuid' => $latestRelease->uuid,
+ ],
+ 'inAppPurchases' => $game->inAppPurchases,
+ 'promotedProduct' => null,
+ 'premium' => $game->premium,
+ 'type' => 'app',
+ 'package' => $game->package,
+ 'updated_at' => strtotime($latestRelease->date),
+ 'updatedAt' => $latestRelease->date,
+ 'title' => $game->title,
+ 'image' => $game->media->discover,
+ 'contentRating' => $game->contentRating,
+ 'rating' => [
+ 'count' => $game->rating->count,
+ 'average' => $game->rating->average,
+ ],
+ ];