AlternC/lib/Alternc/Api/Response.php

71 lines
1.1 KiB
PHP
Raw Normal View History

2014-09-17 15:54:24 +00:00
<?php
/**
* Standard Response object for the AlternC API
*
*/
class Alternc_Api_Response {
/**
* Error codes
*/
const ERR_DISABLED_ACCOUNT = 221801;
const ERR_INVALID_AUTH = 221802;
2014-09-17 15:54:24 +00:00
/**
* Result code. 0 means success
*
* @var int
*/
public $code;
/**
* Result message. May be empty
*
* @var string
*/
public $message;
/**
* Result data
*
* @var array
*/
public $content;
/**
* Result metadata
*
* @var array
*/
public $metadata;
/**
* initialize a response object
* @param options any of the public above
*/
2014-09-21 14:44:06 +00:00
public function __construct($options=array()) {
$os=array("code","message","content","metadata");
foreach ($os as $o) {
if (isset($options[$o])) $this->$o=$options[$o];
}
}
2014-09-17 15:54:24 +00:00
/**
* Formats response to json
*
* @return string
*/
public function toJson (){
2014-09-17 15:54:24 +00:00
return json_encode(get_object_vars($this));
}
2014-09-17 15:54:24 +00:00
} // class Alternc_Api_Response