2018-03-17 18:26:18 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module GithubImport
|
|
|
|
module Representation
|
|
|
|
class User
|
|
|
|
include ToHash
|
|
|
|
include ExposeAttribute
|
|
|
|
|
|
|
|
attr_reader :attributes
|
|
|
|
|
|
|
|
expose_attribute :id, :login
|
|
|
|
|
|
|
|
# Builds a user from a GitHub API response.
|
|
|
|
#
|
2022-11-25 23:54:43 +05:30
|
|
|
# user - An instance of `Hash` containing the user details.
|
2022-08-27 11:52:29 +05:30
|
|
|
def self.from_api_response(user, additional_data = {})
|
2021-06-08 01:23:25 +05:30
|
|
|
new(
|
2022-11-25 23:54:43 +05:30
|
|
|
id: user[:id],
|
|
|
|
login: user[:login]
|
2021-06-08 01:23:25 +05:30
|
|
|
)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
# Builds a user using a Hash that was built from a JSON payload.
|
|
|
|
def self.from_json_hash(raw_hash)
|
|
|
|
new(Representation.symbolize_hash(raw_hash))
|
|
|
|
end
|
|
|
|
|
|
|
|
# attributes - A Hash containing the user details. The keys of this
|
|
|
|
# Hash (and any nested hashes) must be symbols.
|
|
|
|
def initialize(attributes)
|
|
|
|
@attributes = attributes
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|