ihealth 2.2.2 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ihealth.rb +38 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 626f890de4d411637b330158b9de88320790dbc0
|
4
|
+
data.tar.gz: f0cf697ac48a5ff09e08c43c672f77a167c82841
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adf11e9e352de91de5eb783f1e973d671159728a22787391d63d1f5ee1e3c38dc6d02e4aa8ef9e73abb289dc0f905bb7109714af6cb2ecf0b5de60decf2d36e5
|
7
|
+
data.tar.gz: eeab40c65e138815e6a807e54e5624ec1d961a1b402fac28e1dfc005c70ababe45782bf57cdcb286cadfaebe8602e23ce1a59698f1dbe30695fa46e17674aaf5
|
data/lib/ihealth.rb
CHANGED
@@ -189,6 +189,44 @@ class Ihealth
|
|
189
189
|
# response.code != "200" ? (return nil) : (return response.body)
|
190
190
|
# end
|
191
191
|
|
192
|
+
def get_file_list qid, format = "json"
|
193
|
+
authenticate if !@authenticated
|
194
|
+
url = URI("#{@IHEALTHBASE}qkviews/#{qid}/files.#{format}")
|
195
|
+
headers = {'User Agent' => USER_AGENT, 'Cookie' => @cookies }
|
196
|
+
@proxyserver.nil? ? (ihealthclient = Net::HTTP::new(url.host, url.port)) : (ihealthclient = Net::HTTP::new(url.host, url.port,@proxyserver, @proxyport, @proxyuser, @proxypass))
|
197
|
+
ihealthclient.use_ssl = true
|
198
|
+
ihealthclient.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
199
|
+
httprequest = Net::HTTP::Get.new(url.path, headers)
|
200
|
+
httprequest.content_type = 'application/text'
|
201
|
+
response = ihealthclient.start do |http|
|
202
|
+
http.request(httprequest)
|
203
|
+
end
|
204
|
+
response.code != "200" ? (return nil) : (return response.body)
|
205
|
+
end
|
206
|
+
|
207
|
+
def get_file qid, fileid, location
|
208
|
+
authenticate if !@authenticated
|
209
|
+
url = URI("#{@IHEALTHBASE}qkviews/#{qid}/files/#{fileid}")
|
210
|
+
headers = {'User Agent' => USER_AGENT, 'Cookie' => @cookies }
|
211
|
+
@proxyserver.nil? ? (ihealthclient = Net::HTTP::new(url.host, url.port)) : (ihealthclient = Net::HTTP::new(url.host, url.port,@proxyserver, @proxyport, @proxyuser, @proxypass))
|
212
|
+
ihealthclient.use_ssl = true
|
213
|
+
ihealthclient.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
214
|
+
httprequest = Net::HTTP::Get.new(url.path, headers)
|
215
|
+
httprequest.content_type = 'application/octet-stream'
|
216
|
+
response = ihealthclient.start do |http|
|
217
|
+
begin
|
218
|
+
file = open(location,'wb')
|
219
|
+
http.request(httprequest) do |response|
|
220
|
+
response.read_body do |segment|
|
221
|
+
file.write(segment)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
ensure
|
225
|
+
file.close
|
226
|
+
end
|
227
|
+
end
|
228
|
+
response.code != "200" ? (return nil) : (return location)
|
229
|
+
end
|
192
230
|
|
193
231
|
|
194
232
|
# no reason to call authenticate directly
|