Class: BulkImports::Common::Extractors::RestExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/bulk_imports/common/extractors/rest_extractor.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RestExtractor

Returns a new instance of RestExtractor.



7
8
9
# File 'lib/bulk_imports/common/extractors/rest_extractor.rb', line 7

def initialize(options = {})
  @query = options[:query]
end

Instance Method Details

#extract(context) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/bulk_imports/common/extractors/rest_extractor.rb', line 11

def extract(context)
  client = http_client(context.configuration)
  params = query.to_h(context)
  response = client.get(params[:resource], params[:query])

  BulkImports::Pipeline::ExtractedData.new(
    data: response.parsed_response,
    page_info: page_info(response.headers)
  )
end