Class: BitBucket::Issues::Comments

Inherits:
API
  • Object
show all
Defined in:
lib/bitbucket_rest_api/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 Request

Request::METHODS, Request::METHODS_WITH_BODIES

Constants included from Connection

Connection::ALLOWED_OPTIONS

Instance Method Summary collapse

Methods inherited from API

#_merge_mime_type, #_merge_user_into_params!, #_merge_user_repo_into_params!, #_update_user_repo_params, #api_methods_in, inherited, #method_missing, #process_basic_auth, #set_api_client, #setup, #update_and_validate_user_repo_params

Methods included from Normalizer

#normalize!

Methods included from ParameterFilter

#filter!

Methods included from AutoloadHelper

#autoload_all, #lookup_constant, #register_constant

Methods included from Validations::Required

#assert_required_keys, #assert_required_values_present, #parse_values

Methods included from Validations::Token

#validates_token_for

Methods included from Validations::Format

#assert_valid_values

Methods included from Validations::Presence

#_validate_presence_of, #_validate_user_repo_params

Methods included from Request

#delete_request, #get_request, #patch_request, #post_request, #put_request, #request

Methods included from Connection

caching?, clear_cache, connection, default_middleware, default_options, stack

Methods included from Authorization

#authenticated?, #authentication, #basic_authed?

Constructor Details

#initialize(options = {}) ⇒ Comments

Creates new Issues::Comments API



9
10
11
# File 'lib/bitbucket_rest_api/issues/comments.rb', line 9

def initialize(options = {})
  super(options)
end

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'


63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/bitbucket_rest_api/issues/comments.rb', line 63

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
  # _merge_mime_type(:issue_comment, params)
  filter! VALID_ISSUE_COMMENT_PARAM_NAME, params
  assert_required_keys(%w[content], params)

  post_request("/1.0/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'


105
106
107
108
109
110
111
112
113
114
# File 'lib/bitbucket_rest_api/issues/comments.rb', line 105

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
  # _merge_mime_type(:issue_comment, params)

  delete_request("/1.0/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'


86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/bitbucket_rest_api/issues/comments.rb', line 86

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
  # _merge_mime_type(:issue_comment, params)
  filter! VALID_ISSUE_COMMENT_PARAM_NAME, params
  assert_required_keys(%w[content], params)

  put_request("/1.0/repositories/#{user}/#{repo.downcase}/issues/comments/#{comment_id}", params)
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'


41
42
43
44
45
46
47
48
49
50
# File 'lib/bitbucket_rest_api/issues/comments.rb', line 41

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
  # _merge_mime_type(:issue_comment, params)

  get_request("/1.0/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| .. }


20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/bitbucket_rest_api/issues/comments.rb', line 20

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
  # _merge_mime_type(:issue_comment, params)

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

  response.each { |el| yield el }
end