cover_my_meds 2.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d57fb40d0155b2f86d8fe746f311a89c15bceaa
4
- data.tar.gz: 2a9b70d8072b0820304c2d700f811b9265b7ad7a
3
+ metadata.gz: ab2c4a5403a14c4c6e3d376f164c9c12a967096a
4
+ data.tar.gz: 31afd606a40608f3f4ada82f631843604b31b395
5
5
  SHA512:
6
- metadata.gz: b2bb8098036e6a170a955f7ae6fd18e89468fd7fa98fc6fa4240d81162c6d0f1b9fabb0b1242a842385db3c2467f2dbb1c19c84d0d4b0507de4da63230191808
7
- data.tar.gz: 6bebc3febe32329bc623f43cda9311c02335bac3ec23c492251959ecf5d73a3fc22b7b961f155c552749a6fd5cf7df75fbe9c60e306d0a324c8daf8941dc17e1
6
+ metadata.gz: 4527b7f965c94cdcecf5b5108506b56de655807916395597a63dd6cfbee1504980743aaa857468d49cf7f6e9942e777cf47b56acaa897ef45bfd9de315e62de3
7
+ data.tar.gz: 4b2da155c780055ba5c86e40700c76e32126c5665c9da24c96d3d371dec9ca0a59a2fbc53a28faddc01dfda2cc45b3e102a31c0cd0e8eaa5a1fe609a0db6f261
data/.gitignore CHANGED
@@ -25,3 +25,4 @@ quickfix.out
25
25
 
26
26
  # to keep out api keys and secrets
27
27
  spec/support/cassettes/**
28
+ /vendor
@@ -21,15 +21,16 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler"
22
22
  spec.add_development_dependency "rspec", ">= 3.2"
23
23
  spec.add_development_dependency "rspec-junklet", ">= 2.0"
24
- spec.add_development_dependency "webmock", "~> 1.11"
24
+ spec.add_development_dependency "webmock", "~> 2.0"
25
25
  spec.add_development_dependency "rake"
26
26
  spec.add_development_dependency "pry"
27
27
  spec.add_development_dependency "dotenv"
28
28
  spec.add_development_dependency "simplecov"
29
29
  spec.add_development_dependency "railties"
30
30
 
31
- spec.add_runtime_dependency "rest-client", "~> 1.8"
31
+ spec.add_runtime_dependency "faraday", "~> 0.9"
32
+ spec.add_runtime_dependency "typhoeus"
33
+ spec.add_runtime_dependency "mime-types"
32
34
  spec.add_runtime_dependency "hashie", ">= 3.4.0"
33
- spec.add_runtime_dependency "settingslogic"
34
35
  spec.add_runtime_dependency "activesupport"
35
36
  end
@@ -1,30 +1,43 @@
1
- require 'rest-client'
1
+ require 'faraday'
2
+ require 'typhoeus'
3
+ require 'typhoeus/adapters/faraday'
2
4
  require 'json'
3
5
  require 'hashie'
4
6
  require 'active_support/core_ext/object/to_param'
5
7
  require 'active_support/core_ext/object/to_query'
6
8
  require 'cover_my_meds/error'
9
+ require 'mime-types'
10
+
7
11
 
8
12
  module CoverMyMeds
9
13
  module ApiRequest
14
+ DEFAULT_TIMEOUT = 60 #seconds, matches Net::Http's default which rest-client used
10
15
 
11
16
  def request(http_method, host, path, params={}, auth_type = :basic, &block)
12
17
  params = params.symbolize_keys
13
18
  headers = params.delete(:headers) || {}
14
19
 
15
- tail = case auth_type
16
- when :basic
17
- { user: @username, password: @password, headers: headers }
18
- when :bearer
19
- { headers: { "Authorization" => "Bearer #{@username}+#{params.delete(:token_id)}" }.merge(headers) }
20
- else
21
- {}
20
+ conn = Faraday.new host do |faraday|
21
+ faraday.request :multipart
22
+ faraday.request :url_encoded
23
+ faraday.adapter :typhoeus
24
+ end
25
+ case auth_type
26
+ when :basic
27
+ conn.basic_auth @username, @password
28
+ when :bearer
29
+ conn.authorization :Bearer, "#{@username}+#{params.delete(:token_id)}"
22
30
  end
23
31
 
24
- uri = api_uri(host, path, params)
25
- rest_resource = RestClient::Resource.new(uri.to_s, tail)
32
+ response = conn.send http_method do |request|
33
+ request.url path
34
+ request.options.timeout = DEFAULT_TIMEOUT
35
+ request.params = params
36
+ request.headers.merge! headers
37
+ request.body = block_given? ? yield : {}
38
+ end
39
+ raise Error::HTTPError.new(response.status, response.body, http_method, conn) unless response.success?
26
40
 
27
- response = call_api http_method, rest_resource, &block
28
41
  parse_response response
29
42
  end
30
43
 
@@ -34,19 +47,5 @@ module CoverMyMeds
34
47
  rescue JSON::ParserError
35
48
  response.body
36
49
  end
37
-
38
- def call_api http_method, rest_resource
39
- body = block_given? ? yield : {}
40
- rest_resource.send http_method, body
41
- rescue RestClient::Exception => e
42
- raise Error::HTTPError.new(e.http_code, e.http_body, http_method, rest_resource)
43
- end
44
-
45
- def api_uri host, path, params
46
- URI.parse(host).tap do |uri|
47
- uri.path = path
48
- uri.query = params.to_param
49
- end
50
- end
51
50
  end
52
51
  end
@@ -6,7 +6,7 @@ module CoverMyMeds
6
6
 
7
7
  def post_indicators(prescription: prescription(), patient: patient(), payer: {}, prescriber: {}, version: CURRENT_VERSION)
8
8
  params = { prescription: prescription, prescriber: prescriber, patient: patient, payer: payer }
9
- data = indicators_request POST, params: { v: version, headers: { content_type: :json } } do
9
+ data = indicators_request POST, params: { v: version, headers: { content_type: "application/json" } } do
10
10
  params.to_json
11
11
  end
12
12
  Hashie::Mash.new(data)
@@ -14,7 +14,7 @@ module CoverMyMeds
14
14
 
15
15
  def search_indicators(prescriptions: prescriptions(), patient: {}, payer: {}, prescriber: {}, version: CURRENT_VERSION)
16
16
  params = { prescriptions: Array(prescriptions), prescriber: prescriber, patient: patient, payer: payer }
17
- data = indicators_request POST, path: 'search/', params: { v: version, headers: { content_type: :json } } do
17
+ data = indicators_request POST, path: 'search/', params: { v: version, headers: { content_type: "application/json" } } do
18
18
  params.to_json
19
19
  end
20
20
  Hashie::Mash.new(data)
@@ -1,3 +1,3 @@
1
1
  module CoverMyMeds
2
- VERSION = "2.1.0"
2
+ VERSION = "3.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cover_my_meds
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Rolston
@@ -23,7 +23,7 @@ authors:
23
23
  autorequire:
24
24
  bindir: exe
25
25
  cert_chain: []
26
- date: 2016-10-06 00:00:00.000000000 Z
26
+ date: 2016-10-19 00:00:00.000000000 Z
27
27
  dependencies:
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: bundler
@@ -73,14 +73,14 @@ dependencies:
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '1.11'
76
+ version: '2.0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '1.11'
83
+ version: '2.0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rake
86
86
  requirement: !ruby/object:Gem::Requirement
@@ -152,35 +152,35 @@ dependencies:
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  - !ruby/object:Gem::Dependency
155
- name: rest-client
155
+ name: faraday
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
158
  - - "~>"
159
159
  - !ruby/object:Gem::Version
160
- version: '1.8'
160
+ version: '0.9'
161
161
  type: :runtime
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
165
  - - "~>"
166
166
  - !ruby/object:Gem::Version
167
- version: '1.8'
167
+ version: '0.9'
168
168
  - !ruby/object:Gem::Dependency
169
- name: hashie
169
+ name: typhoeus
170
170
  requirement: !ruby/object:Gem::Requirement
171
171
  requirements:
172
172
  - - ">="
173
173
  - !ruby/object:Gem::Version
174
- version: 3.4.0
174
+ version: '0'
175
175
  type: :runtime
176
176
  prerelease: false
177
177
  version_requirements: !ruby/object:Gem::Requirement
178
178
  requirements:
179
179
  - - ">="
180
180
  - !ruby/object:Gem::Version
181
- version: 3.4.0
181
+ version: '0'
182
182
  - !ruby/object:Gem::Dependency
183
- name: settingslogic
183
+ name: mime-types
184
184
  requirement: !ruby/object:Gem::Requirement
185
185
  requirements:
186
186
  - - ">="
@@ -193,6 +193,20 @@ dependencies:
193
193
  - - ">="
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
+ - !ruby/object:Gem::Dependency
197
+ name: hashie
198
+ requirement: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: 3.4.0
203
+ type: :runtime
204
+ prerelease: false
205
+ version_requirements: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: 3.4.0
196
210
  - !ruby/object:Gem::Dependency
197
211
  name: activesupport
198
212
  requirement: !ruby/object:Gem::Requirement
@@ -271,8 +285,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
285
  version: '0'
272
286
  requirements: []
273
287
  rubyforge_project:
274
- rubygems_version: 2.4.5.1
288
+ rubygems_version: 2.4.6
275
289
  signing_key:
276
290
  specification_version: 4
277
291
  summary: CoverMyMeds Public API
278
292
  test_files: []
293
+ has_rdoc: