package de.dtele.net {
/**
* Represents a basically successful response from a source,
* the response itself can signify errors though.
*
* @author Mathias Brodala
*/
public class MediaResponse {
/**
* Signifies a response notifying about
* the successful processing of a request
*/
public static var SUCCESS:String = "success";
/**
* Signifies a response notifying about
* errors during the processing of request
*/
public static var ERROR:String = "error";
private var _version:Number;
/**
* The version of the MediaRequest API this response conforms to
*/
public function get version():Number {
return _version;
}
private var _type:String;
/**
* The type of this response
*/
public function get type():String {
return _type;
}
private var _result:String;
/**
* The result of this response
*/
public function get result():String {
return _result;
}
private var _error:MediaRequestError;
/**
* Description of MediaRequest errors
*/
public function get error():MediaRequestError {
return _error;
}
private var _info:Object = {
title: null,
allowed: [],
restricted: []
};
/**
* Descriptive information of the source
*/
public function get info():Object {
return _info;
}
private var _resources:Object = {};
/**
* Resources attached to this response
*/
public function get resources():Object {
return _resources;
}
public function MediaResponse(data:Object) {
if ("version" in data) {
this._version = data.version;
}
if ("type" in data) {
this._type = data.type;
}
if ("result" in data) {
this._result = data.result;
}
if ("error" in data) {
this._error = new MediaRequestError(data.error.code, data.error.message);
}
if ("info" in data) {
this._info = data.info;
}
if ("resources" in data) {
this._resources = data.resources;
}
}
}
}