Class: ChangeHealthcare::ProfessionalClaims::Wrapper
- Inherits:
-
Object
- Object
- ChangeHealthcare::ProfessionalClaims::Wrapper
- Defined in:
- lib/change_healthcare/professional_claims/wrapper.rb
Overview
Wrapper module, wraps the auto-generated swagger code in a slightly nicer-to-use format.
This is a semi-stateful, thread-safe wrapper. It will get auth tokens for you when needed.
Defined Under Namespace
Classes: AuthToken, BadAuthRequestError, BadAuthorizationError, UnknownAuthError
Instance Method Summary collapse
-
#auth_token ⇒ Object
Obtain a valid authentication token.
-
#health_check ⇒ ChangeHealthcare::ProfessionalClaims::SwaggerClient::HealthCheck
Check health of the API.
-
#initialize(client_id:, client_secret:) ⇒ Wrapper
constructor
A new instance of Wrapper.
-
#process_claim(request, opts = {}) ⇒ ChangeHealthcare::ProfessionalClaims::SwaggerClient::Response
Submits a claim to the payer.
-
#validate_claim(request, opts = {}) ⇒ ChangeHealthcare::ProfessionalClaims::SwaggerClient::Response
Validate the syntax of a claim without submitting it to the payor.
Constructor Details
#initialize(client_id:, client_secret:) ⇒ Wrapper
Returns a new instance of Wrapper.
15 16 17 18 19 20 21 22 |
# File 'lib/change_healthcare/professional_claims/wrapper.rb', line 15 def initialize(client_id:, client_secret:) @client_id = client_id @client_secret = client_secret @api = SwaggerClient::ProfessionalClaimsApi.new # fake auth token that is expired @auth_token = AuthToken.new('', Time.at(0)) @mutex = Mutex.new end |
Instance Method Details
#auth_token ⇒ Object
Obtain a valid authentication token. This method may request a new token if the in-use token is expired. It will do this in a thread-safe manner.
84 85 86 87 88 89 90 |
# File 'lib/change_healthcare/professional_claims/wrapper.rb', line 84 def auth_token @mutex.synchronize do fetch_new_token! unless @auth_token.valid? @auth_token end end |
#health_check ⇒ ChangeHealthcare::ProfessionalClaims::SwaggerClient::HealthCheck
Check health of the API
58 59 60 |
# File 'lib/change_healthcare/professional_claims/wrapper.rb', line 58 def health_check @api.health_check_using_get(auth_token.auth) end |
#process_claim(request, opts = {}) ⇒ ChangeHealthcare::ProfessionalClaims::SwaggerClient::Response
Submits a claim to the payer.
35 36 37 |
# File 'lib/change_healthcare/professional_claims/wrapper.rb', line 35 def process_claim(request, opts = {}) @api.process_claim_using_post(auth_token.auth, request, opts) end |
#validate_claim(request, opts = {}) ⇒ ChangeHealthcare::ProfessionalClaims::SwaggerClient::Response
Validate the syntax of a claim without submitting it to the payor.
50 51 52 |
# File 'lib/change_healthcare/professional_claims/wrapper.rb', line 50 def validate_claim(request, opts = {}) @api.validate_claim_using_post(auth_token.auth, request, opts) end |