2016-08-22 15:15:15 -04:00
|
|
|
module Bitbucket
|
|
|
|
module Representation
|
|
|
|
class PullRequest < Representation::Base
|
2016-08-22 15:15:39 -04:00
|
|
|
def author
|
2016-12-16 16:51:40 -05:00
|
|
|
raw.fetch('author', {}).fetch('username', nil)
|
2016-08-22 15:15:39 -04:00
|
|
|
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['created_on']
|
|
|
|
end
|
|
|
|
|
|
|
|
def updated_at
|
|
|
|
raw['updated_on']
|
|
|
|
end
|
|
|
|
|
|
|
|
def title
|
|
|
|
raw['title']
|
|
|
|
end
|
|
|
|
|
|
|
|
def source_branch_name
|
2016-12-16 16:51:40 -05:00
|
|
|
source_branch.fetch('branch', {}).fetch('name', nil)
|
2016-08-22 15:15:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def source_branch_sha
|
2016-12-16 16:51:40 -05:00
|
|
|
source_branch.fetch('commit', {}).fetch('hash', nil)
|
2016-08-22 15:15:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def target_branch_name
|
2016-12-16 16:51:40 -05:00
|
|
|
target_branch.fetch('branch', {}).fetch('name', nil)
|
2016-08-22 15:15:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def target_branch_sha
|
2016-12-16 16:51:40 -05:00
|
|
|
target_branch.fetch('commit', {}).fetch('hash', nil)
|
2016-08-22 15:15:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def source_branch
|
|
|
|
raw['source']
|
|
|
|
end
|
|
|
|
|
|
|
|
def target_branch
|
|
|
|
raw['destination']
|
|
|
|
end
|
2016-08-22 15:15:15 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|