public int interestingVotes(String id) throws N0ticeException { OAuthRequest request = createOauthRequest(Verb.GET, apiUrl + "/" + id + "/votes/interesting"); final Response response = request.send(); if (response.getCode() == 200) { return searchParser.parseVotes(response.getBody()); } handleExceptions(response); throw new N0ticeException(response.getBody()); }
public Content authedGet(String id) throws N0ticeException { final OAuthRequest request = createOauthRequest(Verb.GET, urlBuilder.get(id)); oauthSignRequest(request); final Response response = request.send(); if (response.getCode() == 200) { return searchParser.parseReport(response.getBody()); } handleExceptions(response); throw new N0ticeException(response.getBody()); }
public List<String> notifications(String username) throws N0ticeException { OAuthRequest request = createOauthRequest(Verb.GET, urlBuilder.userNotifications(username)); oauthSignRequest(request); final Response response = request.send(); if (response.getCode() == 200) { return searchParser.parseNotifications(response.getBody()); } handleExceptions(response); throw new N0ticeException(response.getBody()); }
public ResultSet authedSearch(SearchQuery searchQuery) throws N0ticeException { OAuthRequest request = createOauthRequest(Verb.GET, searchUrlBuilder.toUrl(searchQuery)); oauthSignRequest(request); Response response = request.send(); final String responseBody = response.getBody(); if (response.getCode() == 200) { return searchParser.parseSearchResults(responseBody); } handleExceptions(response); throw new N0ticeException(response.getBody()); }
public Content updateReport(String id, String headline, String body) throws N0ticeException { OAuthRequest request = createOauthRequest(Verb.POST, apiUrl + "/" + id); addBodyParameter(request, "headline", headline); oauthSignRequest(request); Response response = request.send(); final String responseBody = response.getBody(); if (response.getCode() == 200) { return searchParser.parseReport(responseBody); } handleExceptions(response); throw new N0ticeException(response.getBody()); }
public Content postReport( String headline, Double latitude, Double longitude, String body, String link, MediaFile image, VideoAttachment video, String noticeboard, DateTime date) throws N0ticeException { OAuthRequest request = createOauthRequest(Verb.POST, apiUrl + "/report/new"); MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); if (headline != null) { addStringPart(entity, "headline", headline); } if (noticeboard != null) { addStringPart(entity, "noticeboard", noticeboard); } if (latitude != null && longitude != null) { addStringPart(entity, "latitude", Double.toString(latitude)); addStringPart(entity, "longitude", Double.toString(longitude)); } populateUpdateFields(body, link, image, video, entity); if (date != null) { addStringPart(entity, "date", date.toString(ZULE_TIME_FORMAT)); } request.addHeader("Content-Type", entity.getContentType().getValue()); addMultipartEntity(request, entity); oauthSignRequest(request); Response response = request.send(); final String responseBody = response.getBody(); if (response.getCode() == 200) { return searchParser.parseReport(responseBody); } handleExceptions(response); throw new N0ticeException(response.getBody()); }
public Content postEvent( String headline, double latitude, double longitude, String body, String link, MediaFile image, VideoAttachment video, String noticeboard, LocalDateTime startDate, LocalDateTime endDate, Reoccurence reoccurence, LocalDateTime reoccursTo) throws N0ticeException { final OAuthRequest request = createOauthRequest(Verb.POST, apiUrl + "/event/new"); final MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); addEntityPartParameter(entity, "headline", headline); addEntityPartParameter(entity, "noticeboard", noticeboard); addEntityPartParameter(entity, "latitude", Double.toString(latitude)); addEntityPartParameter(entity, "longitude", Double.toString(longitude)); populateUpdateFields(body, link, image, video, entity); addEntityPartParameter(entity, "startDate", startDate.toString(LOCAL_DATE_TIME_FORMAT)); addEntityPartParameter(entity, "endDate", endDate.toString(LOCAL_DATE_TIME_FORMAT)); if (reoccurence != null && reoccursTo != null) { addEntityPartParameter(entity, "reoccurs", reoccurence.toString()); addEntityPartParameter(entity, "reoccursTo", reoccursTo.toString(LOCAL_DATE_TIME_FORMAT)); } request.addHeader("Content-Type", entity.getContentType().getValue()); addMultipartEntity(request, entity); oauthSignRequest(request); Response response = request.send(); final String responseBody = response.getBody(); if (response.getCode() == 200) { return searchParser.parseReport(responseBody); } handleExceptions(response); throw new N0ticeException(response.getBody()); }
public Group createGroup(String name) throws N0ticeException { OAuthRequest request = createOauthRequest(Verb.POST, apiUrl + "/groups/new"); MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); addEntityPartParameter(entity, "name", name); request.addHeader("Content-Type", entity.getContentType().getValue()); addMultipartEntity(request, entity); oauthSignRequest(request); Response response = request.send(); final String responseBody = response.getBody(); if (response.getCode() == 200) { return searchParser.parseGroupResult(responseBody); } handleExceptions(response); throw new N0ticeException(response.getBody()); }
public Update postReportUpdate( String reportId, String body, String link, MediaFile image, VideoAttachment video) throws N0ticeException { OAuthRequest request = createOauthRequest(Verb.POST, apiUrl + "/" + reportId + "/update/new"); MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); populateUpdateFields(body, link, image, video, entity); request.addHeader("Content-Type", entity.getContentType().getValue()); addMultipartEntity(request, entity); oauthSignRequest(request); final Response response = request.send(); if (response.getCode() == 200) { return searchParser.parseUpdate(response.getBody()); } handleExceptions(response); throw new N0ticeException(response.getBody()); }
public ResultSet search(SearchQuery searchQuery) throws N0ticeException { return searchParser.parseSearchResults( httpFetcher.fetchContent(searchUrlBuilder.toUrl(searchQuery), UTF_8)); }
public Update getUpdate(String id) throws N0ticeException { return searchParser.parseUpdate(httpFetcher.fetchContent(urlBuilder.get(id), UTF_8)); }
public Content get(String id) throws N0ticeException { return searchParser.parseReport(httpFetcher.fetchContent(urlBuilder.get(id), UTF_8)); }