Sha256: e55d27178750538f39e5076506d06127582ad69c22fefd661ded13d6f2ddbe0b

Contents?: true

Size: 2 KB

Versions: 5

Compression:

Stored size: 2 KB

Contents

# encoding: utf-8

module Github
  class Gists
    module Comments

      REQUIRED_GIST_COMMENT_INPUTS = %w[ body ]
      
      # List comments on a gist
      #
      # = Examples
      #  @github = Github.new
      #  @github.gists.gist_comments 'gist-id'
      #
      def gist_comments(gist_id, params={})
        _normalize_params_keys(params)
        get("/gists/#{gist_id}/comments", params)
      end

      # Get a single comment
      #
      # = Examples
      #  @github = Github.new
      #  @github.gists.gist_comment 'comment-id'
      #
      def gist_comment(comment_id, params={})
        _normalize_params_keys(params)
        get("/gists/comments/#{comment_id}", params)
      end

      # Create a comment
      #
      # = Examples
      #  @github = Github.new
      #  @github.gists.create_gist_comment 'gist-id'
      #
      def create_gist_comment(gist_id, params={})
        _normalize_params_keys(params)
        _filter_params_keys(REQUIRED_GIST_COMMENT_INPUTS, params)
        
        raise ArgumentError, "Required inputs are: :body" unless _validate_inputs(REQUIRED_GIST_COMMENT_INPUTS, params)

        post("/gists/#{gist_id}/comments", params)
      end

      # Edit a comment
      #
      # = Examples
      #  @github = Github.new
      #  @github.gists.edit_gist_comment 'comment-id'
      #
      def edit_gist_comment(comment_id, params={})
        _normalize_params_keys(params)
        _filter_params_keys(REQUIRED_GIST_COMMENT_INPUTS, params)
        
        raise ArgumentError, "Required inputs are: :body" unless _validate_inputs(REQUIRED_GIST_COMMENT_INPUTS, params)

        patch("/gists/comments/#{comment_id}", params)
      end

      # Delete a comment
      #
      # = Examples
      #  @github = Github.new
      #  @github.gists.delete_gist_comment 'comment-id'
      #
      def delete_gist_comment(comment_id, params={})
        _normalize_params_keys(params)
        delete("/gists/comments/#{comment_id}", params)
      end
       
    end # Comments
  end # Gists
end # Github

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
github_api-0.2.0 lib/github_api/gists/comments.rb
github_api-0.1.2 lib/github_api/gists/comments.rb
github_api-0.1.1 lib/github_api/gists/comments.rb
github_api-0.1.0 lib/github_api/gists/comments.rb
github_api-0.1.0.pre lib/github_api/gists/comments.rb