eligible 3.0.0.beta1 → 3.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/eligible.rb +83 -36
- data/lib/eligible/api_resource.rb +4 -3
- data/lib/eligible/public_key.rb +1 -1
- data/lib/eligible/v1_0/file_object.rb +19 -0
- data/lib/eligible/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b91ee15bde1467fb30499f497982d0ffdea4a5739855a6bd01e2a5d868cd2d85
|
4
|
+
data.tar.gz: c61d65c8a67fb3b775848fa7b54f7e622995d2cf743c635e1d7ac1539e17cf28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e9d0784d9641a575fa423b9b63c5ffcb1c762d3520f1f611a6de10b4888707562dff6fefbf2e5567a16bf478fbb6e5024b4ad4db8f987b5f7a8263be0018f92
|
7
|
+
data.tar.gz: 2152560fada012eb4da4936a7431bacf2ad4c816fca4e04e7f83647b460e6fe32a1f03b682d640e957f8337c95bd90609eb9f02a2c90d1974ed5fc2816b8e0ac
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.0.0.beta2 - 2020-03-03
|
4
|
+
- Added support for V1.0 REST API endpoints and added Files endpoints
|
5
|
+
- Update pinned api.eligible.com and wildcard.eligible.com certificate
|
6
|
+
|
3
7
|
## 3.0.0.beta1 - 2019-10-01
|
4
8
|
- Added support for Eligible-Account Header in the API requests when used Eligible Connect feature
|
5
9
|
|
data/lib/eligible.rb
CHANGED
@@ -41,6 +41,9 @@ require 'eligible/calculator_deploy_url'
|
|
41
41
|
require 'eligible/risk_assessment'
|
42
42
|
require 'eligible/icd'
|
43
43
|
|
44
|
+
# New REST API Endpoints
|
45
|
+
require 'eligible/v1_0/file_object'
|
46
|
+
|
44
47
|
# Errors
|
45
48
|
require 'eligible/errors/eligible_error'
|
46
49
|
require 'eligible/errors/api_connection_error'
|
@@ -54,11 +57,14 @@ module Eligible
|
|
54
57
|
@@api_version = '1.5'
|
55
58
|
@@api_base = "https://gds.eligibleapi.com/v#{@@api_version}"
|
56
59
|
@@fingerprints = %w(9df5f186fb20ad25ffd864942a6394840b02a480
|
57
|
-
a1cd762a9f4be0f3b6bdd6300e52c6ce8d7d67f5
|
60
|
+
a1cd762a9f4be0f3b6bdd6300e52c6ce8d7d67f5
|
61
|
+
d93b7697100fe978ae0f78fbf2a2443cc1958ca3
|
62
|
+
896ce24f7a83eb656c040985fdb50ce39f90b813)
|
58
63
|
@@eligible_account = nil
|
59
64
|
|
60
|
-
def self.api_url(url = '')
|
61
|
-
@@api_base
|
65
|
+
def self.api_url(url = '', rest_api_version = nil)
|
66
|
+
api_base = rest_api_version ? @@api_base.gsub(/v(\d).(\d)/, "v#{rest_api_version}") : @@api_base
|
67
|
+
api_base + url.to_s
|
62
68
|
end
|
63
69
|
|
64
70
|
def self.eligible_account
|
@@ -122,12 +128,18 @@ module Eligible
|
|
122
128
|
Util.key?(params, :api_key)
|
123
129
|
end
|
124
130
|
|
131
|
+
def self.rest_api_version?(params)
|
132
|
+
Util.key?(params, :rest_api_version)
|
133
|
+
end
|
134
|
+
|
125
135
|
def self.request(method, url, api_key, params = {}, headers = {})
|
126
136
|
session_token = Util.value(params, :session_token)
|
127
137
|
api_key ||= @@api_key unless session_token
|
128
138
|
test = self.test
|
129
139
|
api_key = Util.value(params, :api_key) if api_key?(params)
|
130
140
|
test = Util.value(params, :test) if test_key?(params)
|
141
|
+
rest_api_version = Util.value(params, :rest_api_version) if rest_api_version?(params)
|
142
|
+
basic_auth = true if rest_api_version?(params)
|
131
143
|
|
132
144
|
fail AuthenticationError, 'No API key provided. (HINT: set your API key using "Eligible.api_key = <API-KEY>".' unless api_key || session_token
|
133
145
|
|
@@ -141,40 +153,13 @@ module Eligible
|
|
141
153
|
uname: uname
|
142
154
|
}
|
143
155
|
|
144
|
-
#
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
when :get, :head, :delete
|
149
|
-
url += "?api_key=#{api_key}"
|
150
|
-
if params && params.count > 0
|
151
|
-
query_string = Util.flatten_params(params).collect { |key, value| "#{key}=#{Util.url_encode(value)}" }.join('&')
|
152
|
-
url += "&#{query_string}"
|
153
|
-
end
|
154
|
-
url += "&test=#{test}"
|
155
|
-
payload = nil
|
156
|
-
else
|
157
|
-
params.merge!('api_key' => api_key, 'test' => test)
|
158
|
-
payload = Util.key?(params, :file) ? params : Eligible::JSON.dump(params)
|
159
|
-
end
|
160
|
-
|
161
|
-
begin
|
162
|
-
headers = { x_eligible_debuginfo: Eligible::JSON.dump(debug_info) }.merge(headers)
|
163
|
-
rescue => e
|
164
|
-
headers = {
|
165
|
-
x_eligible_client_raw_user_agent: debug_info.inspect,
|
166
|
-
error: "#{e} (#{e.class})"
|
167
|
-
}.merge(headers)
|
168
|
-
end
|
169
|
-
|
170
|
-
headers = {
|
171
|
-
user_agent: "eligible-ruby/#{Eligible::VERSION}",
|
172
|
-
authorization: "Bearer #{api_key}",
|
173
|
-
content_type: 'application/json'
|
174
|
-
}.merge(headers)
|
156
|
+
# Set request URL and Payload based on new and old endpoints version
|
157
|
+
url, payload = generate_request_url_and_payload(
|
158
|
+
method, url, params, { test: test, rest_api_version: rest_api_version, api_key: api_key, basic_auth: basic_auth },
|
159
|
+
)
|
175
160
|
|
176
|
-
|
177
|
-
headers
|
161
|
+
# Set request Headers and Authorization based on new and old endpoints version
|
162
|
+
headers = generate_request_headers(headers, debug_info, basic_auth, { api_key: api_key, session_token: session_token })
|
178
163
|
|
179
164
|
opts = {
|
180
165
|
method: method,
|
@@ -229,6 +214,68 @@ module Eligible
|
|
229
214
|
return [ resp, api_key ]
|
230
215
|
end
|
231
216
|
|
217
|
+
def self.generate_request_url_and_payload(method, url, params, options)
|
218
|
+
# GET requests, parameters on the query string
|
219
|
+
# POST requests, parameters as json in the body
|
220
|
+
url = api_url(url, options[:rest_api_version])
|
221
|
+
|
222
|
+
case method.to_s.downcase.to_sym
|
223
|
+
when :get, :head, :delete
|
224
|
+
url = fetch_url_with_query_string(params, url, options)
|
225
|
+
payload = nil
|
226
|
+
else
|
227
|
+
payload = request_payload(options, params)
|
228
|
+
end
|
229
|
+
|
230
|
+
[url, payload]
|
231
|
+
end
|
232
|
+
|
233
|
+
def self.fetch_url_with_query_string(params, url, options)
|
234
|
+
url += "?test=#{options[:test]}"
|
235
|
+
url += "&api_key=#{options[:api_key]}" unless options[:basic_auth]
|
236
|
+
return url unless params || params.count == 0
|
237
|
+
|
238
|
+
query_string = Util.flatten_params(params).collect { |key, value| "#{key}=#{Util.url_encode(value)}" }.join('&')
|
239
|
+
url += "&#{query_string}"
|
240
|
+
url
|
241
|
+
end
|
242
|
+
|
243
|
+
def self.request_payload(options, params)
|
244
|
+
params.merge!('test' => options[:test])
|
245
|
+
params.merge!('api_key' => options[:api_key]) unless options[:basic_auth]
|
246
|
+
Util.key?(params, :file) ? params : Eligible::JSON.dump(params)
|
247
|
+
end
|
248
|
+
|
249
|
+
def self.generate_request_headers(headers, debug_info, basic_auth, auth_options)
|
250
|
+
begin
|
251
|
+
headers = { x_eligible_debuginfo: Eligible::JSON.dump(debug_info) }.merge(headers)
|
252
|
+
rescue => e
|
253
|
+
headers = {
|
254
|
+
x_eligible_client_raw_user_agent: debug_info.inspect,
|
255
|
+
error: "#{e} (#{e.class})"
|
256
|
+
}.merge(headers)
|
257
|
+
end
|
258
|
+
|
259
|
+
headers = {
|
260
|
+
user_agent: "eligible-ruby/#{Eligible::VERSION}",
|
261
|
+
content_type: 'application/json'
|
262
|
+
}.merge(headers)
|
263
|
+
|
264
|
+
headers[:authorization] = authorization_header(basic_auth, auth_options)
|
265
|
+
headers[:eligible_version] = api_version if api_version
|
266
|
+
headers[:eligible_account] = eligible_account if eligible_account
|
267
|
+
headers
|
268
|
+
end
|
269
|
+
|
270
|
+
def self.authorization_header(basic_auth, auth_options)
|
271
|
+
# Using Bearer scheme for Session Token Auth for new REST API endpoints (v1.0)
|
272
|
+
return "Bearer #{auth_options[:session_token]}" if basic_auth && auth_options[:session_token]
|
273
|
+
|
274
|
+
# Using Basic Auth for new REST API endpoints (v1.0)
|
275
|
+
basic_auth_token = Base64.strict_encode64("#{auth_options[:api_key]}:")
|
276
|
+
"Basic #{basic_auth_token}" if basic_auth
|
277
|
+
end
|
278
|
+
|
232
279
|
def self.verify_certificate
|
233
280
|
lambda do |preverify_ok, certificate_store|
|
234
281
|
return true if test == 'true'
|
@@ -6,10 +6,10 @@ module Eligible
|
|
6
6
|
|
7
7
|
def self.api_url(base, params = nil, param_id = nil)
|
8
8
|
if params.nil?
|
9
|
-
"/#{base}
|
9
|
+
"/#{base}"
|
10
10
|
else
|
11
11
|
id = Util.value(params, param_id)
|
12
|
-
"/#{base}/#{id}
|
12
|
+
"/#{base}/#{id}"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -41,9 +41,10 @@ module Eligible
|
|
41
41
|
|
42
42
|
required_param_validation(params: params, required_params: headers.delete(:required_params))
|
43
43
|
|
44
|
+
# Here rest_api_version is related to New REST API Endpoints
|
45
|
+
params = self.const_defined?(:REST_API_VERSION) ? params.merge(rest_api_version: self::REST_API_VERSION) : params
|
44
46
|
response, api_key = Eligible.request(method, url, api_key, params, headers)
|
45
47
|
Util.convert_to_eligible_object(response, api_key)
|
46
48
|
end
|
47
|
-
|
48
49
|
end
|
49
50
|
end
|
data/lib/eligible/public_key.rb
CHANGED
@@ -12,7 +12,7 @@ module Eligible
|
|
12
12
|
|
13
13
|
def self.activate(params, opts = {})
|
14
14
|
key_id = Util.value(params, :key_id)
|
15
|
-
send_request :get, "/public_keys/#{key_id}/activate
|
15
|
+
send_request :get, "/public_keys/#{key_id}/activate", params, opts.merge(required_params: [:key_id])
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.all(params, opts = {})
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Eligible
|
4
|
+
class FileObject < APIResource
|
5
|
+
REST_API_VERSION = '1.0'.freeze
|
6
|
+
|
7
|
+
def self.get(params, opts = {})
|
8
|
+
send_request :get, api_url('files', params, :file_id), params, opts.merge(required_params: [:file_id])
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.post(params, opts = {})
|
12
|
+
send_request :post, api_url('files'), params, opts
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.list(params, opts = {})
|
16
|
+
send_request :get, api_url('files'), params, opts
|
17
|
+
end
|
18
|
+
end
|
19
|
+
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: 3.0.0.
|
4
|
+
version: 3.0.0.beta2
|
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: 2020-
|
13
|
+
date: 2020-03-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- lib/eligible/session_token.rb
|
156
156
|
- lib/eligible/ticket.rb
|
157
157
|
- lib/eligible/util.rb
|
158
|
+
- lib/eligible/v1_0/file_object.rb
|
158
159
|
- lib/eligible/version.rb
|
159
160
|
- lib/eligible/visit_type.rb
|
160
161
|
- lib/eligible/x12.rb
|