/** {@inheritDoc} */ @Override public void describePost(MethodInfo mInfo) { mInfo.setIdentifier("ContactsAdd"); mInfo.setIdentifier("To add a new contact to the list"); RequestInfo requestInfo = new RequestInfo(); requestInfo .getParameters() .add(new ParameterInfo(ID, true, "Number", ParameterStyle.QUERY, "Contact identifier")); requestInfo.getParameters().add(createCommonParameter(FIRST_NAME, "Contact First Name")); requestInfo.getParameters().add(createCommonParameter(LAST_NAME, "Contact Last Name")); requestInfo.getParameters().add(createCommonParameter(PHONE, "Contact Phone Number")); requestInfo.getParameters().add(createCommonParameter(MAIL, "Contact Email address")); mInfo.setRequest(requestInfo); ResponseInfo response = new ResponseInfo("Contact saved"); response.getStatuses().add(Status.SUCCESS_CREATED); response .getParameters() .add(new ParameterInfo("Content-Location", ParameterStyle.HEADER, "URI contact saved")); mInfo.getResponses().add(response); response = new ResponseInfo("Contact not saved. (restricted to 50)"); response.getStatuses().add(Status.SERVER_ERROR_INSUFFICIENT_STORAGE); mInfo.getResponses().add(response); }
/** {@inheritDoc} */ @Override public void describeGet(MethodInfo mInfo) { mInfo.setIdentifier("ContactsList"); mInfo.setDocumentation("To Retrieve a sorted list of contacts"); RequestInfo requestInfo = new RequestInfo(); ParameterInfo pInfo = createCommonParameter(REQUEST_QUERY_SORT, "Sort query", LAST_NAME); pInfo.getOptions().add(createOptionInfo(FIRST_NAME, "Sort by first name")); pInfo.getOptions().add(createOptionInfo(LAST_NAME, "Sort by last name")); pInfo.getOptions().add(createOptionInfo(MAIL, "Sort by Email")); pInfo.getOptions().add(createOptionInfo(PHONE, "Sort by Phone")); requestInfo.getParameters().add(pInfo); mInfo.setRequest(requestInfo); ResponseInfo response = new ResponseInfo("Current list of contacts"); response.getStatuses().add(Status.SUCCESS_OK); RepresentationInfo repInfo = new RepresentationInfo(MediaType.APPLICATION_XML); repInfo.setXmlElement(CONTACTS); repInfo.setDocumentation("XML List of contacts"); response.getRepresentations().add(repInfo); repInfo = new RepresentationInfo(MediaType.APPLICATION_JSON); repInfo.setXmlElement(CONTACTS); repInfo.setDocumentation("JSON List of contacts"); response.getRepresentations().add(repInfo); mInfo.getResponses().add(response); }