<?php  // vim:set et ts=4 sw=4 sts=4:
# Copyright (C) 2003-2015 hipplay Inc.
#
# This is UNPUBLISHED PROPRIETARY SOURCE CODE OF hipplay Inc.
# The copyright notice above does not evidence any actual or intended
# publication of such source code. The contents of this file may not
# be disclosed to third parties, copied or duplicated in any form, in
# whole or in part, without the prior written permission of
# hipplay Inc.
#
namespace HipPlayConnect\REST\services\kwiltReady;

use HipPlayConnect\Configuration\AxFeatures;
use HipPlayConnect\Configuration\AxOERelease;
use HipPlayConnect\REST\AxAbstractRESTResource;
use HipPlayConnect\REST\AxRESTResourceInterface;

class AxKwiltReadyRESTResource extends AxAbstractRESTResource implements AxRESTResourceInterface
{
    const XML_KWILT_READY = '<kwiltReady productKey="%s" brand="%s" type="%s" model="%s" friendly_name="%s" />';

    protected function GET( array $queryParams )
    {
        self::validateClientLocation();

        $key = AxOERelease::get(AxOERelease::CONFIG_KEY_SERIAL);
        $brand_type_model = AxFeatures::get(AxFeatures::CONFIG_KEY_HIPPLAY_BRAND_TYPE_MODEL);
        $friendly_name = AxOERelease::get(AxOERelease::CONFIG_KEY_FRIENDLY_NAME);
        $retArray = explode('_', $brand_type_model);
        $brand = $retArray[0];
        $type = $retArray[1];
        $model = $retArray[2];

        exec("admin-helper host-event kwilt_ready");

        return $this->generateXmlResponse(
                self::XML_KWILT_READY,
                array(
                    $key,
                    $brand,
                    $type,
                    $model,
                    $friendly_name
                )
            );
	}

}
