class DataScope::OnDemandExtract
Attributes
location[RW]
result[R]
status[RW]
Public Class Methods
init_with_location(session, location)
click to toggle source
# File lib/data_scope_api.rb, line 82 def self.init_with_location(session, location) ins = self.new(session) ins.status = :in_progress ins.location = location ins end
new(session, identifiers=nil, type=nil, fields=nil, condition=nil)
click to toggle source
# File lib/data_scope_api.rb, line 89 def initialize(session, identifiers=nil, type=nil, fields=nil, condition=nil) @session = session @status = :init path = "/RestApi/v1/Extractions/ExtractWithNotes" if fields options = { headers: { "Prefer" => "respond-async; wait=5", "Content-Type" => "application/json; odata=minimalmetadata", "Authorization" => "Token #{@session.token}" }, body: { "ExtractionRequest" => { "@odata.type" => "#{camelize(type)}ExtractionRequest", "ContentFieldNames" => fields, "IdentifierList" => { "@odata.type" => "InstrumentIdentifierList", "InstrumentIdentifiers" => identifiers, "ValidationOptions" => nil, "UseUserPreferencesForValidationOptions" => false }, "Condition" => condition } }.to_json } if session.configured? resp = self.class.post path, options process_response(resp) @session.logger.debug resp else session.not_configured_error end end end
Public Instance Methods
camelize(str)
click to toggle source
# File lib/data_scope_api.rb, line 78 def camelize(str) str.to_s.split('_').collect(&:capitalize).join end
get_result()
click to toggle source
# File lib/data_scope_api.rb, line 136 def get_result if @status == :in_progress options = { headers: { "Prefer" => "respond-async; wait=5", "Authorization" => "Token #{@session.token}" } } if @session.configured? resp = self.class.get @location, options process_response(resp) @session.logger.debug @result @status else @session.not_configured_error end end end
process_response(resp)
click to toggle source
# File lib/data_scope_api.rb, line 125 def process_response(resp) @location = resp["location"] @result = resp @status = case resp["status"] when "InProgress" :in_progress else :completed end end