vericred 0.1.2 → 0.2.0
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/README.md +19 -1
- data/lib/vericred/api_resource.rb +11 -0
- data/lib/vericred/errors.rb +17 -0
- data/lib/vericred/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 393dcaf8b3a364427f884dc53d7ebb9deebe9399
|
4
|
+
data.tar.gz: 55421534bf5376461e4c2f3c2fe24335e5e6ee9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73b67dc66c6fa1c9fc0588bd2a7d2eb3628ebe65644ddcb5a8a656f707a417366e5642da850c6afe428f1b69ff749c186a6745d787a7b8a1182cc749a11f3b05
|
7
|
+
data.tar.gz: ba8a93bb433ed14a0f4f9a990f49cdc7f4c8c845c61ce4120eee6529bc471f70bee43e71bf17e273557c10408bf2b13a0b13cac9252114155d220d25b8838b82
|
data/README.md
CHANGED
@@ -51,6 +51,13 @@ Vericred::Provider.search(search_term: 'foo', zip_code: '11215')
|
|
51
51
|
# => [Vericred::Provider, Vericred::Provider]
|
52
52
|
```
|
53
53
|
|
54
|
+
### Retrieving a total count from the List endpoint
|
55
|
+
To return a total count, use the `total` method in place of the `search method`
|
56
|
+
```ruby
|
57
|
+
Vericred::Provider.total(search_term: 'foo', zip_code: '11215')
|
58
|
+
# => 100
|
59
|
+
```
|
60
|
+
|
54
61
|
#### Searching for Plans
|
55
62
|
When searching for Plans, you may supply one or more applicants to retrieve
|
56
63
|
pricing. The `smoker` flag only need be supplied if it is true.
|
@@ -94,7 +101,7 @@ zip_counties.first.zip_code.code # => 12345
|
|
94
101
|
```
|
95
102
|
|
96
103
|
### Using Futures
|
97
|
-
Any individual
|
104
|
+
Any individual, list of records, or total can be found using a Future. This
|
98
105
|
allows you to make a request early in the execution of your codepath
|
99
106
|
and allow the API to return a result without blocking execution. It also
|
100
107
|
allows you to make requests to the API in parallel.
|
@@ -104,6 +111,17 @@ futures = [npi1, npi2, npi3]
|
|
104
111
|
.map { |id| Vericred::Provider.future.find(npi) }
|
105
112
|
# do some other stuff in the meantime, then call #value to get the result
|
106
113
|
providers = futures.map(&:value)
|
114
|
+
|
115
|
+
futures =
|
116
|
+
[1, 2, 3].map do |i|
|
117
|
+
Vericred::Provider.future.total(
|
118
|
+
zip_code: '12345',
|
119
|
+
radius: i,
|
120
|
+
search_term: 'foo'
|
121
|
+
)
|
122
|
+
end
|
123
|
+
# do some other stuff in the meantime, then call #value to get the result
|
124
|
+
totals = futures.map(&:value)
|
107
125
|
```
|
108
126
|
|
109
127
|
### Error Handling
|
@@ -53,6 +53,13 @@ module Vericred
|
|
53
53
|
(data[root_name.pluralize] || []).map { |row| new(row, data) }
|
54
54
|
end
|
55
55
|
|
56
|
+
def self.total(query = {})
|
57
|
+
query.merge!(page: 1, per_page: 1)
|
58
|
+
make_request(:get, uri, query.to_query, headers)
|
59
|
+
.fetch('meta', nil)
|
60
|
+
.try(:fetch, 'total', nil) || total_not_supported
|
61
|
+
end
|
62
|
+
|
56
63
|
def initialize(attrs, full_data = {})
|
57
64
|
parse_relationships(attrs, full_data)
|
58
65
|
@data = OpenStruct.new(attrs)
|
@@ -86,6 +93,10 @@ module Vericred
|
|
86
93
|
handle_response(response)
|
87
94
|
end
|
88
95
|
|
96
|
+
def self.total_not_supported
|
97
|
+
fail TotalNotSupportedError, self
|
98
|
+
end
|
99
|
+
|
89
100
|
def method_missing(m, *args, &block)
|
90
101
|
return @data.send(m, *args, &block) if @data.respond_to?(m)
|
91
102
|
super
|
data/lib/vericred/errors.rb
CHANGED
@@ -19,6 +19,23 @@ module Vericred
|
|
19
19
|
attr_reader :response
|
20
20
|
end
|
21
21
|
|
22
|
+
|
23
|
+
TotalNotSupportedError = Class.new(Error) do
|
24
|
+
def initialize(klass)
|
25
|
+
@klass = klass
|
26
|
+
end
|
27
|
+
|
28
|
+
def errors
|
29
|
+
OpenStruct.new(
|
30
|
+
not_supported: ["#{klass} does not support total"]
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def status
|
35
|
+
422
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
22
39
|
UnauthenticatedError = Class.new(Error)
|
23
40
|
UnauthorizedError = Class.new(Error)
|
24
41
|
UnprocessableEntityError = Class.new(Error)
|
data/lib/vericred/version.rb
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.
|
4
|
+
version: 0.2.0
|
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-
|
11
|
+
date: 2015-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|