2021-01-29 00:20:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module BulkImports
|
|
|
|
module Groups
|
|
|
|
module Extractors
|
|
|
|
class SubgroupsExtractor
|
|
|
|
def extract(context)
|
|
|
|
encoded_parent_path = ERB::Util.url_encode(context.entity.source_full_path)
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
response = http_client(context.configuration)
|
2021-01-29 00:20:46 +05:30
|
|
|
.each_page(:get, "groups/#{encoded_parent_path}/subgroups")
|
|
|
|
.flat_map(&:itself)
|
2021-03-11 19:13:27 +05:30
|
|
|
|
|
|
|
BulkImports::Pipeline::ExtractedData.new(data: response)
|
2021-01-29 00:20:46 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def http_client(configuration)
|
2021-09-04 01:27:46 +05:30
|
|
|
@http_client ||= BulkImports::Clients::HTTP.new(
|
2021-09-30 23:02:18 +05:30
|
|
|
url: configuration.url,
|
2021-01-29 00:20:46 +05:30
|
|
|
token: configuration.access_token,
|
|
|
|
per_page: 100
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|