Class: DataScope::OnDemandExtract
- Inherits:
-
Object
- Object
- DataScope::OnDemandExtract
- Includes:
- HTTParty
- Defined in:
- lib/data_scope_api.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
Returns the value of attribute location.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #camelize(str) ⇒ Object
- #get_result ⇒ Object
-
#initialize(session, identifiers = nil, type = nil, fields = nil, condition = nil) ⇒ OnDemandExtract
constructor
A new instance of OnDemandExtract.
- #process_response(resp) ⇒ Object
Constructor Details
#initialize(session, identifiers = nil, type = nil, fields = nil, condition = nil) ⇒ OnDemandExtract
Returns a new instance of OnDemandExtract.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# 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 = { 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, process_response(resp) @session.logger.debug resp else session.not_configured_error end end end |
Instance Attribute Details
#location ⇒ Object
Returns the value of attribute location.
76 77 78 |
# File 'lib/data_scope_api.rb', line 76 def location @location end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
75 76 77 |
# File 'lib/data_scope_api.rb', line 75 def result @result end |
#status ⇒ Object
Returns the value of attribute status.
76 77 78 |
# File 'lib/data_scope_api.rb', line 76 def status @status end |
Class Method Details
.init_with_location(session, location) ⇒ Object
82 83 84 85 86 87 |
# 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 |
Instance Method Details
#camelize(str) ⇒ Object
78 79 80 |
# File 'lib/data_scope_api.rb', line 78 def camelize(str) str.to_s.split('_').collect(&:capitalize).join end |
#get_result ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/data_scope_api.rb', line 136 def get_result if @status == :in_progress = { headers: { "Prefer" => "respond-async; wait=5", "Authorization" => "Token #{@session.token}" } } if @session.configured? resp = self.class.get @location, process_response(resp) @session.logger.debug @result @status else @session.not_configured_error end end end |
#process_response(resp) ⇒ Object
125 126 127 128 129 130 131 132 133 134 |
# 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 |