Sha256: 4a7806b12c49651f2a867a9ae4289ce265dbeab41e855b106c849761f6e7e81d

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

module Douban
  class Client
    # 回复Api V2 
    # @see http://developers.douban.com/wiki/?title=comment_v2
    module Comment
      private 
      # 获取回复列表
      # @see http://developers.douban.com/wiki/?title=comment_v2#list
      def comments(target, id, options={})
        response = get("v2/#{target}/#{id}/comments", options)
        response["comments"]
      end

      # 新发讨论
      # @see http://developers.douban.com/wiki/?title=comment_v2#new
      def create_comment(target, id, content)
        post "v2/#{target}/#{id}/comments", {:content => content}
      end

      # 获取单条回复
      # @see http://developers.douban.com/wiki/?title=comment_v2#get
      def comment(target, target_id, comment_id)
        get "v2/#{target}/#{target_id}/comment/#{comment_id}"
      end
      
      # 删除回复
      # @see http://developers.douban.com/wiki/?title=comment_v2#delete
      def remove_comment(target, target_id, comment_id)
        delete("v2/#{target}/#{target_id}/comment/#{comment_id}")[:status] == 200
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
douban_api-0.1.2 lib/douban_api/client/comment.rb
douban_api-0.1.1 lib/douban_api/client/comment.rb
douban_api-0.1.0 lib/douban_api/client/comment.rb