gitlab-org--gitlab-foss/lib/bitbucket_server/representation/pull_request.rb

66 lines
1 KiB
Ruby
Raw Normal View History

module BitbucketServer
module Representation
class PullRequest < Representation::Base
def author
raw.fetch('author', {}).fetch('user', {}).fetch('name')
end
def description
raw['description']
end
def iid
raw['id']
end
def state
if raw['state'] == 'MERGED'
'merged'
elsif raw['state'] == 'DECLINED'
'closed'
else
'opened'
end
end
def created_at
raw['createdDate']
end
def updated_at
raw['updatedDate']
end
def title
raw['title']
end
def source_branch_name
source_branch['id']
end
def source_branch_sha
# XXX Not implemented?
end
def target_branch_name
target_branch['id']
end
def target_branch_sha
# XXX Not implemented?
end
private
def source_branch
raw['fromRef'] || {}
end
def target_branch
raw['toRef'] || {}
end
end
end
end