@Override
  public TopicUpdateResponse postTopic(String queryUri, Topic topic) {
    try {
      Payload topicPayload = new StringPayload(gson.get().toJson(topic, Topic.class));
      HttpResponse response = httpClient.post(queryUri, topicPayload);
      if (response.statusCode() >= 400) {
        throw new BadResponseException(
            "Error POSTing topic "
                + topic.getTitle()
                + " "
                + topic.getNamespace()
                + " "
                + topic.getValue()
                + " code: "
                + response.statusCode()
                + ", message: "
                + response.statusLine());
      }
      WriteResponseWrapper responseWrapper =
          gson.get().fromJson(response.body(), WriteResponseWrapper.class);

      return new TopicUpdateResponse(
          responseWrapper.getAtlasResponse().getId(), response.header(LOCATION));
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
  private Element getResultElement(HttpResponse res) throws ICTomorrowApiException {
    try {
      Builder builder = new Builder();
      Document document = builder.build(res.body(), null);
      Element rootElement = document.getRootElement();

      String statusCode = rootElement.getAttributeValue("status_code");
      String statusMessage = rootElement.getAttributeValue("status_message");
      if (statusCode.equals("200")) {
        return rootElement;
      } else {
        throw new ICTomorrowApiException(
            "Request returned an error response: " + res.body(), statusCode, statusMessage);
      }
    } catch (ParsingException e) {
      throw new ICTomorrowApiException("Exception while parsing response: " + res.body(), e);
    } catch (IOException e) {
      throw new ICTomorrowApiException("Exception while parsing response: " + res.body(), e);
    }
  }
  @Override
  public ContentResponse postItem(String query, Item item) {
    try {
      String json = gson.get().toJson(item);
      Payload httpBody = new StringPayload(json);
      HttpResponse resp = httpClient.post(query, httpBody);
      if (resp.statusCode() >= 400) {
        throw new BadResponseException(
            "Error POSTing item: HTTP "
                + resp.statusCode()
                + " received from Atlas"
                + resp.body()
                + json);
      }

      WriteResponseWrapper responseWrapper =
          gson.get().fromJson(resp.body(), WriteResponseWrapper.class);
      return new ContentResponse(responseWrapper.getAtlasResponse(), resp.header(LOCATION));

    } catch (HttpException e) {
      throw Throwables.propagate(e);
    }
  }