diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 11:33:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 11:33:21 +0000 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /lib/gitlab/github_import/representation/pull_requests/review_requests.rb | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) | |
download | gitlab-ce-7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0.tar.gz |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'lib/gitlab/github_import/representation/pull_requests/review_requests.rb')
-rw-r--r-- | lib/gitlab/github_import/representation/pull_requests/review_requests.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/gitlab/github_import/representation/pull_requests/review_requests.rb b/lib/gitlab/github_import/representation/pull_requests/review_requests.rb new file mode 100644 index 00000000000..692004c4460 --- /dev/null +++ b/lib/gitlab/github_import/representation/pull_requests/review_requests.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +module Gitlab + module GithubImport + module Representation + module PullRequests + class ReviewRequests + include ToHash + include ExposeAttribute + + attr_reader :attributes + + expose_attribute :merge_request_id, :users + + class << self + # Builds a list of requested reviewers from a GitHub API response. + # + # review_requests - An instance of `Hash` containing the review requests details. + def from_api_response(review_requests, _additional_data = {}) + review_requests = Representation.symbolize_hash(review_requests) + users = review_requests[:users].map do |user_data| + Representation::User.from_api_response(user_data) + end + + new( + merge_request_id: review_requests[:merge_request_id], + users: users + ) + end + alias_method :from_json_hash, :from_api_response + end + + # attributes - A Hash containing the review details. The keys of this + # Hash (and any nested hashes) must be symbols. + def initialize(attributes) + @attributes = attributes + end + + def github_identifiers + { merge_request_id: merge_request_id } + end + end + end + end + end +end |