class Tinybucket::Api::PullRequestsApi

PullRequests Api client

@see developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pullrequests

pullrequests Resource

@!attribute [rw] repo_owner

@return [String] repository owner name.

@!attribute [rw] repo_slug

@return [String] {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D repository slug}.

Attributes

repo_owner[RW]
repo_slug[RW]

Public Instance Methods

approve(pr_id, options = {}) click to toggle source

Send 'POST a pull request approval' request

@note This method return true if this pull request already approved.

@param pr_id [String] The pull request identifier @param options [Hash] @return [true, false]

# File lib/tinybucket/api/pull_requests_api.rb, line 86
def approve(pr_id, options = {})
  result = post_path(path_to_approve(pr_id), options)
  (result['approved'] == true)
rescue Tinybucket::Error::Conflict => e
  logger.debug 'Already approved: ' + e.inspect
  true
end
commits(pr_id, options = {}) click to toggle source

Send 'GET the commits for a pull request' request

@param pr_id [String] The pull request identifier @param options [Hash] @return [Tinybucket::Model::PullRequest]

# File lib/tinybucket/api/pull_requests_api.rb, line 71
def commits(pr_id, options = {})
  get_path(
    path_to_commits(pr_id),
    options,
    get_parser(:collection, Tinybucket::Model::Commit)
  )
end
create(attrs) click to toggle source

Send 'POST a specific pull request' request

@param attrs [Hash] @return [true]

# File lib/tinybucket/api/pull_requests_api.rb, line 35
def create(attrs)
  post_path(
    path_to_create,
    attrs,
    get_parser(:object, Tinybucket::Model::PullRequest)
  )
end
decline(pr_id, options = {}) click to toggle source

Send 'Decline or reject a pull request' request

@param pr_id [String] The pull request identifier @param options [Hash] @return [true, false]

# File lib/tinybucket/api/pull_requests_api.rb, line 114
def decline(pr_id, options = {})
  result = post_path(path_to_decline(pr_id), options)
  (result['state'] == 'DECLINED')
end
diff(pr_id, options = {}) click to toggle source

Send 'GET the diff for a pull request' request

@param pr_id [String] The pull request identifier @param options [Hash] @return [String] diff as raw text.

# File lib/tinybucket/api/pull_requests_api.rb, line 134
def diff(pr_id, options = {})
  get_path(path_to_diff(pr_id), options)
end
find(pr_id, options = {}) click to toggle source

Send 'GET a specific pull request' request

@param pr_id [String] The pull request identifier @param options [Hash] @return [Tinybucket::Model::PullRequest]

# File lib/tinybucket/api/pull_requests_api.rb, line 58
def find(pr_id, options = {})
  get_path(
    path_to_find(pr_id),
    options,
    get_parser(:object, Tinybucket::Model::PullRequest)
  )
end
list(options = {}) click to toggle source

Send 'GET a list of open pull requests' request

@param options [Hash] @return [Tinybucket::Model::Page]

# File lib/tinybucket/api/pull_requests_api.rb, line 23
def list(options = {})
  get_path(
    path_to_list,
    options,
    get_parser(:collection, Tinybucket::Model::PullRequest)
  )
end
merge(pr_id, options = {}) click to toggle source

Send 'Accept and merge a pull request' request

@param pr_id [String] The pull request identifier @param options [Hash] @return [true, false]

# File lib/tinybucket/api/pull_requests_api.rb, line 124
def merge(pr_id, options = {})
  result = post_path(path_to_merge(pr_id), options)
  (result['state'] == 'MERGED')
end
unapprove(pr_id, options = {}) click to toggle source

Send 'DELETE a pull request approval' request

@note This method return true if this pull request is not approved yet.

@param pr_id [String] The pull request identifier @param options [Hash] @return [true]

# File lib/tinybucket/api/pull_requests_api.rb, line 101
def unapprove(pr_id, options = {})
  delete_path(path_to_approve(pr_id), options)
  true
rescue Tinybucket::Error::NotFound => e
  logger.debug 'Already unapproved: ' + e.inspect
  true
end
update(pr_id, options = {}) click to toggle source

Send 'PUT a specific pull request' request

@param pr_id [String] The pull request identifier @param options [Hash] @return [true]

# File lib/tinybucket/api/pull_requests_api.rb, line 48
def update(pr_id, options = {})
  put_path(path_to_update(pr_id), options)
  true
end