1: <?php
2:
3: namespace Genetsis\core\activityid;
4:
5: /**
6: * The resulting object is based on the Result property defined in the Result section of the Activity Streams Schema.
7: *
8: * @package Genetsis
9: * @category Bean
10: * @version 1.0
11: * @access private
12: */
13: class Response
14: {
15: /** SUCCESS: The activity was successful created */
16: const RESPONSE_SUCCESS = 201;
17: /** ERROR: Bad Request: The request could not be understood by the server due to malformed syntax. */
18: const RESPONSE_BAD_REQUEST = 400;
19: /** AUTH ERROR: Non authenticated user */
20: const RESPONSE_AUTH_REQUIRE = 401;
21: /** NOT FOUND: Resource not found in server */
22: const RESPONSE_NOT_FOUND = 404;
23: /** ERROR: Conflict: The request could not be completed due to a conflict with the current state of the resource */
24: const RESPONSE_CONFLICT = 409;
25: /** ERROR: Precondition failed: Business validation error */
26: const RESPONSE_VALIDATION_ERROR = 412;
27: /** ERROR: Internal Server Error: The server encountered an unexpected condition which prevented it from fulfilling the request */
28: const RESPONSE_INTERNAL_ERROR = 500;
29:
30: /** @var integer Response Status */
31: private $status = null;
32: /** @var string Error Message */
33: private $error_message;
34: /** @var string Error Reason */
35: private $error_reason;
36: /** @var string Object Id */
37: private $object_id;
38:
39: /**
40: * Returns the response Status.
41: *
42: * @return mixed An integer (201) whether request result is Ok another code otherwise.
43: */
44: public function getStatus()
45: {
46: return ((!isset($this->status) || ($this->status === null))
47: ? null
48: : $this->status);
49: }
50:
51: /**
52: * Sets the response response code.
53: *
54: * @param integer The response code.
55: * @return void
56: */
57: public function setStatus($code)
58: {
59: $this->status = (!is_integer($code)
60: ? (int)$code
61: : $code);
62: }
63:
64: /**
65: * Returns the response Error Message.
66: *
67: * @return mixed An string whether error code!=201 NULL otherwise.
68: */
69: public function getErrorMessage()
70: {
71: return ((!isset($this->error_message) || ($this->error_message === null))
72: ? null
73: : $this->error_message);
74: }
75:
76: /**
77: * Sets the response error message.
78: *
79: * @param string The error message.
80: * @return void
81: */
82: public function setErrorMessage($message)
83: {
84: $this->error_message = $message;
85: }
86:
87: /**
88: * Returns the request Error Reason.
89: *
90: * @return mixed An string whether error code!=201 NULL otherwise.
91: */
92: public function getErrorReason()
93: {
94: return ((!isset($this->error_reason) || ($this->error_reason === null))
95: ? null
96: : $this->error_reason);
97: }
98:
99: /**
100: * Sets the response error reason.
101: *
102: * @param string The error reason.
103: * @return void
104: */
105: public function setErrorReason($reason)
106: {
107: $this->error_reason = $reason;
108: }
109:
110: /**
111: * Returns the response object id.
112: *
113: * @return mixed An string whether error code!=201 NULL otherwise.
114: */
115: public function getObjectId()
116: {
117: return ((!isset($this->object_id) || ($this->object_id === null))
118: ? null
119: : $this->object_id);
120: }
121:
122: /**
123: * Sets the response object id.
124: *
125: * @param string The object id.
126: * @return void
127: */
128: public function setObjectId($obj_id)
129: {
130: $this->object_id = $obj_id;
131: }
132: }
133: