Пример #1
0
    /// <summary>
    /// Sends Scrobble data to Trakt
    /// </summary>
    /// <param name="scrobbleData">The Data to send</param>
    /// <param name="status">The mode to send it as</param>
    /// <returns>The response from Trakt</returns>
    public static TraktResponse ScrobbleMovieState(TraktMovieScrobble scrobbleData, TraktScrobbleStates status)
    {
      //If we are cancelling a scrobble we don't need data
      if (status != TraktScrobbleStates.cancelwatching)
      {
        // check that we have everything we need
        // server can accept title if movie id is not supplied
        if (scrobbleData == null)
        {
          TraktResponse error = new TraktResponse
          {
            Error = "Not enough information to send to server",
            Status = "failure"
          };
          return error;
        }
      }

      // serialize Scrobble object to JSON and send to server
      string response = Transmit(string.Format(TraktURIs.ScrobbleMovie, status), scrobbleData.ToJSON());

      // return success or failure
      return response.FromJSON<TraktResponse>();
    }