Class: Gitlab::GithubImport::Representation::PullRequestReview
- Inherits:
-
Object
- Object
- Gitlab::GithubImport::Representation::PullRequestReview
- Includes:
- Representable
- Defined in:
- lib/gitlab/github_import/representation/pull_request_review.rb
Class Method Summary collapse
-
.from_api_response(review, additional_data = {}) ⇒ Object
Builds a PullRequestReview from a GitHub API response.
-
.from_json_hash(raw_hash) ⇒ Object
Builds a new note using a Hash that was built from a JSON payload.
Instance Method Summary collapse
- #approval? ⇒ Boolean
- #github_identifiers ⇒ Object
-
#initialize(attributes) ⇒ PullRequestReview
constructor
attributes - A Hash containing the raw note details.
Constructor Details
#initialize(attributes) ⇒ PullRequestReview
attributes - A Hash containing the raw note details. The keys of this
Hash must be Symbols.
40 41 42 |
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 40 def initialize(attributes) @attributes = attributes end |
Class Method Details
.from_api_response(review, additional_data = {}) ⇒ Object
Builds a PullRequestReview from a GitHub API response.
review - An instance of Hash containing the note details.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 14 def self.from_api_response(review, additional_data = {}) user = Representation::User.from_api_response(review[:user]) if review[:user] new( merge_request_id: review[:merge_request_id], merge_request_iid: review[:merge_request_iid], author: user, note: review[:body], review_type: review[:state], submitted_at: review[:submitted_at], review_id: review[:id] ) end |
.from_json_hash(raw_hash) ⇒ Object
Builds a new note using a Hash that was built from a JSON payload.
29 30 31 32 33 34 35 36 |
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 29 def self.from_json_hash(raw_hash) hash = Representation.symbolize_hash(raw_hash) hash[:author] &&= Representation::User.from_json_hash(hash[:author]) hash[:submitted_at] = Time.parse(hash[:submitted_at]).in_time_zone if hash[:submitted_at].present? new(hash) end |
Instance Method Details
#approval? ⇒ Boolean
44 45 46 |
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 44 def approval? review_type == 'APPROVED' end |
#github_identifiers ⇒ Object
48 49 50 51 52 53 |
# File 'lib/gitlab/github_import/representation/pull_request_review.rb', line 48 def github_identifiers { merge_request_iid: merge_request_iid, review_id: review_id } end |