@@ 21-34 (lines=14) @@ | ||
18 | * When an API call is rejected due to invalid data or call conditions, |
|
19 | * the JSend object's data key contains an object explaining what went wrong, typically a hash of validation errors |
|
20 | */ |
|
21 | class FailResponse extends AbstractResponse |
|
22 | { |
|
23 | /** |
|
24 | * @param string $content |
|
25 | */ |
|
26 | public function __construct($content) |
|
27 | { |
|
28 | $this->response = parent::instance( |
|
29 | sprintf('{"status": "fail", %s}', substr(substr($content, 1), 0, -1)), |
|
30 | 400, |
|
31 | $this->headers |
|
32 | ); |
|
33 | } |
|
34 | } |
|
35 |
@@ 20-33 (lines=14) @@ | ||
17 | * |
|
18 | * When an API call is successful, the JSend object is used as a simple envelope for the results, using the data key. |
|
19 | */ |
|
20 | class Response extends AbstractResponse |
|
21 | { |
|
22 | /** |
|
23 | * @param string $content |
|
24 | */ |
|
25 | public function __construct($content) |
|
26 | { |
|
27 | $this->response = parent::instance( |
|
28 | sprintf('{"status": "success", %s}', substr(substr($content, 1), 0, -1)), |
|
29 | 200, |
|
30 | $this->headers |
|
31 | ); |
|
32 | } |
|
33 | } |
|
34 |