fhir_client 1.6.8 → 1.6.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12367a6e525d762523753593264ba095cd3ba579
4
- data.tar.gz: 693ef7d5a3c56d599d38fb1c1f28fc848a4e1d7b
3
+ metadata.gz: dd3ac124307f2b5ff1a87964f9f54c88769a0d49
4
+ data.tar.gz: be404fc27a3ea4556eadd151eb4e8c15a7fa8cb1
5
5
  SHA512:
6
- metadata.gz: 0291e7fd065516d8c9ec4d139c1728b3c808b8a17ea92b7c0a315c80fe6dac0ddb20a1933c68da97a47ee6d0b0300ff2d8fdb55ee5b637b9fc9231de2444df05
7
- data.tar.gz: d41df661d9eef8b2462ba43e9648d4b29845f989e63fae4f6afe01b00833e26245b4e3df0e9d9c3fd43b497cba8ea38c0919f1c5301147decec9e3a586eb949b
6
+ metadata.gz: b3c4aa67026efdad576cf1575564872452c752bb7d510e1c153c240370e8b737d6fbf0484a57308f68a15774ea78b8f99f409630bab6cf76cdb068a6b8d7e233
7
+ data.tar.gz: d3f6971059658d6f9b0dbd53f5dc2d80a0ec4776ed4fa540af38ee7e0c406db7c965c53f46362ed808a719ffd7d74ee9384f71d58a66d3377bb227940e255a44
data/bin/console CHANGED
@@ -7,8 +7,8 @@ require 'fhir_client'
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
9
  # (If you use this, don't forget to add pry to your Gemfile!)
10
- require 'pry'
11
- Pry.start
10
+ # require "pry"
11
+ # Pry.start
12
12
 
13
- # require 'irb'
14
- # IRB.start
13
+ require 'irb'
14
+ IRB.start
@@ -324,17 +324,40 @@ module FHIR
324
324
  headers: response.headers,
325
325
  body: response.body
326
326
  }
327
- FHIR.logger.info "GET - Request: #{req}, Response: #{response.body.force_encoding('UTF-8')}"
327
+ if url.end_with?('/metadata')
328
+ FHIR.logger.info "GET - Request: #{req}, Response: [too large]"
329
+ else
330
+ FHIR.logger.info "GET - Request: #{req}, Response: #{response.body.force_encoding('UTF-8')}"
331
+ end
328
332
  @reply = FHIR::ClientReply.new(req, res)
329
333
  else
330
334
  headers.merge!(@security_headers) if @use_basic_auth
331
335
  begin
332
336
  response = @client.get(url, headers)
337
+ rescue RestClient::SSLCertificateNotVerified => sslerr
338
+ FHIR.logger.error "SSL Error: #{url}"
339
+ req = {
340
+ method: :get,
341
+ url: url,
342
+ path: url.gsub(@base_service_url, ''),
343
+ headers: headers,
344
+ payload: nil
345
+ }
346
+ res = {
347
+ code: nil,
348
+ headers: nil,
349
+ body: sslerr.message
350
+ }
351
+ @reply = FHIR::ClientReply.new(req, res)
352
+ return @reply
333
353
  rescue => e
334
354
  response = e.response if e.response
335
355
  end
336
-
337
- FHIR.logger.info "GET - Request: #{response.request.to_json}, Response: #{response.body.force_encoding('UTF-8')}"
356
+ if url.end_with?('/metadata')
357
+ FHIR.logger.info "GET - Request: #{response.request.to_json}, Response: [too large]"
358
+ else
359
+ FHIR.logger.info "GET - Request: #{response.request.to_json}, Response: #{response.body.force_encoding('UTF-8')}"
360
+ end
338
361
  response.request.args[:path] = response.request.args[:url].gsub(@base_service_url, '')
339
362
  headers = response.headers.each_with_object({}) { |(k, v), h| h[k.to_s.tr('_', '-')] = v.to_s; h }
340
363
  res = {
@@ -376,7 +399,7 @@ module FHIR
376
399
  else
377
400
  headers.merge!(@security_headers) if @use_basic_auth
378
401
  @client.post(url, payload, headers) do |resp, request, result|
379
- FHIR.logger.info "POST - Request: #{request.to_json}, Response: #{resp.force_encoding('UTF-8')}"
402
+ FHIR.logger.info "POST - Request: #{request.to_json}\nResponse:\nResponse Headers: #{scrubbed_response_headers(result.each_key {})} \nResponse Body: #{resp.force_encoding('UTF-8')}"
380
403
  request.args[:path] = url.gsub(@base_service_url, '')
381
404
  res = {
382
405
  code: result.code,
@@ -457,16 +480,30 @@ module FHIR
457
480
  @reply = FHIR::ClientReply.new(req, res)
458
481
  else
459
482
  headers.merge!(@security_headers) if @use_basic_auth
460
- # url = 'http://requestb.in/o8juy3o8'
461
- @client.patch(url, payload, headers) do |resp, request, result|
462
- FHIR.logger.info "PATCH - Request: #{request.to_json}, Response: #{resp.force_encoding('UTF-8')}"
463
- request.args[:path] = url.gsub(@base_service_url, '')
483
+ begin
484
+ @client.patch(url, payload, headers) do |resp, request, result|
485
+ FHIR.logger.info "PATCH - Request: #{request.to_json}, Response: #{resp.force_encoding('UTF-8')}"
486
+ request.args[:path] = url.gsub(@base_service_url, '')
487
+ res = {
488
+ code: result.code,
489
+ headers: scrubbed_response_headers(result.each_key {}),
490
+ body: resp
491
+ }
492
+ @reply = FHIR::ClientReply.new(request.args, res)
493
+ end
494
+ rescue => e
495
+ req = {
496
+ method: :patch,
497
+ url: url,
498
+ path: url.gsub(@base_service_url, ''),
499
+ headers: headers,
500
+ payload: payload
501
+ }
464
502
  res = {
465
- code: result.code,
466
- headers: scrubbed_response_headers(result.each_key {}),
467
- body: resp
503
+ body: e.message
468
504
  }
469
- @reply = FHIR::ClientReply.new(request.args, res)
505
+ FHIR.logger.error "PATCH Error: #{e.message}"
506
+ @reply = FHIR::ClientReply.new(req, res)
470
507
  end
471
508
  end
472
509
  end
@@ -63,7 +63,7 @@ module FHIR
63
63
  handle_response client.conditional_create(model, params)
64
64
  end
65
65
 
66
- def self.all
66
+ def self.all(client = @@client)
67
67
  handle_response client.read_feed(self)
68
68
  end
69
69
 
@@ -1,5 +1,5 @@
1
1
  module FHIR
2
2
  class Client
3
- VERSION = '1.6.8'
3
+ VERSION = '1.6.9'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fhir_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.8
4
+ version: 1.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andre Quina
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2016-10-25 00:00:00.000000000 Z
13
+ date: 2016-10-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -271,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
271
  version: '0'
272
272
  requirements: []
273
273
  rubyforge_project:
274
- rubygems_version: 2.6.6
274
+ rubygems_version: 2.6.7
275
275
  signing_key:
276
276
  specification_version: 4
277
277
  summary: A Gem for handling FHIR client requests in ruby