Class: BitBucket::Client::Issues::Comments

Inherits:
API
  • Object
show all
Defined in:
lib/bitbucket_rest_api/client/issues/comments.rb

Constant Summary collapse

VALID_ISSUE_COMMENT_PARAM_NAME =
%w[
  content
].freeze

Constants included from Validations

Validations::VALID_API_KEYS

Constants included from Validations::Token

Validations::Token::TOKEN_REQUIRED, Validations::Token::TOKEN_REQUIRED_REGEXP

Constants included from BitBucket::Constants

BitBucket::Constants::ACCEPT, BitBucket::Constants::ACCEPT_CHARSET, BitBucket::Constants::CACHE_CONTROL, BitBucket::Constants::CONTENT_LENGTH, BitBucket::Constants::CONTENT_TYPE, BitBucket::Constants::DATE, BitBucket::Constants::ETAG, BitBucket::Constants::LOCATION, BitBucket::Constants::META_FIRST, BitBucket::Constants::META_LAST, BitBucket::Constants::META_NEXT, BitBucket::Constants::META_PREV, BitBucket::Constants::META_REL, BitBucket::Constants::PARAM_PAGE, BitBucket::Constants::PARAM_START_PAGE, BitBucket::Constants::QUERY_STR_SEP, BitBucket::Constants::RATELIMIT_LIMIT, BitBucket::Constants::RATELIMIT_REMAINING, BitBucket::Constants::SERVER, BitBucket::Constants::USER_AGENT

Instance Attribute Summary

Attributes inherited from API

#current_options

Instance Method Summary collapse

Methods inherited from API

#_merge_user_into_params!, #_merge_user_repo_into_params!, #_update_user_repo_params, #api_methods_in, #append_arguments, #arguments, extract_class_name, inherited, #initialize, #method_missing, namespace, #process_basic_auth, #set, #set_api_client, #setup, #with, #yield_or_eval

Methods included from BitBucket::ClassMethods

#configuration, #configure, #require_all

Methods included from Normalizer

#normalize!

Methods included from ParameterFilter

#filter!

Methods included from Validations::Required

#assert_required_keys

Methods included from Validations::Token

#validates_token_for

Methods included from Validations::Format

#assert_valid_values

Methods included from Validations::Presence

#assert_presence_of

Methods included from Request::Verbs

#delete_request, #get_request, #options_request, #patch_request, #post_request, #put_request

Methods included from Authorization

#authenticated?, #authentication, #basic_authed?

Constructor Details

This class inherits a constructor from BitBucket::API

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BitBucket::API

Instance Method Details

#create(user_name, repo_name, issue_id, params = {}) ⇒ Object

Create a comment

Inputs

<tt>:content</tt> Required string

Examples

bitbucket = BitBucket.new
bitbucket.issues.comments.create 'user-name', 'repo-name', 'issue-id',
   "content" => 'a new comment'


58
59
60
61
62
63
64
65
66
67
68
# File 'lib/bitbucket_rest_api/client/issues/comments.rb', line 58

def create(user_name, repo_name, issue_id, params={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of issue_id

  normalize! params
  filter! VALID_ISSUE_COMMENT_PARAM_NAME, params
  assert_required_keys(%w[ content ], params)

  post_request("/repositories/#{user}/#{repo.downcase}/issues/#{issue_id}/comments/", params)
end

#delete(user_name, repo_name, comment_id, params = {}) ⇒ Object

Delete a comment

Examples

bitbucket = BitBucket.new
bitbucket.issues.comments.delete 'user-name', 'repo-name', 'comment-id'


98
99
100
101
102
103
104
105
106
# File 'lib/bitbucket_rest_api/client/issues/comments.rb', line 98

def delete(user_name, repo_name, comment_id, params={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of comment_id

  normalize! params

  delete_request("/repositories/#{user}/#{repo.downcase}/issues/comments/#{comment_id}", params)
end

#edit(user_name, repo_name, comment_id, params = {}) ⇒ Object

Edit a comment

Inputs

<tt>:content</tt> Required string

Examples

bitbucket = BitBucket.new
bitbucket.issues.comments.edit 'user-name', 'repo-name', 'comment-id',
   "content" => 'a new comment'


80
81
82
83
84
85
86
87
88
89
90
# File 'lib/bitbucket_rest_api/client/issues/comments.rb', line 80

def edit(user_name, repo_name, comment_id, params={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of comment_id

  normalize! params
  filter! VALID_ISSUE_COMMENT_PARAM_NAME, params
  assert_required_keys(%w[ content ], params)

  put_request("/repositories/#{user}/#{repo.downcase}/issues/comments/#{comment_id}")
end

#get(user_name, repo_name, comment_id, params = {}) ⇒ Object Also known as: find

Get a single comment

Examples

bitbucket = BitBucket.new
bitbucket.issues.comments.find 'user-name', 'repo-name', 'comment-id'


37
38
39
40
41
42
43
44
45
# File 'lib/bitbucket_rest_api/client/issues/comments.rb', line 37

def get(user_name, repo_name, comment_id, params={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of comment_id

  normalize! params

  get_request("/repositories/#{user}/#{repo.downcase}/issues/comments/#{comment_id}", params)
end

#list(user_name, repo_name, issue_id, params = {}) ⇒ Object Also known as: all

List comments on an issue

Examples

bitbucket = BitBucket.new
bitbucket.issues.comments.all 'user-name', 'repo-name', 'issue-id'
bitbucket.issues.comments.all 'user-name', 'repo-name', 'issue-id' {|com| .. }


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bitbucket_rest_api/client/issues/comments.rb', line 18

def list(user_name, repo_name, issue_id, params={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of issue_id

  normalize! params

  response = get_request("/repositories/#{user}/#{repo.downcase}/issues/#{issue_id}/comments/", params)
  return response unless block_given?
  response.each { |el| yield el }
end