eligible 2.8.2 → 2.9.1
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 +4 -4
- data/.codeclimate.yml +3 -9
- data/.gitignore +1 -0
- data/ChangeLog +5 -0
- data/README.md +52 -3
- data/Rakefile +1 -7
- data/circle.yml +15 -0
- data/eligible.gemspec +1 -2
- data/lib/eligible.rb +22 -8
- data/lib/eligible/api_resource.rb +1 -1
- data/lib/eligible/errors/eligible_error.rb +3 -1
- data/lib/eligible/session_token.rb +4 -0
- data/lib/eligible/version.rb +1 -1
- metadata +6 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2a50028978ef5f3a39e998f84ac1e7a80d45696
|
4
|
+
data.tar.gz: 7296fa9ff2ca890a1e3f5464fe190285d0a2f2df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6376bc0fa92857b043ac2da25a9897a34dd5fc51252a980f667277d4226dfe2b51032673fa2261de3c564d78951ce97be213b2916e97027d6742c6894a70947b
|
7
|
+
data.tar.gz: 41c0a0339c6781b82f23f94df810e5fbb159fadece8f3c5beb2d49edfbc36b58a229a571e8b442cd926e616ac13b115d1868482a7651a93a033f4825bfb2b01b
|
data/.codeclimate.yml
CHANGED
@@ -4,9 +4,6 @@ engines:
|
|
4
4
|
config:
|
5
5
|
languages:
|
6
6
|
- ruby
|
7
|
-
- javascript
|
8
|
-
- python
|
9
|
-
- php
|
10
7
|
|
11
8
|
fixme:
|
12
9
|
enabled: true
|
@@ -16,12 +13,9 @@ engines:
|
|
16
13
|
|
17
14
|
ratings:
|
18
15
|
paths:
|
19
|
-
-
|
20
|
-
-
|
21
|
-
- "**.
|
22
|
-
- "**.module"
|
23
|
-
- "**.php"
|
24
|
-
- "**.py"
|
16
|
+
- Gemfile.lock
|
17
|
+
- Rakefile
|
18
|
+
- "**.rake"
|
25
19
|
- "**.rb"
|
26
20
|
|
27
21
|
exclude_paths:
|
data/.gitignore
CHANGED
data/ChangeLog
CHANGED
data/README.md
CHANGED
@@ -90,7 +90,7 @@ the parameter `service_type`, required on the api calls, is provided
|
|
90
90
|
by Eligible from its website, in xml and json format, which you can
|
91
91
|
embed into your applications.
|
92
92
|
|
93
|
-
[https://eligible.com/resources/service-codes.xml](https://eligible.com/resources/service-codes.xml)
|
93
|
+
[https://eligible.com/resources/service-codes.xml](https://eligible.com/resources/service-codes.xml)
|
94
94
|
[https://eligible.com/resources/service-codes.json](ttps://eligible.com/resources/service-codes.json)
|
95
95
|
|
96
96
|
## Place of Service
|
@@ -450,7 +450,7 @@ Eligible::Ticket.all
|
|
450
450
|
### Create a customer
|
451
451
|
|
452
452
|
```ruby
|
453
|
-
customer_params = { customer: { name: "ABC company",
|
453
|
+
customer_params = { customer: { name: "ABC company",
|
454
454
|
site_name: "ABC site name"
|
455
455
|
}
|
456
456
|
}
|
@@ -579,7 +579,7 @@ response.to_hash
|
|
579
579
|
params = { payer_id: '12345' }
|
580
580
|
response = Eligible::Payer.search_options(params)
|
581
581
|
response.to_hash
|
582
|
-
```
|
582
|
+
```
|
583
583
|
|
584
584
|
### Search options for all payers
|
585
585
|
|
@@ -648,6 +648,33 @@ response = Eligible::Referral.create(params)
|
|
648
648
|
response.to_hash
|
649
649
|
```
|
650
650
|
|
651
|
+
## Session Tokens
|
652
|
+
|
653
|
+
### Reference
|
654
|
+
[https://account.eligible.com/docs/account#session-tokens](https://account.eligible.com/docs/account#session-tokens)
|
655
|
+
|
656
|
+
### Retrieve session token
|
657
|
+
|
658
|
+
```ruby
|
659
|
+
params = { endpoints: 'coverage, cost_estimates, visit_types, payer_list',
|
660
|
+
ttl_seconds: 300,
|
661
|
+
max_calls: 50
|
662
|
+
}
|
663
|
+
result = Eligible::SessionToken.create(params)
|
664
|
+
result.to_hash # returns all session token info for the request
|
665
|
+
result.error # returns error, if any
|
666
|
+
```
|
667
|
+
|
668
|
+
### Revoke session token
|
669
|
+
|
670
|
+
```ruby
|
671
|
+
params = { session_token: 'session-token-to-revoke' }
|
672
|
+
result = Eligible::SessionToken.revoke(params)
|
673
|
+
result.to_hash # returns all session token info for the request
|
674
|
+
result.error # returns error, if any
|
675
|
+
```
|
676
|
+
|
677
|
+
|
651
678
|
## Errors
|
652
679
|
|
653
680
|
This is the list of errors thrown from the eligible ruby gem.
|
@@ -660,6 +687,28 @@ This is the list of errors thrown from the eligible ruby gem.
|
|
660
687
|
6. NotImplementedError - Raised when the functionality you are trying to use doesn't exist.
|
661
688
|
7. ArgumentError - Raised when all the required params are not provided.
|
662
689
|
|
690
|
+
### Error Handling
|
691
|
+
|
692
|
+
Raised errors have details in `message`, `http_code`, `http_body`, `json_body`, and `errors` attributes:
|
693
|
+
|
694
|
+
```ruby
|
695
|
+
def call_eligible(request_params)
|
696
|
+
Eligible::Coverage.cost_estimate request_params
|
697
|
+
rescue Eligible::AuthenticationError => auth_error # handle any specific error
|
698
|
+
auth_error.message # readable message
|
699
|
+
auth_error.http_status # HTTP Status Code
|
700
|
+
auth_error.http_body # HTTP Response body
|
701
|
+
auth_error.json_body # HTTP Response body as Hash
|
702
|
+
auth_error.errors # Errors from Response Hash
|
703
|
+
rescue Eligible::EligibleError => error # handle generic error
|
704
|
+
## Similar format
|
705
|
+
error.message
|
706
|
+
error.http_status
|
707
|
+
error.http_body
|
708
|
+
error.json_body
|
709
|
+
error.errors
|
710
|
+
end
|
711
|
+
```
|
663
712
|
|
664
713
|
## Contributing
|
665
714
|
|
data/Rakefile
CHANGED
@@ -5,13 +5,7 @@ require 'rspec/core/rake_task'
|
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
|
9
|
-
RuboCop::RakeTask.new(:rubocop) do |task|
|
10
|
-
task.patterns = ['lib/**/*.rb']
|
11
|
-
task.fail_on_error = false
|
12
|
-
end
|
13
|
-
|
14
|
-
task default: [:rubocop, :spec]
|
8
|
+
task default: [:spec]
|
15
9
|
|
16
10
|
desc 'Runs code coverage'
|
17
11
|
task :rcov do
|
data/circle.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
machine:
|
2
|
+
environment:
|
3
|
+
CC_TEST_REPORTER_ID: 1a814ffba15f437df919868f6c26f3c6ac111338b88f9a9d7e2b3030598bccdd
|
4
|
+
|
5
|
+
dependencies:
|
6
|
+
post:
|
7
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
8
|
+
- chmod +x ./cc-test-reporter
|
9
|
+
|
10
|
+
test:
|
11
|
+
pre:
|
12
|
+
- ./cc-test-reporter before-build
|
13
|
+
|
14
|
+
post:
|
15
|
+
- ./cc-test-reporter after-build --exit-code $EXIT_CODE --coverage-input-type simplecov
|
data/eligible.gemspec
CHANGED
@@ -19,8 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_dependency('rest-client', '~> 2.0.0')
|
20
20
|
gem.add_dependency('multi_json', '~> 1.7')
|
21
21
|
|
22
|
-
gem.add_development_dependency('rake', '~>
|
22
|
+
gem.add_development_dependency('rake', '~> 12.0')
|
23
23
|
gem.add_development_dependency('rspec', '~> 3.4')
|
24
|
-
gem.add_development_dependency('rubocop', '= 0.35.0')
|
25
24
|
gem.add_development_dependency('simplecov', '~> 0.11')
|
26
25
|
end
|
data/lib/eligible.rb
CHANGED
@@ -45,9 +45,8 @@ module Eligible
|
|
45
45
|
@@test = false
|
46
46
|
@@api_version = '1.5'
|
47
47
|
@@api_base = "https://gds.eligibleapi.com/v#{@@api_version}"
|
48
|
-
@@fingerprints = %w(
|
49
|
-
|
50
|
-
de4cdd0aae26df71290f0373af18e9ee7ecff18c)
|
48
|
+
@@fingerprints = %w(de4cdd0aae26df71290f0373af18e9ee7ecff18c
|
49
|
+
9df5f186fb20ad25ffd864942a6394840b02a480)
|
51
50
|
|
52
51
|
def self.api_url(url = '')
|
53
52
|
@@api_base + url.to_s
|
@@ -235,7 +234,21 @@ module Eligible
|
|
235
234
|
RestClient::Request.execute(opts)
|
236
235
|
end
|
237
236
|
|
238
|
-
def self.error_message(error)
|
237
|
+
def self.error_message(error, errors)
|
238
|
+
message = compose_message_from_errors(errors)
|
239
|
+
return message if message
|
240
|
+
|
241
|
+
return compose_message_from_error(error)
|
242
|
+
end
|
243
|
+
|
244
|
+
def self.compose_message_from_errors(errors)
|
245
|
+
return unless errors.is_a?(Array)
|
246
|
+
|
247
|
+
return errors.first[:message] if errors.size == 1
|
248
|
+
return errors.each_with_index.map { |error, index| "#{index + 1}. #{error[:message]}" }.join("\n")
|
249
|
+
end
|
250
|
+
|
251
|
+
def self.compose_message_from_error(error)
|
239
252
|
return error.to_s unless error.is_a?(Hash)
|
240
253
|
result = error[:details] || error[:reject_reason_description] || error
|
241
254
|
return result.to_s
|
@@ -243,15 +256,16 @@ module Eligible
|
|
243
256
|
|
244
257
|
def self.handle_api_error(rcode, rbody)
|
245
258
|
begin
|
246
|
-
error_obj = Eligible::JSON.load(rbody)
|
247
|
-
error_obj
|
248
|
-
fail EligibleError unless error_obj.key?(:error)
|
259
|
+
error_obj = Util.symbolize_names(Eligible::JSON.load(rbody))
|
260
|
+
fail EligibleError unless error_obj.keys.any? { |k| [:error, :errors].include? k }
|
249
261
|
error = error_obj[:error]
|
262
|
+
errors = error_obj[:errors]
|
263
|
+
|
250
264
|
rescue MultiJson::DecodeError, EligibleError
|
251
265
|
raise APIError.new("Invalid response object from API: #{rbody.inspect} (HTTP response code was #{rcode})", rcode, rbody)
|
252
266
|
end
|
253
267
|
|
254
|
-
error_msg = error_message(error)
|
268
|
+
error_msg = error_message(error, errors)
|
255
269
|
|
256
270
|
case rcode
|
257
271
|
when 400, 404 then
|
@@ -21,7 +21,7 @@ module Eligible
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.require_param(value, name)
|
24
|
-
fail ArgumentError, "#{name} of the
|
24
|
+
fail ArgumentError, "#{name} of the #{class_name} is required" if value.nil? || (value.is_a?(String) && value.empty?)
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.send_request(method, url, api_key, params, required_param_name = nil)
|
@@ -4,17 +4,19 @@ module Eligible
|
|
4
4
|
attr_reader :http_status
|
5
5
|
attr_reader :http_body
|
6
6
|
attr_reader :json_body
|
7
|
+
attr_reader :errors
|
7
8
|
|
8
9
|
def initialize(message = nil, http_status = nil, http_body = nil, json_body = nil)
|
9
10
|
@message = message
|
10
11
|
@http_status = http_status
|
11
12
|
@http_body = http_body
|
12
13
|
@json_body = json_body
|
14
|
+
@errors = (@json_body || {}).fetch(:errors, [])
|
13
15
|
end
|
14
16
|
|
15
17
|
def to_s
|
16
18
|
status_string = @http_status.nil? ? '' : "(Status #{@http_status}) "
|
17
|
-
"#{status_string}#{@message}"
|
19
|
+
"#{status_string}#{@message}: #{@errors.to_json}"
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
data/lib/eligible/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eligible
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katelyn Gleaon
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2018-01-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -46,14 +46,14 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '12.0'
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
56
|
+
version: '12.0'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: rspec
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,20 +68,6 @@ dependencies:
|
|
68
68
|
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '3.4'
|
71
|
-
- !ruby/object:Gem::Dependency
|
72
|
-
name: rubocop
|
73
|
-
requirement: !ruby/object:Gem::Requirement
|
74
|
-
requirements:
|
75
|
-
- - '='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 0.35.0
|
78
|
-
type: :development
|
79
|
-
prerelease: false
|
80
|
-
version_requirements: !ruby/object:Gem::Requirement
|
81
|
-
requirements:
|
82
|
-
- - '='
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
version: 0.35.0
|
85
71
|
- !ruby/object:Gem::Dependency
|
86
72
|
name: simplecov
|
87
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,6 +102,7 @@ files:
|
|
116
102
|
- LICENSE
|
117
103
|
- README.md
|
118
104
|
- Rakefile
|
105
|
+
- circle.yml
|
119
106
|
- eligible.gemspec
|
120
107
|
- lib/eligible.rb
|
121
108
|
- lib/eligible/api_resource.rb
|
@@ -168,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
155
|
version: '0'
|
169
156
|
requirements: []
|
170
157
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.6.14
|
172
159
|
signing_key:
|
173
160
|
specification_version: 4
|
174
161
|
summary: Ruby wrapper for the Eligible API
|