Alternc  latest
Alternc logiel libre pour l'hébergement
Response.php
Go to the documentation of this file.
1 <?php
2 
3 /**
4  * Standard Response object for the AlternC API
5  *
6  */
8 
9  /**
10  * Error codes
11  */
12  const ERR_DISABLED_ACCOUNT = 221801;
13  const ERR_INVALID_AUTH = 221802;
14 
15  /**
16  * Result code. 0 means success
17  *
18  * @var int
19  */
20  public $code;
21 
22  /**
23  * Result message. May be empty
24  *
25  * @var string
26  */
27  public $message;
28 
29  /**
30  * Result data
31  *
32  * @var array
33  */
34  public $content;
35 
36  /**
37  * Result metadata
38  *
39  * @var array
40  */
41  public $metadata;
42 
43  /**
44  * initialize a response object
45  * @param options any of the public above
46  */
47  public function __construct($options = array()) {
48  $os = array("code", "message", "content", "metadata");
49  foreach ($os as $o) {
50  if (isset($options[$o]))
51  $this->$o = $options[$o];
52  }
53  }
54 
55  /**
56  * Formats response to json
57  *
58  * @return string
59  */
60  public function toJson() {
61  return json_encode(get_object_vars($this));
62  }
63 
64 }
65 
66 // class Alternc_Api_Response
67 
Standard Response object for the AlternC API.
Definition: Response.php:7
__construct($options=array())
initialize a response object
Definition: Response.php:47
const ERR_DISABLED_ACCOUNT
Error codes.
Definition: Response.php:12
toJson()
Formats response to json.
Definition: Response.php:60