summaryrefslogtreecommitdiff
path: root/lib/gitlab/phabricator_import/conduit/user.rb
blob: fc8c3f7cde926cfe099267c7b6b55ab215c72407 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true
module Gitlab
  module PhabricatorImport
    module Conduit
      class User
        MAX_PAGE_SIZE = 100

        def initialize(phabricator_url:, api_token:)
          @client = Client.new(phabricator_url, api_token)
        end

        def users(phids)
          phids.each_slice(MAX_PAGE_SIZE).map { |limited_phids| get_page(limited_phids) }
        end

        private

        def get_page(phids)
          UsersResponse.new(get_users(phids))
        end

        def get_users(phids)
          client.get('user.search',
                     params: { constraints: { phids: phids } })
        end

        attr_reader :client
      end
    end
  end
end