2018-07-25 08:22:53 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-06-25 16:06:10 -04:00
|
|
|
module BitbucketServer
|
|
|
|
module Representation
|
|
|
|
class PullRequest < Representation::Base
|
|
|
|
def author
|
2018-07-21 01:30:28 -04:00
|
|
|
raw.dig('author', 'user', 'name')
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
2018-06-27 17:25:09 -04:00
|
|
|
def author_email
|
2018-07-21 01:30:28 -04:00
|
|
|
raw.dig('author', 'user', 'emailAddress')
|
2018-06-27 17:25:09 -04:00
|
|
|
end
|
|
|
|
|
2018-06-25 16:06:10 -04:00
|
|
|
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
|
|
|
|
|
2018-07-01 08:13:15 -04:00
|
|
|
def merged?
|
|
|
|
state == 'merged'
|
|
|
|
end
|
|
|
|
|
2018-06-25 16:06:10 -04:00
|
|
|
def created_at
|
2018-07-21 01:30:28 -04:00
|
|
|
Time.at(created_date / 1000) if created_date.is_a?(Integer)
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def updated_at
|
2018-07-21 01:30:28 -04:00
|
|
|
Time.at(updated_date / 1000) if created_date.is_a?(Integer)
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def title
|
|
|
|
raw['title']
|
|
|
|
end
|
|
|
|
|
|
|
|
def source_branch_name
|
2018-07-21 01:30:28 -04:00
|
|
|
dig('fromRef', 'id')
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def source_branch_sha
|
2018-07-21 01:30:28 -04:00
|
|
|
dig('fromRef', 'latestCommit')
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def target_branch_name
|
2018-07-21 01:30:28 -04:00
|
|
|
dig('toRef', 'id')
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def target_branch_sha
|
2018-07-21 01:30:28 -04:00
|
|
|
dig('toRef', 'latestCommit')
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-07-21 01:30:28 -04:00
|
|
|
def created_date
|
|
|
|
raw['createdDate']
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
2018-07-21 01:30:28 -04:00
|
|
|
def updated_date
|
|
|
|
raw['updatedDate']
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|