Class: Verity::Client
- Inherits:
-
Object
- Object
- Verity::Client
- Defined in:
- lib/verity/client.rb
Constant Summary collapse
- DEFAULT_BASE_URL =
'https://verity.backworkai.com/api/v1'- DEFAULT_TIMEOUT =
30
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
- #claims ⇒ Object
- #codes ⇒ Object
- #compliance ⇒ Object
- #coverage ⇒ Object
- #drugs ⇒ Object
- #health ⇒ Object
-
#initialize(api_key:, base_url: nil, timeout: nil) ⇒ Client
constructor
A new instance of Client.
- #policies ⇒ Object
- #prior_auth ⇒ Object
- #request(method, path, params: nil, body: nil, headers: {}) ⇒ Object
- #spending ⇒ Object
- #webhooks ⇒ Object
Constructor Details
#initialize(api_key:, base_url: nil, timeout: nil) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 |
# File 'lib/verity/client.rb', line 10 def initialize(api_key:, base_url: nil, timeout: nil) raise ArgumentError, 'api_key is required' if api_key.nil? || api_key.empty? @api_key = api_key @base_url = base_url || DEFAULT_BASE_URL @timeout = timeout || DEFAULT_TIMEOUT end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/verity/client.rb', line 8 def api_key @api_key end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
8 9 10 |
# File 'lib/verity/client.rb', line 8 def base_url @base_url end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
8 9 10 |
# File 'lib/verity/client.rb', line 8 def timeout @timeout end |
Instance Method Details
#claims ⇒ Object
42 43 44 |
# File 'lib/verity/client.rb', line 42 def claims @claims ||= Resources::Claims.new(self) end |
#codes ⇒ Object
18 19 20 |
# File 'lib/verity/client.rb', line 18 def codes @codes ||= Resources::Codes.new(self) end |
#compliance ⇒ Object
46 47 48 |
# File 'lib/verity/client.rb', line 46 def compliance @compliance ||= Resources::Compliance.new(self) end |
#coverage ⇒ Object
26 27 28 |
# File 'lib/verity/client.rb', line 26 def coverage @coverage ||= Resources::Coverage.new(self) end |
#drugs ⇒ Object
50 51 52 |
# File 'lib/verity/client.rb', line 50 def drugs @drugs ||= Resources::Drugs.new(self) end |
#health ⇒ Object
54 55 56 |
# File 'lib/verity/client.rb', line 54 def health request(:get, '/health') end |
#policies ⇒ Object
22 23 24 |
# File 'lib/verity/client.rb', line 22 def policies @policies ||= Resources::Policies.new(self) end |
#prior_auth ⇒ Object
30 31 32 |
# File 'lib/verity/client.rb', line 30 def prior_auth @prior_auth ||= Resources::PriorAuth.new(self) end |
#request(method, path, params: nil, body: nil, headers: {}) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/verity/client.rb', line 59 def request(method, path, params: nil, body: nil, headers: {}) response = connection.send(method) do |req| req.url path.sub(%r{\A/}, '') req.params = params if params req.body = body.to_json if body req.headers = default_headers.merge(headers) end handle_response(response) rescue Faraday::Error => e raise APIError, "Request failed: #{e.}" end |