| @@ 119-132 (lines=14) @@ | ||
| 116 | * |
|
| 117 | * @return Response |
|
| 118 | */ |
|
| 119 | public function postItem($key) |
|
| 120 | { |
|
| 121 | try { |
|
| 122 | $entry = $this->getRequestBody(); |
|
| 123 | $item = $this->di->get("rem")->addItem($key, $entry); |
|
| 124 | } catch (Exception $e) { |
|
| 125 | return $this->di->get("response")->sendJson( |
|
| 126 | ["message" => "500. HTTP request body is not an object/array or valid JSON."], |
|
| 127 | 500 |
|
| 128 | ); |
|
| 129 | } |
|
| 130 | ||
| 131 | return $this->di->get("response")->sendJson($item); |
|
| 132 | } |
|
| 133 | ||
| 134 | ||
| 135 | /** |
|
| @@ 143-156 (lines=14) @@ | ||
| 140 | * |
|
| 141 | * @return void |
|
| 142 | */ |
|
| 143 | public function putItem($key, $itemId) |
|
| 144 | { |
|
| 145 | try { |
|
| 146 | $entry = $this->getRequestBody(); |
|
| 147 | $item = $this->di->get("rem")->upsertItem($key, $itemId, $entry); |
|
| 148 | } catch (Exception $e) { |
|
| 149 | return $this->di->get("response")->sendJson( |
|
| 150 | ["message" => "500. HTTP request body is not an object/array or valid JSON."], |
|
| 151 | 500 |
|
| 152 | ); |
|
| 153 | } |
|
| 154 | ||
| 155 | return $this->di->get("response")->sendJson($item); |
|
| 156 | } |
|
| 157 | ||
| 158 | ||
| 159 | ||