eligible 2.6.0 → 2.6.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.
@@ -23,7 +23,11 @@ require 'eligible/medicare'
23
23
  require 'eligible/ticket'
24
24
  require 'eligible/customer'
25
25
  require 'eligible/original_signature_pdf'
26
+ require 'eligible/received_pdf'
26
27
  require 'eligible/payer'
28
+ require 'eligible/preauth_resource'
29
+ require 'eligible/precert'
30
+ require 'eligible/referral'
27
31
 
28
32
  # Errors
29
33
  require 'eligible/errors/eligible_error'
@@ -88,11 +92,19 @@ module Eligible
88
92
  params[:format].is_a?(String) && params[:format].downcase == 'x12'
89
93
  end
90
94
 
95
+ def self.test_key?(params)
96
+ Util.key?(params, :test)
97
+ end
98
+
99
+ def self.api_key?(params)
100
+ Util.key?(params, :api_key)
101
+ end
102
+
91
103
  def self.request(method, url, api_key, params = {}, headers = {})
92
104
  api_key ||= @@api_key
93
105
  test = self.test
94
- api_key = params[:api_key] if params.key?(:api_key)
95
- test = params[:test] if params.key?(:test)
106
+ api_key = Util.value(params, :api_key) if api_key?(params)
107
+ test = Util.value(params, :test) if test_key?(params)
96
108
 
97
109
  fail AuthenticationError, 'No API key provided. (HINT: set your API key using "Eligible.api_key = <API-KEY>".' unless api_key
98
110
 
@@ -120,7 +132,7 @@ module Eligible
120
132
  payload = nil
121
133
  else
122
134
  params.merge!('api_key' => api_key, 'test' => test)
123
- payload = params.key?(:file) ? params : Eligible::JSON.dump(params)
135
+ payload = Util.key?(params, :file) ? params : Eligible::JSON.dump(params)
124
136
  end
125
137
 
126
138
  begin
@@ -147,7 +159,8 @@ module Eligible
147
159
  open_timeout: 30,
148
160
  payload: payload,
149
161
  timeout: 80,
150
- ssl_verify_callback: verify_certificate
162
+ ssl_verify_callback: verify_certificate,
163
+ ssl_verify_callback_warnings: false
151
164
  }
152
165
 
153
166
  begin
@@ -4,6 +4,15 @@ module Eligible
4
4
  name.split('::').last
5
5
  end
6
6
 
7
+ def self.api_url(base, params = nil, param_id = nil)
8
+ if params.nil?
9
+ "/#{base}.json"
10
+ else
11
+ id = Util.value(params, param_id)
12
+ "/#{base}/#{id}.json"
13
+ end
14
+ end
15
+
7
16
  def self.url
8
17
  if self == APIResource
9
18
  fail NotImplementedError, 'APIResource is an abstract class. You should perform actions on its subclasses (Plan, Service, etc.)'
@@ -16,9 +25,13 @@ module Eligible
16
25
  end
17
26
 
18
27
  def self.send_request(method, url, api_key, params, required_param_name = nil)
19
- require_param(params[required_param_name], required_param_name) unless required_param_name.nil?
28
+ unless required_param_name.nil?
29
+ required_param = Util.value(params, required_param_name)
30
+ require_param(required_param, required_param_name)
31
+ end
20
32
  response, api_key = Eligible.request(method, url, api_key, params)
21
33
  Util.convert_to_eligible_object(response, api_key)
22
34
  end
35
+
23
36
  end
24
37
  end
@@ -1,7 +1,8 @@
1
1
  module Eligible
2
2
  class Claim < APIResource
3
3
  def self.ack(params, api_key = nil)
4
- send_request(:get, "/claims/#{params[:reference_id]}/acknowledgements.json", api_key, params, :reference_id)
4
+ reference_id = Util.value(params, :reference_id)
5
+ send_request(:get, "/claims/#{reference_id}/acknowledgements.json", api_key, params, :reference_id)
5
6
  end
6
7
 
7
8
  def self.post(params, api_key = nil)
@@ -13,8 +14,10 @@ module Eligible
13
14
  end
14
15
 
15
16
  def self.payment_report(params, api_key = nil)
16
- require_param(params[:reference_id], 'Reference id')
17
- url = params.key?(:id) ? "/claims/#{params[:reference_id]}/payment_reports/#{params[:id]}" : "/claims/#{params[:reference_id]}/payment_reports"
17
+ reference_id = Util.value(params, :reference_id)
18
+ require_param(reference_id, 'Reference id')
19
+ id = Util.value(params, :id)
20
+ url = id.nil? ? "/claims/#{reference_id}/payment_reports" : "/claims/#{reference_id}/payment_reports/#{id}"
18
21
  send_request(:get, url, api_key, params)
19
22
  end
20
23
 
@@ -4,7 +4,7 @@ module Eligible
4
4
  send_request(:get, get_uri, api_key, params)
5
5
  end
6
6
 
7
- def self.batch_post(params, api_key = nil)
7
+ def self.post(params, api_key = nil)
8
8
  send_request(:post, post_uri, api_key, params)
9
9
  end
10
10
 
@@ -15,5 +15,9 @@ module Eligible
15
15
  def self.post_uri
16
16
  fail NotImplementedError, "Please implement class method #{self}.post_uri"
17
17
  end
18
+
19
+ class << self
20
+ alias_method :batch_post, :post
21
+ end
18
22
  end
19
23
  end
@@ -1,19 +1,19 @@
1
1
  module Eligible
2
2
  class Customer < APIResource
3
3
  def self.get(params, api_key = nil)
4
- send_request(:get, "/customers/#{params[:customer_id]}.json", api_key, params, :customer_id)
4
+ send_request(:get, api_url('customers', params, :customer_id), api_key, params, :customer_id)
5
5
  end
6
6
 
7
7
  def self.post(params, api_key = nil)
8
- send_request(:post, '/customers.json', api_key, params)
8
+ send_request(:post, api_url('customers'), api_key, params)
9
9
  end
10
10
 
11
11
  def self.update(params, api_key = nil)
12
- send_request(:put, "/customers/#{params[:customer_id]}.json", api_key, params, :customer_id)
12
+ send_request(:put, api_url('customers', params, :customer_id), api_key, params, :customer_id)
13
13
  end
14
14
 
15
15
  def self.all(params, api_key = nil)
16
- send_request(:get, '/customers.json', api_key, params)
16
+ send_request(:get, api_url('customers'), api_key, params)
17
17
  end
18
18
  end
19
19
  end
@@ -1,19 +1,19 @@
1
1
  module Eligible
2
2
  class Enrollment < APIResource
3
3
  def self.get(params, api_key = nil)
4
- send_request(:get, "/enrollment_npis/#{params[:enrollment_npi_id]}.json", api_key, params, :enrollment_npi_id)
4
+ send_request(:get, api_url('enrollment_npis', params, :enrollment_npi_id), api_key, params, :enrollment_npi_id)
5
5
  end
6
6
 
7
7
  def self.list(params, api_key = nil)
8
- send_request(:get, '/enrollment_npis.json', api_key, params)
8
+ send_request(:get, api_url('enrollment_npis'), api_key, params)
9
9
  end
10
10
 
11
11
  def self.post(params, api_key = nil)
12
- send_request(:post, '/enrollment_npis.json', api_key, params)
12
+ send_request(:post, api_url('enrollment_npis'), api_key, params)
13
13
  end
14
14
 
15
15
  def self.update(params, api_key = nil)
16
- send_request(:put, "/enrollment_npis/#{params[:enrollment_npi_id]}.json", api_key, params, :enrollment_npi_id)
16
+ send_request(:put, api_url('enrollment_npis', params, :enrollment_npi_id), api_key, params, :enrollment_npi_id)
17
17
  end
18
18
 
19
19
  def enrollment_npis
@@ -1,29 +1,43 @@
1
1
  module Eligible
2
2
  class OriginalSignaturePdf < APIResource
3
+ def self.original_signature_pdf_url(params)
4
+ enrollment_npi_id = Util.value(params, :enrollment_npi_id)
5
+ "/enrollment_npis/#{enrollment_npi_id}/original_signature_pdf"
6
+ end
7
+
3
8
  def self.get(params, api_key = nil)
4
- send_request(:get, "/enrollment_npis/#{params[:enrollment_npi_id]}/original_signature_pdf", api_key, params, :enrollment_npi_id)
9
+ send_request(:get, original_signature_pdf_url(params), api_key, params, :enrollment_npi_id)
10
+ end
11
+
12
+ def self.setup_file(params)
13
+ file = Util.value(params, :file)
14
+ params[:file] = File.new(file, 'rb') if file.is_a?(String)
5
15
  end
6
16
 
7
17
  def self.post(params, api_key = nil)
8
- send_request(:post, "/enrollment_npis/#{params[:enrollment_npi_id]}/original_signature_pdf", api_key, params, :enrollment_npi_id)
18
+ setup_file(params)
19
+ send_request(:post, original_signature_pdf_url(params), api_key, params, :enrollment_npi_id)
9
20
  end
10
21
 
11
22
  def self.update(params, api_key = nil)
12
- send_request(:put, "/enrollment_npis/#{params[:enrollment_npi_id]}/original_signature_pdf", api_key, params, :enrollment_npi_id)
23
+ setup_file(params)
24
+ send_request(:put, original_signature_pdf_url(params), api_key, params, :enrollment_npi_id)
13
25
  end
14
26
 
15
27
  def self.delete(params, api_key = nil)
16
- send_request(:delete, "/enrollment_npis/#{params[:enrollment_npi_id]}/original_signature_pdf", api_key, params, :enrollment_npi_id)
28
+ send_request(:delete, original_signature_pdf_url(params), api_key, params, :enrollment_npi_id)
17
29
  end
18
30
 
19
31
  def self.download(params, api_key = nil)
20
- require_param(params[:enrollment_npi_id], 'Enrollment Npi id')
32
+ enrollment_npi_id = Util.value(params, :enrollment_npi_id)
33
+ require_param(enrollment_npi_id, 'Enrollment Npi id')
21
34
  params[:format] = 'x12'
22
- response = Eligible.request(:get, "/enrollment_npis/#{params[:enrollment_npi_id]}/original_signature_pdf/download", api_key, params)[0]
35
+ response = Eligible.request(:get, "/enrollment_npis/#{enrollment_npi_id}/original_signature_pdf/download", api_key, params)[0]
23
36
  filename = params[:filename] || '/tmp/original_signature_pdf.pdf'
24
37
  file = File.new(filename, 'w')
25
38
  file.write response
26
39
  file.close
40
+ "PDF file stored at #{filename}"
27
41
  end
28
42
  end
29
43
  end
@@ -1,15 +1,16 @@
1
1
  module Eligible
2
2
  class Payer < APIResource
3
3
  def self.list(params, api_key = nil)
4
- send_request(:get, '/payers.json', api_key, params)
4
+ send_request(:get, api_url('payers'), api_key, params)
5
5
  end
6
6
 
7
7
  def self.get(params, api_key = nil)
8
- send_request(:get, "/payers/#{params[:payer_id]}.json", api_key, params, :payer_id)
8
+ send_request(:get, api_url('payers', params, :payer_id), api_key, params, :payer_id)
9
9
  end
10
10
 
11
11
  def self.search_options(params, api_key = nil)
12
- url = params.key?(:payer_id) ? "/payers/#{params[:payer_id]}/search_options" : '/payers/search_options'
12
+ payer_id = Util.value(params, :payer_id)
13
+ url = payer_id.nil? ? '/payers/search_options' : "/payers/#{payer_id}/search_options"
13
14
  send_request(:get, url, api_key, params)
14
15
  end
15
16
  end
@@ -0,0 +1,11 @@
1
+ module Eligible
2
+ class PreauthResource < CoverageResource
3
+ def self.inquiry(params, api_key = nil)
4
+ get(params, api_key)
5
+ end
6
+
7
+ def self.create(params, api_key = nil)
8
+ post(params, api_key)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Eligible
2
+ class Precert < PreauthResource
3
+ def self.get_uri
4
+ return '/precert/inquiry.json'
5
+ end
6
+
7
+ def self.post_uri
8
+ return '/precert/create.json'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,24 @@
1
+ module Eligible
2
+ class ReceivedPdf < APIResource
3
+ def self.received_pdf_url(params)
4
+ enrollment_npi_id = Util.value(params, :enrollment_npi_id)
5
+ "/enrollment_npis/#{enrollment_npi_id}/received_pdf"
6
+ end
7
+
8
+ def self.get(params, api_key = nil)
9
+ send_request(:get, received_pdf_url(params), api_key, params, :enrollment_npi_id)
10
+ end
11
+
12
+ def self.download(params, api_key = nil)
13
+ enrollment_npi_id = Util.value(params, :enrollment_npi_id)
14
+ require_param(enrollment_npi_id, 'Enrollment Npi id')
15
+ params[:format] = 'x12'
16
+ response = Eligible.request(:get, "/enrollment_npis/#{params[:enrollment_npi_id]}/received_pdf/download", api_key, params)[0]
17
+ filename = params[:filename] || '/tmp/received_pdf.pdf'
18
+ file = File.new(filename, 'w')
19
+ file.write response
20
+ file.close
21
+ "PDF file stored at #{filename}"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ module Eligible
2
+ class Referral < PreauthResource
3
+ def self.get_uri
4
+ return '/referral/inquiry.json'
5
+ end
6
+
7
+ def self.post_uri
8
+ return '/referral/create.json'
9
+ end
10
+ end
11
+ end
@@ -1,27 +1,40 @@
1
1
  module Eligible
2
2
  class Ticket < APIResource
3
+ def self.ticket_url(params = nil, comments = false)
4
+ if params.nil?
5
+ '/tickets'
6
+ else
7
+ id = Util.value(params, :id)
8
+ if comments
9
+ "/tickets/#{id}/comments"
10
+ else
11
+ "/tickets/#{id}"
12
+ end
13
+ end
14
+ end
15
+
3
16
  def self.create(params, api_key = nil)
4
- send_request(:post, '/tickets', api_key, params)
17
+ send_request(:post, ticket_url, api_key, params)
5
18
  end
6
19
 
7
20
  def self.comments(params, api_key = nil)
8
- send_request(:post, "/tickets/#{params[:id]}/comments", api_key, params, :id)
21
+ send_request(:post, ticket_url(params, true), api_key, params, :id)
9
22
  end
10
23
 
11
24
  def self.all(params, api_key = nil)
12
- send_request(:get, '/tickets', api_key, params)
25
+ send_request(:get, ticket_url, api_key, params)
13
26
  end
14
27
 
15
28
  def self.get(params, api_key = nil)
16
- send_request(:get, "/tickets/#{params[:id]}", api_key, params, :id)
29
+ send_request(:get, ticket_url(params), api_key, params, :id)
17
30
  end
18
31
 
19
32
  def self.delete(params, api_key = nil)
20
- send_request(:delete, "/tickets/#{params[:id]}", api_key, params, :id)
33
+ send_request(:delete, ticket_url(params), api_key, params, :id)
21
34
  end
22
35
 
23
36
  def self.update(params, api_key = nil)
24
- send_request(:put, "/tickets/#{params[:id]}", api_key, params, :id)
37
+ send_request(:put, ticket_url(params), api_key, params, :id)
25
38
  end
26
39
  end
27
40
  end
@@ -1,5 +1,14 @@
1
1
  module Eligible
2
2
  module Util
3
+
4
+ def self.key?(params, key)
5
+ [key.to_sym, key.to_s].any? { |k| params.key?(k) }
6
+ end
7
+
8
+ def self.value(params, key)
9
+ params[key.to_sym] || params[key.to_s]
10
+ end
11
+
3
12
  def self.convert_to_eligible_object(resp, api_key)
4
13
  case resp
5
14
  when Array
@@ -1,3 +1,3 @@
1
1
  module Eligible
2
- VERSION = '2.6.0'.freeze
2
+ VERSION = '2.6.1'.freeze
3
3
  end
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.6.0
4
+ version: 2.6.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: 2016-02-24 00:00:00.000000000 Z
13
+ date: 2016-05-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -135,6 +135,10 @@ files:
135
135
  - lib/eligible/original_signature_pdf.rb
136
136
  - lib/eligible/payer.rb
137
137
  - lib/eligible/payment.rb
138
+ - lib/eligible/preauth_resource.rb
139
+ - lib/eligible/precert.rb
140
+ - lib/eligible/received_pdf.rb
141
+ - lib/eligible/referral.rb
138
142
  - lib/eligible/ticket.rb
139
143
  - lib/eligible/util.rb
140
144
  - lib/eligible/version.rb