/** * {@inheritdoc} */ public function parse(Request $request) { switch ($request->getMethod()) { case 'POST': $request->addTest(new Test('Successful POST request', 'responseCode.code === 201 || responseCode.code === 202')); $request->addTest(new Test('Content-Type is correct', 'postman.getResponseHeader("Content-Type") === "application/ld+json"')); break; case 'PUT': case 'PATCH': case 'GET': $request->addTest(new Test(sprintf('Successful %s request', $request->getMethod()), 'responseCode.code === 200')); $request->addTest(new Test('Content-Type is correct', 'postman.getResponseHeader("Content-Type") === "application/ld+json"')); break; case 'DELETE': $request->addTest(new Test('Successful DELETE request', 'responseCode.code === 204')); break; } }
/** * {@inheritdoc} */ public function parse(Request $request) { $shortName = Inflector::camelize($request->getResource()->getShortName()); switch ($request->getMethod()) { case 'POST': $request->setName(sprintf('Create %s', $shortName)); break; case 'PUT': case 'PATCH': $request->setName(sprintf('Update %s', $shortName)); break; case 'DELETE': $request->setName(sprintf('Delete %s', $shortName)); break; case 'GET': if (!preg_match(UriRequestParser::PATTERN, $request->getUrl())) { $shortName = Inflector::pluralize($shortName) . ' list'; } $request->setName(sprintf('Get %s', $shortName)); break; } }
/** * {@inheritdoc} */ public function supports(Request $request) { return in_array($request->getMethod(), ['POST', 'PUT', 'PATCH']); }