Class: Eligible::APIResource
Direct Known Subclasses
CalculatorDeployUrl, Claim, CoverageResource, Customer, Enrollment, Icd, Lockbox, Ocr, OriginalSignaturePdf, Payer, Payment, ProviderModel, PublicKey, ReceivedPdf, RiskAssessment, SessionToken, Ticket, VisitType, X12
Instance Attribute Summary
#api_key, #eligible_id
Class Method Summary
collapse
#[], #[]=, construct_from, #each, #error, #initialize, #keys, #refresh_from, #to_hash, #to_json, #values
Class Method Details
.api_url(base, params = nil, param_id = nil) ⇒ Object
7
8
9
10
11
12
13
14
|
# File 'lib/eligible/api_resource.rb', line 7
def self.api_url(base, params = nil, param_id = nil)
if params.nil?
"/#{base}.json"
else
id = Util.value(params, param_id)
"/#{base}/#{id}.json"
end
end
|
.class_name ⇒ Object
3
4
5
|
# File 'lib/eligible/api_resource.rb', line 3
def self.class_name
name.split('::').last
end
|
.require_param(value, name) ⇒ Object
23
24
25
|
# File 'lib/eligible/api_resource.rb', line 23
def self.require_param(value, name)
fail ArgumentError, "#{name} of the #{class_name} is required" if value.nil? || (value.is_a?(String) && value.empty?)
end
|
.send_request(method, url, api_key, params, required_param_name = nil) ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/eligible/api_resource.rb', line 27
def self.send_request(method, url, api_key, params, required_param_name = nil)
unless required_param_name.nil?
required_param = Util.value(params, required_param_name)
require_param(required_param, required_param_name)
end
response, api_key = Eligible.request(method, url, api_key, **params)
Util.convert_to_eligible_object(response, api_key)
end
|
.url ⇒ Object
16
17
18
19
20
21
|
# File 'lib/eligible/api_resource.rb', line 16
def self.url
if self == APIResource
fail NotImplementedError, 'APIResource is an abstract class. You should perform actions on its subclasses (Plan, Service, etc.)'
end
"/#{CGI.escape(class_name.downcase)}/"
end
|