Class: Tinybucket::Api::CommentsApi
- Includes:
- Helper::CommentsHelper
- Defined in:
- lib/tinybucket/api/comments_api.rb
Overview
Comments Api client
Constant Summary
Constants included from Connection
Connection::DEFAULT_USER_AGENT
Instance Attribute Summary collapse
- #commented_to ⇒ Tinybucket::Model::Commit, Tinybucket::Model::PullRequest
-
#repo_owner ⇒ String
Repository owner name.
- #repo_slug ⇒ String
Instance Method Summary collapse
-
#find(comment_id, options = {}) ⇒ Tinybucket::Model::Comment
Send ‘GET a individual comment’ request.
-
#list(options = {}) ⇒ Tinybucket::Model::Page
Send ‘GET a list of comments’ request.
Methods included from Connection
#caching?, #clear_cache, #connection
Instance Attribute Details
#commented_to ⇒ Tinybucket::Model::Commit, Tinybucket::Model::PullRequest
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/tinybucket/api/comments_api.rb', line 13 class CommentsApi < BaseApi include Tinybucket::Api::Helper::CommentsHelper attr_accessor :repo_owner, :repo_slug attr_accessor :commented_to # Send 'GET a list of comments' request. # # This method send different request depend on 'commented_to' attribute. # # @note When 'commented_to' is {Tinybucket::Model::Commit} instance, # this method send {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bsha%7D/comments#get # GET a list of commit comments}. # @note When 'commented_to' is {Tinybucket::Model::PullRequest} instance, # this method send {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bsha%7D/comments#get # GET a list of pull request comments}. # # @param options [Hash] # @return [Tinybucket::Model::Page] def list( = {}) list = get_path(path_to_list, , get_parser(:collection, Tinybucket::Model::Comment)) associate_with_target(list) list end # Send 'GET a individual comment' request. # # This method send different request depend on 'commented_to' attribute. # # @note When 'commented_to' is {Tinybucket::Model::Commit} instance, # this method send {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bsha%7D/comments/%7Bcomment_id%7D#get # GET an individual commit comment}. # @note When 'commented_to' is {Tinybucket::Model::PullRequest} instance, # this method send {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bsha%7D/comments/%7Bcomment_id%7D#get # GET an individual pull request comment}. # # @param comment_id [String] comment identifier # @param options [Hash] # @return [Tinybucket::Model::Comment] def find(comment_id, = {}) comment = get_path(path_to_find(comment_id), , get_parser(:object, Tinybucket::Model::Comment)) associate_with_target(comment) comment end private def associate_with_target(result) case result when Tinybucket::Model::Comment result.commented_to = commented_to when Tinybucket::Model::Page result.items.map { |m| m.commented_to = commented_to } else raise ArgumentError, "Invalid result: #{result.inspect}" end result end end |
#repo_owner ⇒ String
Returns repository owner name.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/tinybucket/api/comments_api.rb', line 13 class CommentsApi < BaseApi include Tinybucket::Api::Helper::CommentsHelper attr_accessor :repo_owner, :repo_slug attr_accessor :commented_to # Send 'GET a list of comments' request. # # This method send different request depend on 'commented_to' attribute. # # @note When 'commented_to' is {Tinybucket::Model::Commit} instance, # this method send {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bsha%7D/comments#get # GET a list of commit comments}. # @note When 'commented_to' is {Tinybucket::Model::PullRequest} instance, # this method send {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bsha%7D/comments#get # GET a list of pull request comments}. # # @param options [Hash] # @return [Tinybucket::Model::Page] def list( = {}) list = get_path(path_to_list, , get_parser(:collection, Tinybucket::Model::Comment)) associate_with_target(list) list end # Send 'GET a individual comment' request. # # This method send different request depend on 'commented_to' attribute. # # @note When 'commented_to' is {Tinybucket::Model::Commit} instance, # this method send {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bsha%7D/comments/%7Bcomment_id%7D#get # GET an individual commit comment}. # @note When 'commented_to' is {Tinybucket::Model::PullRequest} instance, # this method send {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bsha%7D/comments/%7Bcomment_id%7D#get # GET an individual pull request comment}. # # @param comment_id [String] comment identifier # @param options [Hash] # @return [Tinybucket::Model::Comment] def find(comment_id, = {}) comment = get_path(path_to_find(comment_id), , get_parser(:object, Tinybucket::Model::Comment)) associate_with_target(comment) comment end private def associate_with_target(result) case result when Tinybucket::Model::Comment result.commented_to = commented_to when Tinybucket::Model::Page result.items.map { |m| m.commented_to = commented_to } else raise ArgumentError, "Invalid result: #{result.inspect}" end result end end |
#repo_slug ⇒ String
Returns repository slug.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/tinybucket/api/comments_api.rb', line 13 class CommentsApi < BaseApi include Tinybucket::Api::Helper::CommentsHelper attr_accessor :repo_owner, :repo_slug attr_accessor :commented_to # Send 'GET a list of comments' request. # # This method send different request depend on 'commented_to' attribute. # # @note When 'commented_to' is {Tinybucket::Model::Commit} instance, # this method send {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bsha%7D/comments#get # GET a list of commit comments}. # @note When 'commented_to' is {Tinybucket::Model::PullRequest} instance, # this method send {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bsha%7D/comments#get # GET a list of pull request comments}. # # @param options [Hash] # @return [Tinybucket::Model::Page] def list( = {}) list = get_path(path_to_list, , get_parser(:collection, Tinybucket::Model::Comment)) associate_with_target(list) list end # Send 'GET a individual comment' request. # # This method send different request depend on 'commented_to' attribute. # # @note When 'commented_to' is {Tinybucket::Model::Commit} instance, # this method send {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bsha%7D/comments/%7Bcomment_id%7D#get # GET an individual commit comment}. # @note When 'commented_to' is {Tinybucket::Model::PullRequest} instance, # this method send {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bsha%7D/comments/%7Bcomment_id%7D#get # GET an individual pull request comment}. # # @param comment_id [String] comment identifier # @param options [Hash] # @return [Tinybucket::Model::Comment] def find(comment_id, = {}) comment = get_path(path_to_find(comment_id), , get_parser(:object, Tinybucket::Model::Comment)) associate_with_target(comment) comment end private def associate_with_target(result) case result when Tinybucket::Model::Comment result.commented_to = commented_to when Tinybucket::Model::Page result.items.map { |m| m.commented_to = commented_to } else raise ArgumentError, "Invalid result: #{result.inspect}" end result end end |
Instance Method Details
#find(comment_id, options = {}) ⇒ Tinybucket::Model::Comment
When ‘commented_to’ is Model::Commit instance, this method send GET an individual commit comment.
When ‘commented_to’ is Model::PullRequest instance, this method send GET an individual pull request comment.
Send ‘GET a individual comment’ request.
This method send different request depend on ‘commented_to’ attribute.
56 57 58 59 60 61 62 63 |
# File 'lib/tinybucket/api/comments_api.rb', line 56 def find(comment_id, = {}) comment = get_path(path_to_find(comment_id), , get_parser(:object, Tinybucket::Model::Comment)) associate_with_target(comment) comment end |
#list(options = {}) ⇒ Tinybucket::Model::Page
When ‘commented_to’ is Model::Commit instance, this method send GET a list of commit comments.
When ‘commented_to’ is Model::PullRequest instance, this method send GET a list of pull request comments.
Send ‘GET a list of comments’ request.
This method send different request depend on ‘commented_to’ attribute.
33 34 35 36 37 38 39 40 |
# File 'lib/tinybucket/api/comments_api.rb', line 33 def list( = {}) list = get_path(path_to_list, , get_parser(:collection, Tinybucket::Model::Comment)) associate_with_target(list) list end |