Ejemplo n.º 1
0
                $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();