Sha256: ba63bf7a40b755e85f76ecba0fc60ebcc9b9c8adcfe892960caa1799130827f7

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 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

2 entries across 2 versions & 1 rubygems

Version Path
totter-0.3.1 lib/totter/client/comments.rb
totter-0.3.0 lib/totter/client/comments.rb