Exemplo n.º 1
0
  /**
   * This method lets users rate a movie.
   *
   * <p>A valid session id is required.
   *
   * @param sessionToken
   * @param movieId
   * @param rating
   * @throws com.fasterxml.jackson.core.JsonProcessingException
   */
  public boolean postMovieRating(SessionToken sessionToken, Integer movieId, Integer rating) {
    ApiUrl apiUrl = new ApiUrl(TmdbMovies.TMDB_METHOD_MOVIE, movieId, "rating");

    apiUrl.addParam(PARAM_SESSION, sessionToken);

    if (rating < 0 || rating > 10) {
      throw new MovieDbException("rating out of range");
    }

    String jsonBody = Utils.convertToJson(jsonMapper, Collections.singletonMap("value", rating));

    return mapJsonResult(apiUrl, ResponseStatus.class, jsonBody).getStatusCode() == 12;
  }
Exemplo n.º 2
0
  private ResponseStatus modifyWatchList(
      SessionToken sessionToken,
      AccountID accountId,
      Integer movieId,
      MediaType mediaType,
      boolean isWatched) {
    ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "watchlist");

    apiUrl.addParam(PARAM_SESSION, sessionToken);

    HashMap<String, Object> body = new HashMap<String, Object>();

    body.put("media_type", mediaType.toString());
    body.put("media_id", movieId);
    body.put("watchlist", isWatched);

    String jsonBody = Utils.convertToJson(jsonMapper, body);

    return mapJsonResult(apiUrl, ResponseStatus.class, jsonBody);
  }