module LifenFhir class AppAuthenticatedClient < Client private def handle_errors(response, params) super(response, params) case response.status when 400 raise_error("400 Error, Unknown error", response, params) when 401 raise_error("401 Error, Invalid app bearer", response, params) when 404 raise_error("404 Error, Record not found", response, params) when 422 json = JSON.parse response.body diagnostic = json["issue"][0]["diagnostics"] raise_error("422 Error, Unprocessable Entity, Diagnostic: '#{diagnostic}'", response, params) end end def bearer LifenFhir.configuration.application_access_token end end end