} else { $results = $corps->put($data, $id); $RestServer->setMessage($id . ' updated'); } } if ($verb === 'POST') { if ($corps->post($data)) { $RestServer->setMessage('Corporation Added'); $RestServer->setStatus(201); } else { throw new Exception('Corporation not added'); } } if ($verb === 'DELETE') { if ($id === NULL) { throw new InvalidArgumentException('No ID'); } else { if ($corps->delete($id)) { $RestServer->setMessage($id . ' deleted'); } else { throw new InvalidArgumentException($id . ' not deleted'); } } } $RestServer->setData($results); } } catch (Exception $ex) { $RestServer->setErrors($ex->getMessage()); $RestServer->setStatus(500); } $RestServer->outputReponse();
if ($resourceData->put($serverData, $id)) { $restServer->setMessage("{$id} Corp Updated"); } else { throw new Exception('Corp could not be updated'); } } } if ('DELETE' === $verb) { if (NULL === $id) { throw new InvalidArgumentException('Corp ID ' . $id . ' was not found'); } else { if ($resourceData->delete($id)) { $restServer->setMessage("{$id} Corp Deleted"); } else { throw new Exception('Corp could not be deleted'); } } } } else { throw new InvalidArgumentException($resource . ' Resource Not Found'); //$response['errors'] = 'Resource Not Found'; //$status = 404; } } catch (InvalidArgumentException $e) { $restServer->setStatus(400); $restServer->setErrors($e->getMessage()); } catch (Exception $e) { $restServer->setStatus(500); $restServer->setErrors($e->getMessage()); } $restServer->outputResponse();