Class: ChangeHealth::Connection

Inherits:
Object
  • Object
show all
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('')

Instance Method Summary collapse

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