Sha256: e79b05311a0d313da50a0754413d05b722bc98daedf48fe5cd3a54428d8cd4bb

Contents?: true

Size: 1.45 KB

Versions: 17

Compression:

Stored size: 1.45 KB

Contents

module Totter
  class Client
    # Client methods for working with avatars.
    module Comments
      # Gets comments for a given decision
      #
      # @param user_id [Numeric] The decision's user id
      # @param decision_id [Numeric] The decision's id
      # @return [Array]
      # @example
      #   Totter.comments(1, 1)
      def comments(user_id, decision_id)
        get("users/#{user_id}/decisions/#{decision_id}/comments").body
      end

      # Creates a new comment
      #
      # @param user_id [Numeric] The decision's user id
      # @param decision_id [Numeric] The decision's id
      # @param message [String] The comment body
      # @return [Hashie::Mash]
      # @example
      #   Totter.create_comment(1, 1, 'I love boots!')
      def create_comment(user_id, decision_id, message)
        options = {
          :comment => {
            :message => message
          }
        }
        post("users/#{user_id}/decisions/#{decision_id}/comments", options).body
      end

      # Destroys a comment
      #
      # @param user_id [Numeric] The decision's user id
      # @param decision_id [Numeric] The decision's id
      # @param comment_id [Numeric] The comment id
      # @return [Boolean]
      # @example
      #   Totter.destroy_comment(1, 1, 15)
      def destroy_comment(user_id, decision_id, comment_id)
        boolean_from_response(:delete, "users/#{user_id}/decisions/#{decision_id}/comments/#{comment_id}")
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
totter-0.4.8 lib/totter/client/comments.rb
totter-0.4.7 lib/totter/client/comments.rb
totter-0.4.6 lib/totter/client/comments.rb
totter-0.4.5 lib/totter/client/comments.rb
totter-0.4.4 lib/totter/client/comments.rb
totter-0.4.3 lib/totter/client/comments.rb
totter-0.4.2 lib/totter/client/comments.rb
totter-0.4.1 lib/totter/client/comments.rb
totter-0.4.0 lib/totter/client/comments.rb
totter-0.3.9 lib/totter/client/comments.rb
totter-0.3.8 lib/totter/client/comments.rb
totter-0.3.7 lib/totter/client/comments.rb
totter-0.3.6 lib/totter/client/comments.rb
totter-0.3.5 lib/totter/client/comments.rb
totter-0.3.4 lib/totter/client/comments.rb
totter-0.3.3 lib/totter/client/comments.rb
totter-0.3.2 lib/totter/client/comments.rb