2021-05-11 15:10:20 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module BulkImports
|
|
|
|
class ExportRequestWorker
|
|
|
|
include ApplicationWorker
|
|
|
|
|
|
|
|
idempotent!
|
|
|
|
worker_has_external_dependencies!
|
|
|
|
feature_category :importers
|
|
|
|
|
|
|
|
GROUP_EXPORTED_URL_PATH = "/groups/%s/export_relations"
|
|
|
|
|
|
|
|
def perform(entity_id)
|
|
|
|
entity = BulkImports::Entity.find(entity_id)
|
|
|
|
|
|
|
|
request_export(entity)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def request_export(entity)
|
|
|
|
http_client(entity.bulk_import.configuration)
|
|
|
|
.post(GROUP_EXPORTED_URL_PATH % entity.encoded_source_full_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
def http_client(configuration)
|
2021-06-11 15:09:58 +00:00
|
|
|
@client ||= Clients::HTTP.new(
|
2021-05-11 15:10:20 +00:00
|
|
|
uri: configuration.url,
|
|
|
|
token: configuration.access_token
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|