git.cweiske.de
/
stouyapi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
588d488
)
Buying games #1: output promoted products
author
Christian Weiske
<cweiske@cweiske.de>
Fri, 20 Dec 2019 09:27:37 +0000
(10:27 +0100)
committer
Christian Weiske
<cweiske@cweiske.de>
Fri, 20 Dec 2019 09:27:37 +0000
(10:27 +0100)
bin/import-game-data.php
patch
|
blob
|
history
diff --git
a/bin/import-game-data.php
b/bin/import-game-data.php
index bb3fef86921a60c64cfaf91dbc993e06203ced6c..0ae5a4ee7ca3347b3bc319fd9a83f9f01ecdc986 100755
(executable)
--- a/
bin/import-game-data.php
+++ b/
bin/import-game-data.php
@@
-210,6
+210,21
@@
function buildApps($game)
{
$latestRelease = $game->latestRelease;
{
$latestRelease = $game->latestRelease;
+ $product = null;
+ $gamePromoted = getPromotedProduct($game);
+ if ($gamePromoted) {
+ $product = [
+ 'type' => 'entitlement',
+ 'identifier' => $gamePromoted->identifier,
+ 'name' => $gamePromoted->name,
+ 'description' => $gamePromoted->description ?? '',
+ 'localPrice' => $gamePromoted->localPrice,
+ 'originalPrice' => $gamePromoted->originalPrice,
+ 'percentOff' => 0,
+ 'currency' => $gamePromoted->currency,
+ ];
+ }
+
// http://cweiske.de/ouya-store-api-docs.htm#get-https-devs-ouya-tv-api-v1-apps-xxx
return [
'app' => [
// http://cweiske.de/ouya-store-api-docs.htm#get-https-devs-ouya-tv-api-v1-apps-xxx
return [
'app' => [
@@
-247,7
+262,7
@@
function buildApps($game)
'supportPhone' => $game->developer->supportPhone,
'founder' => $game->developer->founder,
'supportPhone' => $game->developer->supportPhone,
'founder' => $game->developer->founder,
- 'promotedProduct' =>
null
,
+ 'promotedProduct' =>
$product
,
],
];
}
],
];
}
@@
-307,6
+322,21
@@
function buildDetails($game)
];
}
];
}
+ $product = null;
+ $gamePromoted = getPromotedProduct($game);
+ if ($gamePromoted) {
+ $product = [
+ 'type' => 'entitlement',
+ 'identifier' => $gamePromoted->identifier,
+ 'name' => $gamePromoted->name,
+ 'description' => $gamePromoted->description ?? '',
+ 'localPrice' => $gamePromoted->localPrice,
+ 'originalPrice' => $gamePromoted->originalPrice,
+ 'percentOff' => 0,
+ 'currency' => $gamePromoted->currency,
+ ];
+ }
+
// http://cweiske.de/ouya-store-api-docs.htm#get-https-devs-ouya-tv-api-v1-details
return [
'type' => 'Game',
// http://cweiske.de/ouya-store-api-docs.htm#get-https-devs-ouya-tv-api-v1-details
return [
'type' => 'Game',
@@
-363,7
+393,7
@@
function buildDetails($game)
'url' => null,
],
'url' => null,
],
- 'promotedProduct' =>
null
,
+ 'promotedProduct' =>
$product
,
'buttons' => $buttons,
];
}
'buttons' => $buttons,
];
}
@@
-589,6
+619,19
@@
function getAllImageUrls($media)
return $imageUrls;
}
return $imageUrls;
}
+function getPromotedProduct($game)
+{
+ if (!isset($game->products) || !count($game->products)) {
+ return null;
+ }
+ foreach ($game->products as $gameProd) {
+ if ($gameProd->promoted) {
+ return $gameProd;
+ }
+ }
+ return null;
+}
+
function writeJson($path, $data)
{
global $wwwDir;
function writeJson($path, $data)
{
global $wwwDir;