Split update info parsing to 2 functions

This commit is contained in:
mkuba50 2017-10-02 17:30:10 +02:00
parent 564ddb209a
commit 4bed14f093
2 changed files with 17 additions and 1 deletions

View File

@ -16,7 +16,7 @@ limitations under the License.
*/
function uupApiVersion() {
return '0.6.1-beta';
return '0.7.0-beta';
}
function uupApiPrintBrand() {

View File

@ -26,6 +26,22 @@ function uupUpdateInfo($updateId, $onlyInfo = 0) {
$info = json_decode($info, true);
$parsedInfo = uupParseUpdateInfo($info, $onlyInfo);
if(isset($parsedInfo['error'])) {
return $parsedInfo['error'];
}
return array(
'apiVersion' => uupApiVersion(),
'info' => $parsedInfo['info'],
);
}
function uupParseUpdateInfo($info, $onlyInfo = 0) {
if(empty($info)) {
return array('error' => 'UPDATE_INFORMATION_NOT_EXISTS');
}
if($onlyInfo) {
if(isset($info[$onlyInfo])) {
$returnInfo = $info[$onlyInfo];