vericred 0.1.1 → 0.1.2
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/.travis.yml +1 -0
- data/README.md +44 -19
- data/lib/vericred/api_resource.rb +7 -2
- data/lib/vericred/version.rb +1 -1
- data/vericred.gemspec +0 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdbf40d3b2c58e519021855243fe1b7e4784967d
|
4
|
+
data.tar.gz: 9ce033b544c99e98d65b6e37364b0fcc38d0ebae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d0a527b18e4d542a9bc01b653ff61ccd102f38ab69eafe399770e3c15abdae3726f5f51b88a2b5241cb9caf80964d8173abd7c09b2c9bd803d65fcb28f08f11
|
7
|
+
data.tar.gz: 1ac43a0881b3941901a059a394ae33917b981578a09d1da17b0d90e66d4df7dea61b2fae925743fdec4a0e85b5dc70b17ce5958153044d8870a8b4704331d7fb
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Vericred
|
2
2
|
|
3
|
+
[](https://codeclimate.com/repos/562a2857e30ba04788014399/feed)
|
4
|
+
|
5
|
+
[](https://travis-ci.org/vericred/vericred_ruby)
|
6
|
+
|
3
7
|
A client gem to interact with the Vericred API. It provides useful helpers for:
|
4
8
|
|
5
9
|
- Futures
|
@@ -19,18 +23,18 @@ gem 'vericred'
|
|
19
23
|
|
20
24
|
And then execute:
|
21
25
|
|
22
|
-
|
26
|
+
$ bundle
|
23
27
|
|
24
28
|
Or install it yourself as:
|
25
29
|
|
26
|
-
|
30
|
+
$ gem install vericred
|
27
31
|
|
28
32
|
### With Rails
|
29
33
|
|
30
34
|
Add a configuration block in `config/initializers/vericred.rb`
|
31
35
|
```ruby
|
32
36
|
Vericred.configure do |config|
|
33
|
-
|
37
|
+
config.api_key = ENV['VERICRED_API_KEY']
|
34
38
|
end
|
35
39
|
```
|
36
40
|
|
@@ -44,7 +48,28 @@ Vericred::Provider.find(npi) # => Vericred::Provider
|
|
44
48
|
### Retrieving a List of Records
|
45
49
|
```ruby
|
46
50
|
Vericred::Provider.search(search_term: 'foo', zip_code: '11215')
|
47
|
-
|
51
|
+
# => [Vericred::Provider, Vericred::Provider]
|
52
|
+
```
|
53
|
+
|
54
|
+
#### Searching for Plans
|
55
|
+
When searching for Plans, you may supply one or more applicants to retrieve
|
56
|
+
pricing. The `smoker` flag only need be supplied if it is true.
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
Vericred::Plan.search(
|
60
|
+
zip_code: '11215',
|
61
|
+
fips_code: '36047',
|
62
|
+
market: 'individual',
|
63
|
+
applicants: [
|
64
|
+
{ age: 31 },
|
65
|
+
{ age: 42, smoker: true }
|
66
|
+
],
|
67
|
+
providers: [
|
68
|
+
{ npi: 1841293990 },
|
69
|
+
{ npi: 1740283779 }
|
70
|
+
]
|
71
|
+
)
|
72
|
+
# => [Vericred::Plan<premium=401.23>, Vericred::Plan<premium=501.13>]
|
48
73
|
```
|
49
74
|
|
50
75
|
### Sideloaded data
|
@@ -53,9 +78,9 @@ Sideloaded data is automatically added to the object found. For example,
|
|
53
78
|
with the following response (simplified)
|
54
79
|
```json
|
55
80
|
{
|
56
|
-
|
57
|
-
|
58
|
-
|
81
|
+
"zip_counties": [{"id": 1, "zip_code_id": 2, "county_id": 3}],
|
82
|
+
"counties": [{"id": 3, "name": "County"}],
|
83
|
+
"zip_codes": [{"id": 2, "code": "12345"}]
|
59
84
|
}
|
60
85
|
```
|
61
86
|
|
@@ -86,42 +111,42 @@ providers = futures.map(&:value)
|
|
86
111
|
Generic error handling:
|
87
112
|
```ruby
|
88
113
|
begin
|
89
|
-
|
114
|
+
Vericred::Provider.find(npi)
|
90
115
|
rescue Vericred::Error => e
|
91
|
-
|
116
|
+
# Retry or do something else
|
92
117
|
end
|
93
118
|
```
|
94
119
|
|
95
120
|
Handling each possible error
|
96
121
|
```ruby
|
97
122
|
begin
|
98
|
-
|
123
|
+
Vericred::Provider.find(npi)
|
99
124
|
rescue Vericred::UnauthenticatedError => e
|
100
|
-
|
125
|
+
# No credentials supplied
|
101
126
|
rescue Vericred::UnauthorizedError => e
|
102
|
-
|
127
|
+
# Invalid credentials
|
103
128
|
rescue Vericred::UnprocessableEntityError => e
|
104
|
-
|
129
|
+
# Invalid parameters have been specified
|
105
130
|
rescue Vericred::UnknownError => e
|
106
|
-
|
131
|
+
# Something else has gone wrong - see e.errors for details
|
107
132
|
end
|
108
133
|
```
|
109
134
|
Every instance of `Vericred::Error` has an `#errors` method, which returns
|
110
135
|
the parsed error messages from the server. They are in the format.
|
111
136
|
```json
|
112
137
|
{
|
113
|
-
|
114
|
-
|
115
|
-
|
138
|
+
"errors": {
|
139
|
+
"field_or_category": ["list", "of", "things", "wrong"]
|
140
|
+
}
|
116
141
|
}
|
117
142
|
```
|
118
143
|
|
119
144
|
When parsed, they can be accessed like:
|
120
145
|
```ruby
|
121
146
|
begin
|
122
|
-
|
147
|
+
Vericred::Provider.find(npi)
|
123
148
|
rescue Vericred::Error => e
|
124
|
-
|
149
|
+
e.errors.field_or_category.join(', ') # "list, of, things, wrong"
|
125
150
|
end
|
126
151
|
```
|
127
152
|
|
@@ -49,7 +49,7 @@ module Vericred
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def self.search(query = {})
|
52
|
-
data = make_request(:get, uri, query, headers)
|
52
|
+
data = make_request(:get, uri, query.to_query, headers)
|
53
53
|
(data[root_name.pluralize] || []).map { |row| new(row, data) }
|
54
54
|
end
|
55
55
|
|
@@ -71,8 +71,13 @@ module Vericred
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
+
def self.log_request(verb, uri, *args)
|
75
|
+
args = args.map { |arg| arg.is_a?(String) ? URI.unescape(arg) : arg }
|
76
|
+
logger.info { "[#{verb.to_s.upcase}] to #{uri} with #{args}" }
|
77
|
+
end
|
78
|
+
|
74
79
|
def self.make_request(verb, uri, *args)
|
75
|
-
|
80
|
+
log_request(verb, uri, *args)
|
76
81
|
response = nil
|
77
82
|
ActiveSupport::Notifications
|
78
83
|
.instrument "vericred.http_request", opts: [verb, uri, *args] do
|
data/lib/vericred/version.rb
CHANGED
data/vericred.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vericred
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Langevin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '10.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry-debugger
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - '>='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - '>='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: guard-rspec
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|