<?xml version="1.0" encoding="UTF-8"?>
<component name="GetCodeTask" extends="Task">
    
    <interface>
        <field id="code" type="string"/>
        <field id="expires" type="integer"/>
        <field id="result" type="boolean"/>
        <field id="errorMsg" type="string"/>
    </interface>

    <script type="text/brightscript">
    <![CDATA[
        sub init()
            m.top.functionName = "GetActivationCode"
        end sub
        
        sub GetActivationCode()
            m.top.result = false

            request = CreateObject("roUrlTransfer")
            url = "http://rokupro.contentmastersrebrand.com/get_code.php"
            request.SetUrl(url)
            
            response = request.GetToString()
            
            if response = invalid or response = "" then
                return
            end if

            json = ParseJSON(response)
            
            if json = invalid then
                return
            end if

            if json.code <> invalid
                m.top.code = json.code
                if json.expires <> invalid
                    m.top.expires = json.expires
                end if
                m.top.result = true
            end if
        end sub
    ]]>
    </script>

</component>