Class: ChangeHealth::Connection
- Inherits:
-
Object
- Object
- ChangeHealth::Connection
- Includes:
- HTTParty
- Defined in:
- lib/change_health/connection.rb
Constant Summary collapse
- URI_BUILDER =
->(host) { "https://#{host}apigw.changehealthcare.com/".freeze }
- QA_ENDPOINT =
URI_BUILDER.call('sandbox.')
- PROD_ENDPOINT =
URI_BUILDER.call('')
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.endpoint_for(klass) ⇒ Object
24 25 26 27 28 |
# File 'lib/change_health/connection.rb', line 24 def self.endpoint_for(klass) = ChangeHealth.configuration.endpoints || {} [klass.to_s] || [klass.to_s.to_sym] || klass::ENDPOINT end |
Instance Method Details
#request(endpoint:, query: nil, body: nil, headers: {}, auth: true, verb: :post) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/change_health/connection.rb', line 16 def request(endpoint:, query: nil, body: nil, headers: {}, auth: true, verb: :post) body = body.to_json if body.is_a?(Hash) headers = {} if headers.nil? headers = auth_header.merge(headers) if auth self.class.send(verb.to_s, endpoint, query: query, body: body, headers: headers) end |